GNU Linux-libre 6.1.90-gnu
[releases.git] / tools / memory-model / scripts / checkghlitmus.sh
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0+
3 #
4 # Runs the C-language litmus tests having a maximum number of processes
5 # to run, defaults to 6.
6 #
7 # sh checkghlitmus.sh
8 #
9 # Run from the Linux kernel tools/memory-model directory.  See the
10 # parseargs.sh scripts for arguments.
11
12 . scripts/parseargs.sh
13
14 T=/tmp/checkghlitmus.sh.$$
15 trap 'rm -rf $T' 0
16 mkdir $T
17
18 # Clone the repository if it is not already present.
19 if test -d litmus
20 then
21         :
22 else
23         git clone https://github.com/paulmckrcu/litmus
24         ( cd litmus; git checkout origin/master )
25 fi
26
27 # Create any new directories that have appeared in the github litmus
28 # repo since the last run.
29 if test "$LKMM_DESTDIR" != "."
30 then
31         find litmus -type d -print |
32         ( cd "$LKMM_DESTDIR"; sed -e 's/^/mkdir -p /' | sh )
33 fi
34
35 # Create a list of the C-language litmus tests previously run.
36 ( cd $LKMM_DESTDIR; find litmus -name '*.litmus.out' -print ) |
37         sed -e 's/\.out$//' |
38         xargs -r egrep -l '^ \* Result: (Never|Sometimes|Always|DEADLOCK)' |
39         xargs -r grep -L "^P${LKMM_PROCS}"> $T/list-C-already
40
41 # Create a list of C-language litmus tests with "Result:" commands and
42 # no more than the specified number of processes.
43 find litmus -name '*.litmus' -exec grep -l -m 1 "^C " {} \; > $T/list-C
44 xargs < $T/list-C -r egrep -l '^ \* Result: (Never|Sometimes|Always|DEADLOCK)' > $T/list-C-result
45 xargs < $T/list-C-result -r grep -L "^P${LKMM_PROCS}" > $T/list-C-result-short
46
47 # Form list of tests without corresponding .litmus.out files
48 sort $T/list-C-already $T/list-C-result-short | uniq -u > $T/list-C-needed
49
50 # Run any needed tests.
51 if scripts/runlitmushist.sh < $T/list-C-needed > $T/run.stdout 2> $T/run.stderr
52 then
53         errs=
54 else
55         errs=1
56 fi
57
58 sed < $T/list-C-result-short -e 's,^,scripts/judgelitmus.sh ,' |
59         sh > $T/judge.stdout 2> $T/judge.stderr
60
61 if test -n "$errs"
62 then
63         cat $T/run.stderr 1>&2
64 fi
65 grep '!!!' $T/judge.stdout