xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 499
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 499
6 #
7 # Look for stringified constants in the __print_symbolic format strings,
8 # which suggest that we forgot to TRACE_DEFINE_ENUM somewhere, which causes
9 # incomplete ftrace reporting.
10 #
11 . ./common/preamble
12 _begin_fstest auto quick
13
14 _register_cleanup "_cleanup" BUS
15
16 # Import common functions.
17
18 # real QA test starts here
19 _supported_fs xfs
20 _require_command "$CC_PROG" "cc"
21
22 cprog=$tmp.ftrace.c
23 oprog=$tmp.ftrace
24 sedprog=$tmp.ftrace.sed
25
26 ftrace_dir=$DEBUGFS_MNT/tracing/events/xfs
27
28 test -d $ftrace_dir || _notrun "ftrace not enabled"
29
30 # The second argument to __print_symbolic is stringified in the tracepoint's
31 # fmt file, so we look for "{ NUM, STRING }" and try to separate each of them
32 # into single lines so that we can build a C structure.  This will (we hope)
33 # catch non-constant numbers that the compiler won't know about.
34 cat > $sedprog << ENDL
35 s/}, /},\n/g
36 s/}),/},\n/g
37 s/})/},\n/g
38 s/, {/\n{/g
39 ENDL
40
41 cat > $cprog << ENDL
42 struct ftrace_chk {
43         unsigned long long      num;
44         char                    *str;
45 } syms[] = {
46 ENDL
47 egrep '(__print_flags|__print_symbolic)' $ftrace_dir*/*/format | \
48         sed -f $sedprog | grep '^{' | sort | uniq >> $cprog
49 cat >> $cprog << ENDL
50 };
51
52 int main(int argc, char *argv[]) { return 0; }
53 ENDL
54
55 cat $cprog >> $seqres.full
56 echo Compiler errors imply missing TRACE_DEFINE_ENUM.
57 $CC_PROG -o $oprog $cprog
58
59 # success, all done
60 echo Silence is golden
61 status=0
62 exit