mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-23 21:35:29 +03:00
Add a workaround for missing losetup -s
by jstava, and a print a stacktrace
on errors (also by jstava). Currently requires bash, a fix for that may come later -- explicitly using bash to run tests in the meantime.
This commit is contained in:
parent
c8584e1cce
commit
4d534dd7e4
@ -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."
|
||||
|
@ -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
|
||||
trap 'aux teardown' EXIT # don't forget to clean up
|
||||
trap 'set +vex; STACKTRACE; set -vex' ERR
|
||||
#trap - ERR
|
||||
|
||||
LOOPFILE=test.img
|
||||
dd if=/dev/zero of=test.img bs=$((1024*1024)) count=1 seek=$(($size-1))
|
||||
LOOP=`losetup -s -f test.img`
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user