Linux 5.7.7
[linux/fpc-iii.git] / tools / memory-model / scripts / cmplitmushist.sh
blob0f498aeeccf5ec6cc76fd2634aa1204db73bdce5
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 perfect=0
16 obsline=0
17 noobsline=0
18 obsresult=0
19 badcompare=0
20 comparetest () {
21 grep -v 'maxresident)k\|minor)pagefaults\|^Time' $1 > $T/oldout
22 grep -v 'maxresident)k\|minor)pagefaults\|^Time' $2 > $T/newout
23 if cmp -s $T/oldout $T/newout && grep -q '^Observation' $1
24 then
25 echo Exact output match: $2
26 perfect=`expr "$perfect" + 1`
27 return 0
30 grep '^Observation' $1 > $T/oldout
31 grep '^Observation' $2 > $T/newout
32 if test -s $T/oldout -o -s $T/newout
33 then
34 if cmp -s $T/oldout $T/newout
35 then
36 echo Matching Observation result and counts: $2
37 obsline=`expr "$obsline" + 1`
38 return 0
40 else
41 echo Missing Observation line "(e.g., herd7 timeout)": $2
42 noobsline=`expr "$noobsline" + 1`
43 return 0
46 grep '^Observation' $1 | awk '{ print $3 }' > $T/oldout
47 grep '^Observation' $2 | awk '{ print $3 }' > $T/newout
48 if cmp -s $T/oldout $T/newout
49 then
50 echo Matching Observation Always/Sometimes/Never result: $2
51 obsresult=`expr "$obsresult" + 1`
52 return 0
54 echo ' !!!' Result changed: $2
55 badcompare=`expr "$badcompare" + 1`
56 return 1
59 sed -e 's/^.*$/comparetest &.out &.out.new/' > $T/cmpscript
60 . $T/cmpscript > $T/cmpscript.out
61 cat $T/cmpscript.out
63 echo ' ---' Summary: 1>&2
64 grep '!!!' $T/cmpscript.out 1>&2
65 if test "$perfect" -ne 0
66 then
67 echo Exact output matches: $perfect 1>&2
69 if test "$obsline" -ne 0
70 then
71 echo Matching Observation result and counts: $obsline 1>&2
73 if test "$noobsline" -ne 0
74 then
75 echo Missing Observation line "(e.g., herd7 timeout)": $noobsline 1>&2
77 if test "$obsresult" -ne 0
78 then
79 echo Matching Observation Always/Sometimes/Never result: $obsresult 1>&2
81 if test "$badcompare" -ne 0
82 then
83 echo "!!!" Result changed: $badcompare 1>&2
84 exit 1
87 exit 0