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/."
24 rm -f $new_groups.check
28 ret=1 # trigger cleanup of temporary files unless we succeed
29 trap 'cleanup; exit $ret' EXIT INT TERM QUIT
31 # Make sure each group is in the documentation file.
33 test -n "$GROUPNAME_DOC_FILE" || return 0
38 for group in `grep -v '#' $groups`; do
39 if ! grep -q "^${group}[[:space:]]" "$GROUPNAME_DOC_FILE"; then
40 missing+=("\"${group}\"")
43 test "${#missing}" -eq 0 && return 0
46 test "${#missing}" -gt 1 && suffix="s"
47 echo "group$suffix ${missing[@]} not mentioned in documentation." 1>&2
52 generate_groupfile() {
53 cat << ENDL > $new_groups
54 # QA groups control file, automatically generated.
55 # See _begin_fstest in each test for details.
61 # Aggregate the groups each test belongs to for the group file
62 grep -I -R "^_begin_fstest" $test_dir/ | \
63 sed -e 's/^.*\/\([0-9]*\):_begin_fstest/\1/' >> $new_groups
65 # Create the list of unique groups for existence checking
66 grep -I -R "^_begin_fstest" $test_dir/ | \
67 sed -e 's/^.*_begin_fstest //' -e 's/ /\n/g' | \
68 sort -u > $new_groups.check
70 _check_groups $new_groups.check
75 if [ -z "$groupfile" ] || [ "$groupfile" = "-" ]; then
76 # Dump the group file to stdout and exit
81 # Otherwise, write the group file to disk somewhere.
83 mv -f "$new_groups" "$groupfile"