blob: 64d793850718b490c11978dbab51a597689128eb [file] [log] [blame]
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2021 Oracle. All Rights Reserved.
# Boilerplate fstests functionality
# Standard cleanup function. Individual tests can override this.
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.
local cleanup="$1"
test -n "$cleanup" && cleanup="${cleanup}; "
trap "${cleanup}exit \$status" EXIT HUP INT QUIT TERM $*
# Make sure each group is in the documentation file.
_check_groups() {
test -n "$GROUPNAME_DOC_FILE" || return 0
local testname="$(echo "$0" | sed -e 's/^.*tests\///g')"
declare -a missing=()
for group in "$@"; do
if ! grep -q "^${group}[[:space:]]" "$GROUPNAME_DOC_FILE"; then
test "${#missing}" -eq 0 && return 0
local suffix=
test "${#missing}" -gt 1 && suffix="s"
echo "$testname: group$suffix ${missing[@]} not mentioned in documentation." 1>&2
return 1
# 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.
if [ -n "$seq" ]; then
echo "_begin_fstest can only be called once!"
exit 1
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
_check_groups "$@" || exit 1
echo "$seq $@"
exit 0
echo "QA output created by $seq"
status=1 # failure is the default!
_register_cleanup _cleanup
. ./common/rc
# remove previous $seqres.full before test
rm -f $seqres.full