2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
5 # Generate a group file from the _begin_fstest call in each test.
7 if [ "$1" = "--help" ]; then
8 echo "Usage: (cd tests/XXX/ ; ../../tools/mkgroupfile [output])"
14 new_groups="/tmp/groups.$$"
15 GROUPNAME_DOC_FILE="$(readlink -m ../../doc/group-names.txt)"
17 if [ ! -x ../../check ]; then
18 echo "$0: Run this from tests/XXX/."
22 . ../../common/test_names
26 rm -f $new_groups.check
30 ret=1 # trigger cleanup of temporary files unless we succeed
31 trap 'cleanup; exit $ret' EXIT INT TERM QUIT
33 # Make sure each group is in the documentation file.
35 test -n "$GROUPNAME_DOC_FILE" || return 0
40 for group in `grep -v '#' $groups`; do
41 if ! grep -q "^${group}[[:space:]]" "$GROUPNAME_DOC_FILE"; then
42 missing+=("\"${group}\"")
45 test "${#missing}" -eq 0 && return 0
48 test "${#missing}" -gt 1 && suffix="s"
49 echo "group$suffix ${missing[@]} not mentioned in documentation." 1>&2
54 generate_groupfile() {
55 cat << ENDL > $new_groups
56 # QA groups control file, automatically generated.
57 # See _begin_fstest in each test for details.
63 # Aggregate the groups each test belongs to for the group file
64 grep -I -R "^_begin_fstest" $test_dir/ | \
65 sed -e "s/^.*\/\($VALID_TEST_NAME\):_begin_fstest/\1/" \
68 # Create the list of unique groups for existence checking
69 grep -I -R "^_begin_fstest" $test_dir/ | \
70 sed -e 's/^.*_begin_fstest //' -e 's/ /\n/g' | \
71 sort -u > $new_groups.check
73 _check_groups $new_groups.check
78 if [ -z "$groupfile" ] || [ "$groupfile" = "-" ]; then
79 # Dump the group file to stdout and exit
84 # Otherwise, write the group file to disk somewhere.
86 mv -f "$new_groups" "$groupfile"