@@ -52,6 +52,8 @@ rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.report.* $tmp.arglist
SRC_GROUPS="generic"
export SRC_DIR="tests"
+. ./common/exit
+
usage()
{
echo "Usage: $0 [options] [testlist]"'
@@ -40,6 +40,7 @@
#
. common/test_names
+. common/exit
# all tests should use a common language setting to prevent golden
# output mismatches.
@@ -96,15 +97,6 @@ export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
export RECREATE_TEST_DEV=${RECREATE_TEST_DEV:=false}
-# This functions sets the exit code to status and then exits. Don't use
-# exit directly, as it might not set the value of "$status" correctly, which is
-# used as an exit code in the trap handler routine set up by the check script.
-_exit()
-{
- test -n "$1" && status="$1"
- exit "$status"
-}
-
# Handle mkfs.$fstyp which does (or does not) require -f to overwrite
set_mkfs_prog_path_with_opts()
{
@@ -121,12 +113,6 @@ set_mkfs_prog_path_with_opts()
fi
}
-_fatal()
-{
- echo "$*"
- _exit 1
-}
-
export MKFS_PROG="$(type -P mkfs)"
[ "$MKFS_PROG" = "" ] && _fatal "mkfs not found"
new file mode 100644
@@ -0,0 +1,48 @@
+##/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
+#
+# Test termination functions that need to be independent of the context that the
+# test is running in. This must not have any dependencies on common/config or
+# common/rc, as they both require these functions to be defined before they are
+# sourced.
+
+# Exit a context, setting up the test exit status if appropriate.
+#
+# "$status" is the exit code for the trap handler routine set up by the check
+# script, hence we cannot call exit directly from contexts that require $status
+# to be set.
+_exit()
+{
+ test -n "$1" && status="$1"
+ exit "$status"
+}
+
+# Bail out of a test context, setting up .notrun file. Need to kill the
+# filesystem check files here, otherwise they are set incorrectly for the next
+# test.
+_notrun()
+{
+ echo "$*" > $seqres.notrun
+ echo "$seq not run: $*"
+ rm -f ${RESULT_DIR}/require_test*
+ rm -f ${RESULT_DIR}/require_scratch*
+
+ _exit 0
+}
+
+# Exit a test immediately with a fatal error.
+_fail()
+{
+ echo "$*" | tee -a $seqres.full
+ echo "(see $seqres.full for details)"
+ _exit 1
+}
+
+# Exit any context with a fatal error.
+_fatal()
+{
+ echo "$*"
+ _exit 1
+}
+
@@ -49,6 +49,7 @@ _begin_fstest()
_register_cleanup _cleanup
+ . ./common/exit
. ./common/rc
init_rc
@@ -1798,28 +1798,6 @@ _do()
return $ret
}
-# bail out, setting up .notrun file. Need to kill the filesystem check files
-# here, otherwise they are set incorrectly for the next test.
-#
-_notrun()
-{
- echo "$*" > $seqres.notrun
- echo "$seq not run: $*"
- rm -f ${RESULT_DIR}/require_test*
- rm -f ${RESULT_DIR}/require_scratch*
-
- _exit 0
-}
-
-# just plain bail out
-#
-_fail()
-{
- echo "$*" | tee -a $seqres.full
- echo "(see $seqres.full for details)"
- _exit 1
-}
-
#
# Tests whether $FSTYP should be exclude from this test.
#