Files
apfstests/common/preamble
T
Darrick J. Wong 17f6ac8ecc fstests: automatically generate group files
Now that we've moved the group membership details into the test case
files themselves, automatically generate the group files during build.
The autogenerated files are named "group.list" instead of "group" to
avoid conflicts between generated and (stale) SCM files as everyone
rebases.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-06-27 22:50:06 +08:00

64 lines
1.4 KiB
Bash

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2021 Oracle. All Rights Reserved.
# Boilerplate fstests functionality
# Standard cleanup function. Individual tests can override this.
_cleanup()
{
cd /
rm -r -f $tmp.*
}
# Install the supplied cleanup code as a signal handler for HUP, INT, QUIT,
# TERM, or when the test exits. Extra signals can be specified as subsequent
# parameters.
_register_cleanup()
{
local cleanup="$1"
shift
test -n "$cleanup" && cleanup="${cleanup}; "
trap "${cleanup}exit \$status" EXIT HUP INT QUIT TERM $*
}
# Prepare to run a fstest by initializing the required global variables to
# their defaults, sourcing common functions, registering a cleanup function,
# and removing the $seqres.full file.
#
# The list of group memberships for this test (e.g. auto quick rw) must be
# passed as arguments to this helper. It is not necessary to name this test
# explicitly as a member of the 'all' group.
_begin_fstest()
{
if [ -n "$seq" ]; then
echo "_begin_fstest can only be called once!"
exit 1
fi
seq=`basename $0`
# If we're only running the test to generate a group.list file,
# spit out the group data and exit.
if [ -n "$GENERATE_GROUPS" ]; then
echo "$seq $@"
exit 0
fi
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_register_cleanup _cleanup
. ./common/rc
# remove previous $seqres.full before test
rm -f $seqres.full
}