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