1
0

runlitmus.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0+
  3. #
  4. # Without the -hw argument, runs a herd7 test and outputs verification
  5. # results to a file whose name is that of the specified litmus test,
  6. # but with ".out" appended.
  7. #
  8. # If the --hw argument is specified, this script translates the .litmus
  9. # C-language file to the specified type of assembly and verifies that.
  10. # But in this case, litmus tests using complex synchronization (such as
  11. # locking, RCU, and SRCU) are cheerfully ignored.
  12. #
  13. # Either way, return the status of the herd7 command.
  14. #
  15. # Usage:
  16. # runlitmus.sh file.litmus
  17. #
  18. # Run this in the directory containing the memory model, specifying the
  19. # pathname of the litmus test to check. The caller is expected to have
  20. # properly set up the LKMM environment variables.
  21. #
  22. # Copyright IBM Corporation, 2019
  23. #
  24. # Author: Paul E. McKenney <paulmck@linux.ibm.com>
  25. litmus=$1
  26. if test -f "$litmus" -a -r "$litmus"
  27. then
  28. :
  29. else
  30. echo ' !!! ' error: \"$litmus\" is not a readable file
  31. exit 255
  32. fi
  33. if test -z "$LKMM_HW_MAP_FILE" -o ! -e $LKMM_DESTDIR/$litmus.out
  34. then
  35. # LKMM run
  36. herdoptions=${LKMM_HERD_OPTIONS--conf linux-kernel.cfg}
  37. echo Herd options: $herdoptions > $LKMM_DESTDIR/$litmus.out
  38. /usr/bin/time $LKMM_TIMEOUT_CMD herd7 $herdoptions $litmus >> $LKMM_DESTDIR/$litmus.out 2>&1
  39. ret=$?
  40. if test -z "$LKMM_HW_MAP_FILE"
  41. then
  42. exit $ret
  43. fi
  44. echo " --- " Automatically generated LKMM output for '"'--hw $LKMM_HW_MAP_FILE'"' run
  45. fi
  46. # Hardware run
  47. T=/tmp/checklitmushw.sh.$$
  48. trap 'rm -rf $T' 0 2
  49. mkdir $T
  50. # Generate filenames
  51. mapfile="Linux2${LKMM_HW_MAP_FILE}.map"
  52. themefile="$T/${LKMM_HW_MAP_FILE}.theme"
  53. herdoptions="-model $LKMM_HW_CAT_FILE"
  54. hwlitmus=`echo $litmus | sed -e 's/\.litmus$/.litmus.'${LKMM_HW_MAP_FILE}'/'`
  55. hwlitmusfile=`echo $hwlitmus | sed -e 's,^.*/,,'`
  56. # Don't run on litmus tests with complex synchronization
  57. if ! scripts/simpletest.sh $litmus
  58. then
  59. echo ' --- ' error: \"$litmus\" contains locking, RCU, or SRCU
  60. exit 254
  61. fi
  62. # Generate the assembly code and run herd7 on it.
  63. gen_theme7 -n 10 -map $mapfile -call Linux.call > $themefile
  64. jingle7 -v -theme $themefile $litmus > $LKMM_DESTDIR/$hwlitmus 2> $T/$hwlitmusfile.jingle7.out
  65. if grep -q "Generated 0 tests" $T/$hwlitmusfile.jingle7.out
  66. then
  67. echo ' !!! ' jingle7 failed, errors in $hwlitmus.err
  68. cp $T/$hwlitmusfile.jingle7.out $LKMM_DESTDIR/$hwlitmus.err
  69. exit 253
  70. fi
  71. /usr/bin/time $LKMM_TIMEOUT_CMD herd7 -unroll 0 $LKMM_DESTDIR/$hwlitmus > $LKMM_DESTDIR/$hwlitmus.out 2>&1
  72. exit $?