Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # SPDX-License-Identifier: GPL-2.0+
0003 #
0004 # Runs the C-language litmus tests specified on standard input, using up
0005 # to the specified number of CPUs (defaulting to all of them) and placing
0006 # the results in the specified directory (defaulting to the same place
0007 # the litmus test came from).
0008 #
0009 # sh runlitmushist.sh
0010 #
0011 # Run from the Linux kernel tools/memory-model directory.
0012 # This script uses environment variables produced by parseargs.sh.
0013 #
0014 # Copyright IBM Corporation, 2018
0015 #
0016 # Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
0017 
0018 T=/tmp/runlitmushist.sh.$$
0019 trap 'rm -rf $T' 0
0020 mkdir $T
0021 
0022 if test -d litmus
0023 then
0024         :
0025 else
0026         echo Directory \"litmus\" missing, aborting run.
0027         exit 1
0028 fi
0029 
0030 # Prefixes for per-CPU scripts
0031 for ((i=0;i<$LKMM_JOBS;i++))
0032 do
0033         echo dir="$LKMM_DESTDIR" > $T/$i.sh
0034         echo T=$T >> $T/$i.sh
0035         echo herdoptions=\"$LKMM_HERD_OPTIONS\" >> $T/$i.sh
0036         cat << '___EOF___' >> $T/$i.sh
0037         runtest () {
0038                 echo ' ... ' /usr/bin/time $LKMM_TIMEOUT_CMD herd7 $herdoptions $1 '>' $dir/$1.out '2>&1'
0039                 if /usr/bin/time $LKMM_TIMEOUT_CMD herd7 $herdoptions $1 > $dir/$1.out 2>&1
0040                 then
0041                         if ! grep -q '^Observation ' $dir/$1.out
0042                         then
0043                                 echo ' !!! Herd failed, no Observation:' $1
0044                         fi
0045                 else
0046                         exitcode=$?
0047                         if test "$exitcode" -eq 124
0048                         then
0049                                 exitmsg="timed out"
0050                         else
0051                                 exitmsg="failed, exit code $exitcode"
0052                         fi
0053                         echo ' !!! Herd' ${exitmsg}: $1
0054                 fi
0055         }
0056 ___EOF___
0057 done
0058 
0059 awk -v q="'" -v b='\\' '
0060 {
0061         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
0062 }' | bash |
0063 sort -k1n |
0064 awk -v ncpu=$LKMM_JOBS -v t=$T '
0065 {
0066         print "runtest " $2 >> t "/" NR % ncpu ".sh";
0067 }
0068 
0069 END {
0070         for (i = 0; i < ncpu; i++) {
0071                 print "sh " t "/" i ".sh > " t "/" i ".sh.out 2>&1 &";
0072                 close(t "/" i ".sh");
0073         }
0074         print "wait";
0075 }' | sh
0076 cat $T/*.sh.out
0077 if grep -q '!!!' $T/*.sh.out
0078 then
0079         echo ' ---' Summary: 1>&2
0080         grep '!!!' $T/*.sh.out 1>&2
0081         nfail="`grep '!!!' $T/*.sh.out | wc -l`"
0082         echo 'Number of failed herd7 runs (e.g., timeout): ' $nfail 1>&2
0083         exit 1
0084 else
0085         echo All runs completed successfully. 1>&2
0086         exit 0
0087 fi