67 lines · bash
1#!/bin/sh2# SPDX-License-Identifier: GPL-2.0+3#4# Create a spreadsheet from torture-test Kconfig options and kernel boot5# parameters. Run this in the directory containing the scenario files.6#7# Usage: config2csv path.csv [ "scenario1 scenario2 ..." ]8#9# By default, this script will take the list of scenarios from the CFLIST10# file in that directory, otherwise it will consider only the scenarios11# specified on the command line. It will examine each scenario's file12# and also its .boot file, if present, and create a column in the .csv13# output file. Note that "CFLIST" is a synonym for all the scenarios in the14# CFLIST file, which allows easy comparison of those scenarios with selected15# scenarios such as BUSTED that are normally omitted from CFLIST files.16 17csvout=${1}18if test -z "$csvout"19then20 echo "Need .csv output file as first argument."21 exit 122fi23shift24defaultconfigs="`tr '\012' ' ' < CFLIST`"25if test "$#" -eq 026then27 scenariosarg=$defaultconfigs28else29 scenariosarg=$*30fi31scenarios="`echo $scenariosarg | sed -e "s/\<CFLIST\>/$defaultconfigs/g"`"32 33T=`mktemp -d /tmp/config2latex.sh.XXXXXX`34trap 'rm -rf $T' 035 36cat << '---EOF---' >> $T/p.awk37END {38---EOF---39for i in $scenarios40do41 echo ' s["'$i'"] = 1;' >> $T/p.awk42 grep -v '^#' < $i | grep -v '^ *$' > $T/p43 if test -r $i.boot44 then45 tr -s ' ' '\012' < $i.boot | grep -v '^#' >> $T/p46 fi47 sed -e 's/^[^=]*$/&=?/' < $T/p |48 sed -e 's/^\([^=]*\)=\(.*\)$/\tp["\1:'"$i"'"] = "\2";\n\tc["\1"] = 1;/' >> $T/p.awk49done50cat << '---EOF---' >> $T/p.awk51 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]];60 }61 printf "\n";62 }63}64---EOF---65awk -f $T/p.awk < /dev/null > $T/p.csv66cp $T/p.csv $csvout67