Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0+
0003 #
0004 # Create a spreadsheet from torture-test Kconfig options and kernel boot
0005 # parameters.  Run this in the directory containing the scenario files.
0006 #
0007 # Usage: config2csv path.csv [ "scenario1 scenario2 ..." ]
0008 #
0009 # By default, this script will take the list of scenarios from the CFLIST
0010 # file in that directory, otherwise it will consider only the scenarios
0011 # specified on the command line.  It will examine each scenario's file
0012 # and also its .boot file, if present, and create a column in the .csv
0013 # output file.  Note that "CFLIST" is a synonym for all the scenarios in the
0014 # CFLIST file, which allows easy comparison of those scenarios with selected
0015 # scenarios such as BUSTED that are normally omitted from CFLIST files.
0016 
0017 csvout=${1}
0018 if test -z "$csvout"
0019 then
0020         echo "Need .csv output file as first argument."
0021         exit 1
0022 fi
0023 shift
0024 defaultconfigs="`tr '\012' ' ' < CFLIST`"
0025 if test "$#" -eq 0
0026 then
0027         scenariosarg=$defaultconfigs
0028 else
0029         scenariosarg=$*
0030 fi
0031 scenarios="`echo $scenariosarg | sed -e "s/\<CFLIST\>/$defaultconfigs/g"`"
0032 
0033 T=/tmp/config2latex.sh.$$
0034 trap 'rm -rf $T' 0
0035 mkdir $T
0036 
0037 cat << '---EOF---' >> $T/p.awk
0038 END     {
0039 ---EOF---
0040 for i in $scenarios
0041 do
0042         echo '  s["'$i'"] = 1;' >> $T/p.awk
0043         grep -v '^#' < $i | grep -v '^ *$' > $T/p
0044         if test -r $i.boot
0045         then
0046                 tr -s ' ' '\012' < $i.boot | grep -v '^#' >> $T/p
0047         fi
0048         sed -e 's/^[^=]*$/&=?/' < $T/p |
0049         sed -e 's/^\([^=]*\)=\(.*\)$/\tp["\1:'"$i"'"] = "\2";\n\tc["\1"] = 1;/' >> $T/p.awk
0050 done
0051 cat << '---EOF---' >> $T/p.awk
0052         ns = asorti(s, ss);
0053         nc = asorti(c, cs);
0054         for (j = 1; j <= ns; j++)
0055                 printf ",\"%s\"", ss[j];
0056         printf "\n";
0057         for (i = 1; i <= nc; i++) {
0058                 printf "\"%s\"", cs[i];
0059                 for (j = 1; j <= ns; j++) {
0060                         printf ",\"%s\"", p[cs[i] ":" ss[j]];
0061                 }
0062                 printf "\n";
0063         }
0064 }
0065 ---EOF---
0066 awk -f $T/p.awk < /dev/null > $T/p.csv
0067 cp $T/p.csv $csvout