mirror of
https://github.com/kdave/btrfs-progs
synced 2025-03-31 23:57:26 +00:00
btrfs-progs: tests: catch bad usage of run_mustfail
This function has an extra argument and can get forgotten, add a sanity check so the bad usage can be caught during development. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
f0c7703671
commit
d7dd9d00e9
25
tests/common
25
tests/common
@ -21,6 +21,26 @@ _assert_path()
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# $1: this string gets matched to files, absolute or relative path, or a
|
||||||
|
# systemwide command available via $PATH
|
||||||
|
_is_file_or_command()
|
||||||
|
{
|
||||||
|
local msg
|
||||||
|
|
||||||
|
msg="$1"
|
||||||
|
if [ -z "$msg" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$msg" -o -d "$msg" -o -b "$msg" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [ -f $(type -p "$msg") ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
_fail()
|
_fail()
|
||||||
{
|
{
|
||||||
echo "$*" | tee -a "$RESULTS"
|
echo "$*" | tee -a "$RESULTS"
|
||||||
@ -185,6 +205,11 @@ run_mustfail()
|
|||||||
msg="$1"
|
msg="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
if _is_file_or_command "$msg"; then
|
||||||
|
echo "ASSERTION FAIL: 1st argument of run_mustfail must be a message"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
ins=$(_get_spec_ins "$@")
|
ins=$(_get_spec_ins "$@")
|
||||||
spec=$(($ins-1))
|
spec=$(($ins-1))
|
||||||
cmd=$(eval echo "\${$spec}")
|
cmd=$(eval echo "\${$spec}")
|
||||||
|
Loading…
Reference in New Issue
Block a user