]>
Commit | Line | Data |
---|---|---|
b02eb5b0 PM |
1 | #!/bin/bash |
2 | # SPDX-License-Identifier: GPL-2.0+ | |
3 | # | |
4 | # Runs the C-language litmus tests specified on standard input, using up | |
5 | # to the specified number of CPUs (defaulting to all of them) and placing | |
6 | # the results in the specified directory (defaulting to the same place | |
7 | # the litmus test came from). | |
8 | # | |
9 | # sh runlitmushist.sh | |
10 | # | |
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, 2018 | |
15 | # | |
16 | # Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com> | |
17 | ||
18 | T=/tmp/runlitmushist.sh.$$ | |
19 | trap 'rm -rf $T' 0 | |
20 | mkdir $T | |
21 | ||
22 | if test -d litmus | |
23 | then | |
24 | : | |
25 | else | |
26 | echo Directory \"litmus\" missing, aborting run. | |
27 | exit 1 | |
28 | fi | |
29 | ||
30 | # Prefixes for per-CPU scripts | |
31 | for ((i=0;i<$LKMM_JOBS;i++)) | |
32 | do | |
33 | echo dir="$LKMM_DESTDIR" > $T/$i.sh | |
34 | echo T=$T >> $T/$i.sh | |
35 | echo herdoptions=\"$LKMM_HERD_OPTIONS\" >> $T/$i.sh | |
36 | cat << '___EOF___' >> $T/$i.sh | |
37 | runtest () { | |
38 | echo ' ... ' /usr/bin/time $LKMM_TIMEOUT_CMD herd7 $herdoptions $1 '>' $dir/$1.out '2>&1' | |
39 | if /usr/bin/time $LKMM_TIMEOUT_CMD herd7 $herdoptions $1 > $dir/$1.out 2>&1 | |
40 | then | |
41 | if ! grep -q '^Observation ' $dir/$1.out | |
42 | then | |
43 | echo ' !!! Herd failed, no Observation:' $1 | |
44 | fi | |
45 | else | |
46 | exitcode=$? | |
47 | if test "$exitcode" -eq 124 | |
48 | then | |
49 | exitmsg="timed out" | |
50 | else | |
51 | exitmsg="failed, exit code $exitcode" | |
52 | fi | |
53 | echo ' !!! Herd' ${exitmsg}: $1 | |
54 | fi | |
55 | } | |
56 | ___EOF___ | |
57 | done | |
58 | ||
59 | awk -v q="'" -v b='\\' ' | |
60 | { | |
61 | 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 | |
62 | }' | bash | | |
63 | sort -k1n | | |
64 | awk -v ncpu=$LKMM_JOBS -v t=$T ' | |
65 | { | |
66 | print "runtest " $2 >> t "/" NR % ncpu ".sh"; | |
67 | } | |
68 | ||
69 | END { | |
70 | for (i = 0; i < ncpu; i++) { | |
71 | print "sh " t "/" i ".sh > " t "/" i ".sh.out 2>&1 &"; | |
72 | close(t "/" i ".sh"); | |
73 | } | |
74 | print "wait"; | |
75 | }' | sh | |
76 | cat $T/*.sh.out | |
77 | if grep -q '!!!' $T/*.sh.out | |
78 | then | |
79 | echo ' ---' Summary: 1>&2 | |
80 | grep '!!!' $T/*.sh.out 1>&2 | |
81 | nfail="`grep '!!!' $T/*.sh.out | wc -l`" | |
37c600a3 | 82 | echo 'Number of failed herd7 runs (e.g., timeout): ' $nfail 1>&2 |
b02eb5b0 PM |
83 | exit 1 |
84 | else | |
85 | echo All runs completed successfully. 1>&2 | |
86 | exit 0 | |
87 | fi |