summaryrefslogtreecommitdiff
path: root/tests/common
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/common b/tests/common
index 61780486..91682eff 100644
--- a/tests/common
+++ b/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