generic/019: don't dump cores when fio/fsstress hit io errors
[xfstests-dev.git] / common / preamble
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4
5 # Boilerplate fstests functionality
6
7 # Standard cleanup function.  Individual tests can override this.
8 _cleanup()
9 {
10         cd /
11         rm -r -f $tmp.*
12 }
13
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
16 # parameters.
17 _register_cleanup()
18 {
19         local cleanup="$1"
20         shift
21
22         test -n "$cleanup" && cleanup="${cleanup}; "
23         trap "${cleanup}exit \$status" EXIT HUP INT QUIT TERM $*
24 }
25
26 # Prepare to run a fstest by initializing the required global variables to
27 # their defaults, sourcing common functions, registering a cleanup function,
28 # and removing the $seqres.full file.
29 #
30 # The list of group memberships for this test (e.g. auto quick rw) must be
31 # passed as arguments to this helper.  It is not necessary to name this test
32 # explicitly as a member of the 'all' group.
33 _begin_fstest()
34 {
35         if [ -n "$seq" ]; then
36                 echo "_begin_fstest can only be called once!"
37                 exit 1
38         fi
39
40         seq=`basename $0`
41
42         # If we're only running the test to generate a group.list file,
43         # spit out the group data and exit.
44         if [ -n "$GENERATE_GROUPS" ]; then
45                 echo "$seq $@"
46                 exit 0
47         fi
48
49         seqres=$RESULT_DIR/$seq
50         echo "QA output created by $seq"
51
52         here=`pwd`
53         tmp=/tmp/$$
54         status=1        # failure is the default!
55
56         _register_cleanup _cleanup
57
58         . ./common/rc
59
60         # remove previous $seqres.full before test
61         rm -f $seqres.full
62
63 }