brintos

brintos / linux-shallow public Read only

0
0
Text · 2.1 KiB · c6c2bdc Raw
95 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.0+3#4# Runs the C-language litmus tests specified on standard input, using up5# to the specified number of CPUs (defaulting to all of them) and placing6# the results in the specified directory (defaulting to the same place7# the litmus test came from).8#9# sh runlitmushist.sh10#11# Run from the Linux kernel tools/memory-model directory.12# This script uses environment variables produced by parseargs.sh.13#14# Copyright IBM Corporation, 201815#16# Author: Paul E. McKenney <paulmck@linux.ibm.com>17 18. scripts/hwfnseg.sh19 20T=/tmp/runlitmushist.sh.$$21trap 'rm -rf $T' 022mkdir $T23 24if test -d litmus25then26	:27else28	echo Directory \"litmus\" missing, aborting run.29	exit 130fi31 32# Prefixes for per-CPU scripts33for ((i=0;i<$LKMM_JOBS;i++))34do35	echo T=$T >> $T/$i.sh36	cat << '___EOF___' >> $T/$i.sh37	runtest () {38		if scripts/runlitmus.sh $139		then40			if ! grep -q '^Observation ' $LKMM_DESTDIR/$1$2.out41			then42				echo ' !!! Herd failed, no Observation:' $143			fi44		else45			exitcode=$?46			if test "$exitcode" -eq 12447			then48				exitmsg="timed out"49			elif test "$exitcode" -eq 25350			then51				exitmsg=52			else53				exitmsg="failed, exit code $exitcode"54			fi55			if test -n "$exitmsg"56			then57				echo ' !!! Herd' ${exitmsg}: $158			fi59		fi60	}61___EOF___62done63 64awk -v q="'" -v b='\\' '65{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 "` " $067}' | sh | sort -k1n |68awk -v dq='"' -v hwfnseg="$hwfnseg" -v ncpu="$LKMM_JOBS" -v t="$T" '69{70	print "if test -z " dq hwfnseg dq " || scripts/simpletest.sh " dq $2 dq71	print "then"72	print "\techo runtest " dq $2 dq " " hwfnseg " >> " t "/" NR % ncpu ".sh";73	print "fi"74}75 76END {77	for (i = 0; i < ncpu; i++) {78		print "sh " t "/" i ".sh > " t "/" i ".sh.out 2>&1 &";79		close(t "/" i ".sh");80	}81	print "wait";82}' | sh83cat $T/*.sh.out84if grep -q '!!!' $T/*.sh.out85then86	echo ' ---' Summary: 1>&287	grep '!!!' $T/*.sh.out 1>&288	nfail="`grep '!!!' $T/*.sh.out | wc -l`"89	echo 'Number of failed herd7 runs (e.g., timeout): ' $nfail 1>&290	exit 191else92	echo All runs completed successfully. 1>&293	exit 094fi95