Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / memory-model / scripts / cmplitmushist.sh
blobca1ac8b646144ac95b0ae13d5534bbebcf411ea6
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0+
4 # Compares .out and .out.new files for each name on standard input,
5 # one full pathname per line. Outputs comparison results followed by
6 # a summary.
8 # sh cmplitmushist.sh
10 T=/tmp/cmplitmushist.sh.$$
11 trap 'rm -rf $T' 0
12 mkdir $T
14 # comparetest oldpath newpath
15 badmacnam=0
16 timedout=0
17 perfect=0
18 obsline=0
19 noobsline=0
20 obsresult=0
21 badcompare=0
22 comparetest () {
23 if grep -q ': Unknown macro ' $1 || grep -q ': Unknown macro ' $2
24 then
25 if grep -q ': Unknown macro ' $1
26 then
27 badname=`grep ': Unknown macro ' $1 |
28 sed -e 's/^.*: Unknown macro //' |
29 sed -e 's/ (User error).*$//'`
30 echo 'Current LKMM version does not know "'$badname'"' $1
32 if grep -q ': Unknown macro ' $2
33 then
34 badname=`grep ': Unknown macro ' $2 |
35 sed -e 's/^.*: Unknown macro //' |
36 sed -e 's/ (User error).*$//'`
37 echo 'Current LKMM version does not know "'$badname'"' $2
39 badmacnam=`expr "$badmacnam" + 1`
40 return 0
41 elif grep -q '^Command exited with non-zero status 124' $1 ||
42 grep -q '^Command exited with non-zero status 124' $2
43 then
44 if grep -q '^Command exited with non-zero status 124' $1 &&
45 grep -q '^Command exited with non-zero status 124' $2
46 then
47 echo Both runs timed out: $2
48 elif grep -q '^Command exited with non-zero status 124' $1
49 then
50 echo Old run timed out: $2
51 elif grep -q '^Command exited with non-zero status 124' $2
52 then
53 echo New run timed out: $2
55 timedout=`expr "$timedout" + 1`
56 return 0
58 grep -v 'maxresident)k\|minor)pagefaults\|^Time' $1 > $T/oldout
59 grep -v 'maxresident)k\|minor)pagefaults\|^Time' $2 > $T/newout
60 if cmp -s $T/oldout $T/newout && grep -q '^Observation' $1
61 then
62 echo Exact output match: $2
63 perfect=`expr "$perfect" + 1`
64 return 0
67 grep '^Observation' $1 > $T/oldout
68 grep '^Observation' $2 > $T/newout
69 if test -s $T/oldout -o -s $T/newout
70 then
71 if cmp -s $T/oldout $T/newout
72 then
73 echo Matching Observation result and counts: $2
74 obsline=`expr "$obsline" + 1`
75 return 0
77 else
78 echo Missing Observation line "(e.g., syntax error)": $2
79 noobsline=`expr "$noobsline" + 1`
80 return 0
83 grep '^Observation' $1 | awk '{ print $3 }' > $T/oldout
84 grep '^Observation' $2 | awk '{ print $3 }' > $T/newout
85 if cmp -s $T/oldout $T/newout
86 then
87 echo Matching Observation Always/Sometimes/Never result: $2
88 obsresult=`expr "$obsresult" + 1`
89 return 0
91 echo ' !!!' Result changed: $2
92 badcompare=`expr "$badcompare" + 1`
93 return 1
96 sed -e 's/^.*$/comparetest &.out &.out.new/' > $T/cmpscript
97 . $T/cmpscript > $T/cmpscript.out
98 cat $T/cmpscript.out
100 echo ' ---' Summary: 1>&2
101 grep '!!!' $T/cmpscript.out 1>&2
102 if test "$perfect" -ne 0
103 then
104 echo Exact output matches: $perfect 1>&2
106 if test "$obsline" -ne 0
107 then
108 echo Matching Observation result and counts: $obsline 1>&2
110 if test "$noobsline" -ne 0
111 then
112 echo Missing Observation line "(e.g., syntax error)": $noobsline 1>&2
114 if test "$obsresult" -ne 0
115 then
116 echo Matching Observation Always/Sometimes/Never result: $obsresult 1>&2
118 if test "$timedout" -ne 0
119 then
120 echo "!!!" Timed out: $timedout 1>&2
122 if test "$badmacnam" -ne 0
123 then
124 echo "!!!" Unknown primitive: $badmacnam 1>&2
126 if test "$badcompare" -ne 0
127 then
128 echo "!!!" Result changed: $badcompare 1>&2
129 exit 1
132 exit 0