]> sourceware.org Git - lvm2.git/commitdiff
Add a workaround for missing `losetup -s` by jstava, and a print a stacktrace
authorPetr Rockai <prokai@redhat.com>
Mon, 6 Oct 2008 16:55:30 +0000 (16:55 +0000)
committerPetr Rockai <prokai@redhat.com>
Mon, 6 Oct 2008 16:55:30 +0000 (16:55 +0000)
on errors (also by jstava). Currently requires bash, a fix for that may come
later -- explicitly using bash to run tests in the meantime.

test/harness.sh
test/test-utils.sh

index dbd6f51de3b9b7290d43230893374aa8dca56927..8913322733894334927c12f273a635b6e7e3acdc 100644 (file)
@@ -5,7 +5,7 @@ test -z "$tests" && tests=`echo t-*.sh`
 
 for t in $tests; do
     printf "Running %-40s" "$t ..."
-    out=`sh ./$t 2>&1`
+    out=`bash ./$t 2>&1`
     ret=$?
     if test $ret = 0; then
        echo " passed."
index 1b32fa9ffe0c5d67c0406fab4ef38ab73132e88a..cf4b9444e3acf67c786ec4b6f79f37332dcca284 100644 (file)
@@ -14,10 +14,20 @@ test_description="foo" # silence test-lib for now
 aux() {
     # use just "$@" for verbose operation
     "$@" > /dev/null 2> /dev/null
+       #"$@"
 }
 
 not () { "$@" && exit 1 || return 0; }
 
+STACKTRACE() {
+       trap - ERR;
+       i=0;
+       while FUNC=${FUNCNAME[$i]}; test "$FUNC" != "main"; do 
+               echo "$i ${FUNC}() called from ${BASH_SOURCE[$i]}:${BASH_LINENO[$i]}"
+               i=$(($i + 1));
+       done
+}      
+
 teardown() {
     echo $LOOP
     echo $PREFIX
@@ -50,11 +60,32 @@ prepare_loop() {
     test -n "$size" || size=32
 
     test -n "$LOOP" && return 0
-    trap "aux teardown" EXIT # don't forget to clean up
-
-    LOOPFILE=test.img
-    dd if=/dev/zero of=test.img bs=$((1024*1024)) count=1 seek=$(($size-1))
-    LOOP=`losetup -s -f test.img`
+       trap 'aux teardown' EXIT # don't forget to clean up
+       trap 'set +vex; STACKTRACE; set -vex' ERR
+       #trap - ERR
+
+       LOOPFILE="$PWD/test.img"
+       dd if=/dev/zero of="$LOOPFILE" bs=$((1024*1024)) count=1 seek=$(($size-1))
+       if LOOP=`losetup -s -f "$LOOPFILE" 2>/dev/null`; then
+               return 0
+       elif LOOP=`losetup -f` && losetup $LOOP "$LOOPFILE"; then
+               # no -s support
+               return 0
+       else
+               # no -f support 
+               # Iterate through $G_dev_/loop{,/}{0,1,2,3,4,5,6,7,8,9}
+               for slash in '' /; do
+                       for i in 0 1 2 3 4 5 6 7 8 9; do
+                               local dev=$G_dev_/loop$slash$i
+                               ! losetup $dev >/dev/null 2>&1 || continue
+                               # got a free
+                               losetup "$dev" "$LOOPFILE"
+                               LOOP=$dev
+                       done
+               done
+               test -n "LOOP" # confirm or fail
+       fi
+       exit 1 # should not be accesible
 }
 
 prepare_devs() {
@@ -142,6 +173,6 @@ prepare_lvmconf() {
 EOF
 }
 
-set -vex
+set -vexE
 aux prepare_lvmconf
 
This page took 0.042757 seconds and 5 git commands to generate.