Path: blob/master/tools/memory-model/scripts/runlitmushist.sh
29266 views
#!/bin/bash1# SPDX-License-Identifier: GPL-2.0+2#3# Runs the C-language litmus tests specified on standard input, using up4# to the specified number of CPUs (defaulting to all of them) and placing5# the results in the specified directory (defaulting to the same place6# the litmus test came from).7#8# sh runlitmushist.sh9#10# Run from the Linux kernel tools/memory-model directory.11# This script uses environment variables produced by parseargs.sh.12#13# Copyright IBM Corporation, 201814#15# Author: Paul E. McKenney <[email protected]>1617. scripts/hwfnseg.sh1819T=/tmp/runlitmushist.sh.$$20trap 'rm -rf $T' 021mkdir $T2223if test -d litmus24then25:26else27echo Directory \"litmus\" missing, aborting run.28exit 129fi3031# Prefixes for per-CPU scripts32for ((i=0;i<$LKMM_JOBS;i++))33do34echo T=$T >> $T/$i.sh35cat << '___EOF___' >> $T/$i.sh36runtest () {37if scripts/runlitmus.sh $138then39if ! grep -q '^Observation ' $LKMM_DESTDIR/$1$2.out40then41echo ' !!! Herd failed, no Observation:' $142fi43else44exitcode=$?45if test "$exitcode" -eq 12446then47exitmsg="timed out"48elif test "$exitcode" -eq 25349then50exitmsg=51else52exitmsg="failed, exit code $exitcode"53fi54if test -n "$exitmsg"55then56echo ' !!! Herd' ${exitmsg}: $157fi58fi59}60___EOF___61done6263awk -v q="'" -v b='\\' '64{65print "echo `grep " q "^P[0-9]" b "+(" q " " $0 " | tail -1 | sed -e " q "s/^P" b "([0-9]" b "+" b ")(.*$/" b "1/" q "` " $066}' | sh | sort -k1n |67awk -v dq='"' -v hwfnseg="$hwfnseg" -v ncpu="$LKMM_JOBS" -v t="$T" '68{69print "if test -z " dq hwfnseg dq " || scripts/simpletest.sh " dq $2 dq70print "then"71print "\techo runtest " dq $2 dq " " hwfnseg " >> " t "/" NR % ncpu ".sh";72print "fi"73}7475END {76for (i = 0; i < ncpu; i++) {77print "sh " t "/" i ".sh > " t "/" i ".sh.out 2>&1 &";78close(t "/" i ".sh");79}80print "wait";81}' | sh82cat $T/*.sh.out83if grep -q '!!!' $T/*.sh.out84then85echo ' ---' Summary: 1>&286grep '!!!' $T/*.sh.out 1>&287nfail="`grep '!!!' $T/*.sh.out | wc -l`"88echo 'Number of failed herd7 runs (e.g., timeout): ' $nfail 1>&289exit 190else91echo All runs completed successfully. 1>&292exit 093fi949596