Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / rcutorture / bin / config2csv.sh
blob0cf55f1bf6548a4440c5d5e55cde723429adbb35
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0+
4 # Create a spreadsheet from torture-test Kconfig options and kernel boot
5 # parameters. Run this in the directory containing the scenario files.
7 # Usage: config2csv path.csv [ "scenario1 scenario2 ..." ]
9 # By default, this script will take the list of scenarios from the CFLIST
10 # file in that directory, otherwise it will consider only the scenarios
11 # specified on the command line. It will examine each scenario's file
12 # and also its .boot file, if present, and create a column in the .csv
13 # output file. Note that "CFLIST" is a synonym for all the scenarios in the
14 # CFLIST file, which allows easy comparison of those scenarios with selected
15 # scenarios such as BUSTED that are normally omitted from CFLIST files.
17 csvout=${1}
18 if test -z "$csvout"
19 then
20 echo "Need .csv output file as first argument."
21 exit 1
23 shift
24 defaultconfigs="`tr '\012' ' ' < CFLIST`"
25 if test "$#" -eq 0
26 then
27 scenariosarg=$defaultconfigs
28 else
29 scenariosarg=$*
31 scenarios="`echo $scenariosarg | sed -e "s/\<CFLIST\>/$defaultconfigs/g"`"
33 T=`mktemp -d /tmp/config2latex.sh.XXXXXX`
34 trap 'rm -rf $T' 0
36 cat << '---EOF---' >> $T/p.awk
37 END {
38 ---EOF---
39 for i in $scenarios
41 echo ' s["'$i'"] = 1;' >> $T/p.awk
42 grep -v '^#' < $i | grep -v '^ *$' > $T/p
43 if test -r $i.boot
44 then
45 tr -s ' ' '\012' < $i.boot | grep -v '^#' >> $T/p
47 sed -e 's/^[^=]*$/&=?/' < $T/p |
48 sed -e 's/^\([^=]*\)=\(.*\)$/\tp["\1:'"$i"'"] = "\2";\n\tc["\1"] = 1;/' >> $T/p.awk
49 done
50 cat << '---EOF---' >> $T/p.awk
51 ns = asorti(s, ss);
52 nc = asorti(c, cs);
53 for (j = 1; j <= ns; j++)
54 printf ",\"%s\"", ss[j];
55 printf "\n";
56 for (i = 1; i <= nc; i++) {
57 printf "\"%s\"", cs[i];
58 for (j = 1; j <= ns; j++) {
59 printf ",\"%s\"", p[cs[i] ":" ss[j]];
61 printf "\n";
64 ---EOF---
65 awk -f $T/p.awk < /dev/null > $T/p.csv
66 cp $T/p.csv $csvout