btrfs-progs: tests: introduce mustfail helper

Invalid syntax, expected failure on corrupted data etc. Failure is
success.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2016-03-22 18:47:18 +01:00
parent 338e5832e7
commit 10d308d5ea

View File

@ -61,6 +61,32 @@ run_mayfail()
fi
}
# first argument is error message to print if it fails, otherwise
# same as run_check but expects the command to fail, output is logged
run_mustfail()
{
local msg
msg="$1"
shift
echo "############### $@" >> $RESULTS 2>&1
if [ "$TEST_LOG" = 'tty' ]; then echo "CMD(mustfail): $@" > /dev/tty; fi
if [ "$1" = 'root_helper' ]; then
"$@" >> $RESULTS 2>&1
else
$INSTRUMENT "$@" >> $RESULTS 2>&1
fi
if [ $? != 0 ]; then
echo "failed (expected): $@" >> $RESULTS
return 0
else
echo "succeeded (unexpected!): $@" >> $RESULTS
_fail "unexpected success: $msg"
return 1
fi
}
check_prereq()
{
if ! [ -f $TOP/$1 ]; then