1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0+ 3# 4# Create a spreadsheet from torture-test Kconfig options and kernel boot 5# 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 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. 16 17csvout=${1} 18if test -z "$csvout" 19then 20 echo "Need .csv output file as first argument." 21 exit 1 22fi 23shift 24defaultconfigs="`tr '\012' ' ' < CFLIST`" 25if test "$#" -eq 0 26then 27 scenariosarg=$defaultconfigs 28else 29 scenariosarg=$* 30fi 31scenarios="`echo $scenariosarg | sed -e "s/\<CFLIST\>/$defaultconfigs/g"`" 32 33T=`mktemp -d /tmp/config2latex.sh.XXXXXX` 34trap 'rm -rf $T' 0 35 36cat << '---EOF---' >> $T/p.awk 37END { 38---EOF--- 39for i in $scenarios 40do 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 46 fi 47 sed -e 's/^[^=]*$/&=?/' < $T/p | 48 sed -e 's/^\([^=]*\)=\(.*\)$/\tp["\1:'"$i"'"] = "\2";\n\tc["\1"] = 1;/' >> $T/p.awk 49done 50cat << '---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]]; 60 } 61 printf "\n"; 62 } 63} 64---EOF--- 65awk -f $T/p.awk < /dev/null > $T/p.csv 66cp $T/p.csv $csvout 67