runlitmushist.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0+
  3. #
  4. # Runs the C-language litmus tests specified on standard input, using up
  5. # to the specified number of CPUs (defaulting to all of them) and placing
  6. # the results in the specified directory (defaulting to the same place
  7. # the litmus test came from).
  8. #
  9. # sh runlitmushist.sh
  10. #
  11. # Run from the Linux kernel tools/memory-model directory.
  12. # This script uses environment variables produced by parseargs.sh.
  13. #
  14. # Copyright IBM Corporation, 2018
  15. #
  16. # Author: Paul E. McKenney <paulmck@linux.ibm.com>
  17. . scripts/hwfnseg.sh
  18. T=/tmp/runlitmushist.sh.$$
  19. trap 'rm -rf $T' 0
  20. mkdir $T
  21. if test -d litmus
  22. then
  23. :
  24. else
  25. echo Directory \"litmus\" missing, aborting run.
  26. exit 1
  27. fi
  28. # Prefixes for per-CPU scripts
  29. for ((i=0;i<$LKMM_JOBS;i++))
  30. do
  31. echo T=$T >> $T/$i.sh
  32. cat << '___EOF___' >> $T/$i.sh
  33. runtest () {
  34. if scripts/runlitmus.sh $1
  35. then
  36. if ! grep -q '^Observation ' $LKMM_DESTDIR/$1$2.out
  37. then
  38. echo ' !!! Herd failed, no Observation:' $1
  39. fi
  40. else
  41. exitcode=$?
  42. if test "$exitcode" -eq 124
  43. then
  44. exitmsg="timed out"
  45. elif test "$exitcode" -eq 253
  46. then
  47. exitmsg=
  48. else
  49. exitmsg="failed, exit code $exitcode"
  50. fi
  51. if test -n "$exitmsg"
  52. then
  53. echo ' !!! Herd' ${exitmsg}: $1
  54. fi
  55. fi
  56. }
  57. ___EOF___
  58. done
  59. awk -v q="'" -v b='\\' '
  60. {
  61. print "echo `grep " q "^P[0-9]" b "+(" q " " $0 " | tail -1 | sed -e " q "s/^P" b "([0-9]" b "+" b ")(.*$/" b "1/" q "` " $0
  62. }' | sh | sort -k1n |
  63. awk -v dq='"' -v hwfnseg="$hwfnseg" -v ncpu="$LKMM_JOBS" -v t="$T" '
  64. {
  65. print "if test -z " dq hwfnseg dq " || scripts/simpletest.sh " dq $2 dq
  66. print "then"
  67. print "\techo runtest " dq $2 dq " " hwfnseg " >> " t "/" NR % ncpu ".sh";
  68. print "fi"
  69. }
  70. END {
  71. for (i = 0; i < ncpu; i++) {
  72. print "sh " t "/" i ".sh > " t "/" i ".sh.out 2>&1 &";
  73. close(t "/" i ".sh");
  74. }
  75. print "wait";
  76. }' | sh
  77. cat $T/*.sh.out
  78. if grep -q '!!!' $T/*.sh.out
  79. then
  80. echo ' ---' Summary: 1>&2
  81. grep '!!!' $T/*.sh.out 1>&2
  82. nfail="`grep '!!!' $T/*.sh.out | wc -l`"
  83. echo 'Number of failed herd7 runs (e.g., timeout): ' $nfail 1>&2
  84. exit 1
  85. else
  86. echo All runs completed successfully. 1>&2
  87. exit 0
  88. fi