summaryrefslogtreecommitdiff
path: root/tests/xfs/499
blob: 383e57192d4226f446b6f3714e31e7c5d6e2602b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc.  All Rights Reserved.
#
# FS QA Test No. 499
#
# Look for stringified constants in the __print_symbolic format strings,
# which suggest that we forgot to TRACE_DEFINE_ENUM somewhere, which causes
# incomplete ftrace reporting.
#
. ./common/preamble
_begin_fstest auto quick

_register_cleanup "_cleanup" BUS

. ./common/tracing

# real QA test starts here
_supported_fs xfs
_require_ftrace
_require_command "$CC_PROG" "cc"

cprog=$tmp.ftrace.c
oprog=$tmp.ftrace
sedprog=$tmp.ftrace.sed

ftrace_dir=$FTRACE_ROOT/events/xfs

# The second argument to __print_symbolic is stringified in the tracepoint's
# fmt file, so we look for "{ NUM, STRING }" and try to separate each of them
# into single lines so that we can build a C structure.  This will (we hope)
# catch non-constant numbers that the compiler won't know about.
cat > $sedprog << ENDL
s/}, /},\n/g
s/}),/},\n/g
s/})/},\n/g
s/, {/\n{/g
ENDL

cat > $cprog << ENDL
struct ftrace_chk {
	unsigned long long	num;
	char			*str;
} syms[] = {
ENDL
grep -E '(__print_flags|__print_symbolic)' $ftrace_dir*/*/format | \
	sed -f $sedprog | grep '^{' | sort | uniq >> $cprog
cat >> $cprog << ENDL
};

int main(int argc, char *argv[]) { return 0; }
ENDL

cat $cprog >> $seqres.full
echo Compiler errors imply missing TRACE_DEFINE_ENUM.
$CC_PROG -o $oprog $cprog

# success, all done
echo Silence is golden
status=0
exit