mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-23 22:53:35 +00:00
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:
parent
338e5832e7
commit
10d308d5ea
26
tests/common
26
tests/common
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user