^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # Run herd7 tests on all .litmus files in the litmus-tests directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # and check each file's result against a "Result:" comment within that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # litmus test. If the verification result does not match that specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) # in the litmus test, this script prints an error message prefixed with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # "^^^". It also outputs verification results to a file whose name is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) # that of the specified litmus test, but with ".out" appended.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # Usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # checkalllitmus.sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) # Run this in the directory containing the memory model.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) # This script makes no attempt to run the litmus tests concurrently.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) # Copyright IBM Corporation, 2018
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) # Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) . scripts/parseargs.sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) litmusdir=litmus-tests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) if test -d "$litmusdir" -a -r "$litmusdir" -a -x "$litmusdir"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) echo ' --- ' error: $litmusdir is not an accessible directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) exit 255
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) # Create any new directories that have appeared in the github litmus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) # repo since the last run.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) if test "$LKMM_DESTDIR" != "."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) find $litmusdir -type d -print |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) ( cd "$LKMM_DESTDIR"; sed -e 's/^/mkdir -p /' | sh )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) # Find the checklitmus script. If it is not where we expect it, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) # assume that the caller has the PATH environment variable set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) # appropriately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) if test -x scripts/checklitmus.sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) clscript=scripts/checklitmus.sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) clscript=checklitmus.sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) # Run the script on all the litmus tests in the specified directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) ret=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) for i in $litmusdir/*.litmus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if ! $clscript $i
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ret=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) if test "$ret" -ne 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) echo " ^^^ VERIFICATION MISMATCHES" 1>&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) echo All litmus tests verified as was expected. 1>&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) exit $ret