config2csv.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. csvout=${1}
  17. if test -z "$csvout"
  18. then
  19. echo "Need .csv output file as first argument."
  20. exit 1
  21. fi
  22. shift
  23. defaultconfigs="`tr '\012' ' ' < CFLIST`"
  24. if test "$#" -eq 0
  25. then
  26. scenariosarg=$defaultconfigs
  27. else
  28. scenariosarg=$*
  29. fi
  30. scenarios="`echo $scenariosarg | sed -e "s/\<CFLIST\>/$defaultconfigs/g"`"
  31. T=`mktemp -d /tmp/config2latex.sh.XXXXXX`
  32. trap 'rm -rf $T' 0
  33. cat << '---EOF---' >> $T/p.awk
  34. END {
  35. ---EOF---
  36. for i in $scenarios
  37. do
  38. echo ' s["'$i'"] = 1;' >> $T/p.awk
  39. grep -v '^#' < $i | grep -v '^ *$' > $T/p
  40. if test -r $i.boot
  41. then
  42. sed -e 's/#.*$//' < $i.boot | tr -s ' ' '\012' >> $T/p
  43. fi
  44. sed -e 's/^[^=]*$/&=?/' < $T/p |
  45. sed -e 's/^\([^=]*\)=\(.*\)$/\tp["\1:'"$i"'"] = "\2";\n\tc["\1"] = 1;/' >> $T/p.awk
  46. done
  47. cat << '---EOF---' >> $T/p.awk
  48. ns = asorti(s, ss);
  49. nc = asorti(c, cs);
  50. for (j = 1; j <= ns; j++)
  51. printf ",\"%s\"", ss[j];
  52. printf "\n";
  53. for (i = 1; i <= nc; i++) {
  54. printf "\"%s\"", cs[i];
  55. for (j = 1; j <= ns; j++) {
  56. printf ",\"%s\"", p[cs[i] ":" ss[j]];
  57. }
  58. printf "\n";
  59. }
  60. }
  61. ---EOF---
  62. awk -f $T/p.awk < /dev/null > $T/p.csv
  63. cp $T/p.csv $csvout