[lvm-devel] master - tests: correcting globbing usage

Zdenek Kabelac zkabelac at sourceware.org
Fri Jun 30 15:10:28 UTC 2017


Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=57779e39eccf456344fa4a51ddfc49cee41a40d7
Commit:        57779e39eccf456344fa4a51ddfc49cee41a40d7
Parent:        9348ad4f164a2d8806b08f28a937aaa1041b4f6b
Author:        Zdenek Kabelac <zkabelac at redhat.com>
AuthorDate:    Fri Jun 30 14:28:44 2017 +0200
Committer:     Zdenek Kabelac <zkabelac at redhat.com>
CommitterDate: Fri Jun 30 14:40:50 2017 +0200

tests: correcting  globbing usage

Ensure globbing uses current dir.
Break loop when no match is found.
Let STACKTRACE finish its output when gdb fails.
---
 test/lib/utils.sh |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index 4f3e460..2b5b782 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -120,7 +120,7 @@ stacktrace() {
 
 STACKTRACE() {
 	trap - ERR
-	local i=0
+	local i
 
 	stacktrace
 
@@ -134,10 +134,12 @@ STACKTRACE() {
 		echo bt full > gdb_commands.txt
 		echo l >> gdb_commands.txt
 		echo quit >> gdb_commands.txt
-		for core in $(echo core* 2>/dev/null); do
-			bin=$(gdb -batch -c "$core" 2>&1 | grep "generated by" | \
-			sed -e "s,.*generated by \`\([^ ']*\).*,\1,")
-			gdb -batch -c "$core" -x gdb_commands.txt "$(which "$bin")"
+		# TODO: use sysctl to get 'core' position in system
+		for i in core*; do
+			test -f "$i" || break   # empty globbing
+			bin=$(gdb -batch -c "$i" 2>&1 | grep "generated by" | \
+			sed -e "s,.*generated by \`\([^ ']*\).*,\1,") || continue
+			gdb -batch -c "$i" -x gdb_commands.txt "$(which "$bin")" || continue
 		done
 	fi
 




More information about the lvm-devel mailing list