2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
5 # Boilerplate fstests functionality
7 # Standard cleanup function. Individual tests can override this.
14 # Install the supplied cleanup code as a signal handler for HUP, INT, QUIT,
15 # TERM, or when the test exits. Extra signals can be specified as subsequent
22 test -n "$cleanup" && cleanup="${cleanup}; "
23 trap "${cleanup}exit \$status" EXIT HUP INT QUIT TERM $*
26 # Make sure each group is in the documentation file.
28 test -n "$GROUPNAME_DOC_FILE" || return 0
30 local testname="$(echo "$0" | sed -e 's/^.*tests\///g')"
34 if ! grep -q "^${group}[[:space:]]" "$GROUPNAME_DOC_FILE"; then
35 missing+=("\"${group}\"")
38 test "${#missing}" -eq 0 && return 0
41 test "${#missing}" -gt 1 && suffix="s"
42 echo "$testname: group$suffix ${missing[@]} not mentioned in documentation." 1>&2
46 # Prepare to run a fstest by initializing the required global variables to
47 # their defaults, sourcing common functions, registering a cleanup function,
48 # and removing the $seqres.full file.
50 # The list of group memberships for this test (e.g. auto quick rw) must be
51 # passed as arguments to this helper. It is not necessary to name this test
52 # explicitly as a member of the 'all' group.
55 if [ -n "$seq" ]; then
56 echo "_begin_fstest can only be called once!"
62 # If we're only running the test to generate a group.list file,
63 # spit out the group data and exit.
64 if [ -n "$GENERATE_GROUPS" ]; then
65 _check_groups "$@" || exit 1
70 seqres=$RESULT_DIR/$seq
71 echo "QA output created by $seq"
75 status=1 # failure is the default!
77 _register_cleanup _cleanup
81 # remove previous $seqres.full before test
82 rm -f $seqres.full $seqres.hints