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=/tmp/config2latex.sh.$$ 34trap 'rm -rf $T' 0 35mkdir $T 36 37cat << '---EOF---' >> $T/p.awk 38END { 39---EOF--- 40for i in $scenarios 41do 42 echo ' s["'$i'"] = 1;' >> $T/p.awk 43 grep -v '^#' < $i | grep -v '^ *$' > $T/p 44 if test -r $i.boot 45 then 46 tr -s ' ' '\012' < $i.boot | grep -v '^#' >> $T/p 47 fi 48 sed -e 's/^[^=]*$/&=?/' < $T/p | 49 sed -e 's/^\([^=]*\)=\(.*\)$/\tp["\1:'"$i"'"] = "\2";\n\tc["\1"] = 1;/' >> $T/p.awk 50done 51cat << '---EOF---' >> $T/p.awk 52 ns = asorti(s, ss); 53 nc = asorti(c, cs); 54 for (j = 1; j <= ns; j++) 55 printf ",\"%s\"", ss[j]; 56 printf "\n"; 57 for (i = 1; i <= nc; i++) { 58 printf "\"%s\"", cs[i]; 59 for (j = 1; j <= ns; j++) { 60 printf ",\"%s\"", p[cs[i] ":" ss[j]]; 61 } 62 printf "\n"; 63 } 64} 65---EOF--- 66awk -f $T/p.awk < /dev/null > $T/p.csv 67cp $T/p.csv $csvout 68