^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) # Given a .litmus test and the corresponding .litmus.out file, check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # the .litmus.out file against the "Result:" comment to judge whether
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # the test ran correctly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # Usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) # judgelitmus.sh file.litmus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # Run this in the directory containing the memory model, specifying the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # pathname of the litmus test to check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) # Copyright IBM Corporation, 2018
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) # Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) litmus=$1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) if test -f "$litmus" -a -r "$litmus"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) echo ' --- ' error: \"$litmus\" is not a readable file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) exit 255
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if test -f "$LKMM_DESTDIR/$litmus".out -a -r "$LKMM_DESTDIR/$litmus".out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) echo ' --- ' error: \"$LKMM_DESTDIR/$litmus\".out is not a readable file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) exit 255
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) if grep -q '^ \* Result: ' $litmus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) outcome=`grep -m 1 '^ \* Result: ' $litmus | awk '{ print $3 }'`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) outcome=specified
^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) grep '^Observation' $LKMM_DESTDIR/$litmus.out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) if grep -q '^Observation' $LKMM_DESTDIR/$litmus.out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) echo ' !!! Verification error' $litmus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) if ! grep -q '!!!' $LKMM_DESTDIR/$litmus.out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) echo ' !!! Verification error' >> $LKMM_DESTDIR/$litmus.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) exit 255
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if test "$outcome" = DEADLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if grep '^Observation' $LKMM_DESTDIR/$litmus.out | grep -q 'Never 0 0$'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ret=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) echo " !!! Unexpected non-$outcome verification" $litmus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) if ! grep -q '!!!' $LKMM_DESTDIR/$litmus.out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) echo " !!! Unexpected non-$outcome verification" >> $LKMM_DESTDIR/$litmus.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ret=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) elif grep '^Observation' $LKMM_DESTDIR/$litmus.out | grep -q $outcome || test "$outcome" = Maybe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) ret=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) echo " !!! Unexpected non-$outcome verification" $litmus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if ! grep -q '!!!' $LKMM_DESTDIR/$litmus.out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) echo " !!! Unexpected non-$outcome verification" >> $LKMM_DESTDIR/$litmus.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) ret=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) tail -2 $LKMM_DESTDIR/$litmus.out | head -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) exit $ret