1 #!/bin/sh 1 #!/bin/sh 2 # SPDX-License-Identifier: GPL-2.0+ 2 # SPDX-License-Identifier: GPL-2.0+ 3 # 3 # 4 # Compares .out and .out.new files for each na 4 # Compares .out and .out.new files for each name on standard input, 5 # one full pathname per line. Outputs compari 5 # one full pathname per line. Outputs comparison results followed by 6 # a summary. 6 # a summary. 7 # 7 # 8 # sh cmplitmushist.sh 8 # sh cmplitmushist.sh 9 9 10 T=/tmp/cmplitmushist.sh.$$ 10 T=/tmp/cmplitmushist.sh.$$ 11 trap 'rm -rf $T' 0 11 trap 'rm -rf $T' 0 12 mkdir $T 12 mkdir $T 13 13 14 # comparetest oldpath newpath 14 # comparetest oldpath newpath 15 badmacnam=0 15 badmacnam=0 16 timedout=0 16 timedout=0 17 perfect=0 17 perfect=0 18 obsline=0 18 obsline=0 19 noobsline=0 19 noobsline=0 20 obsresult=0 20 obsresult=0 21 badcompare=0 21 badcompare=0 22 comparetest () { 22 comparetest () { 23 if grep -q ': Unknown macro ' $1 || gr 23 if grep -q ': Unknown macro ' $1 || grep -q ': Unknown macro ' $2 24 then 24 then 25 if grep -q ': Unknown macro ' 25 if grep -q ': Unknown macro ' $1 26 then 26 then 27 badname=`grep ': Unkno 27 badname=`grep ': Unknown macro ' $1 | 28 sed -e 's/^.*: 28 sed -e 's/^.*: Unknown macro //' | 29 sed -e 's/ (Us 29 sed -e 's/ (User error).*$//'` 30 echo 'Current LKMM ver 30 echo 'Current LKMM version does not know "'$badname'"' $1 31 fi 31 fi 32 if grep -q ': Unknown macro ' 32 if grep -q ': Unknown macro ' $2 33 then 33 then 34 badname=`grep ': Unkno 34 badname=`grep ': Unknown macro ' $2 | 35 sed -e 's/^.*: 35 sed -e 's/^.*: Unknown macro //' | 36 sed -e 's/ (Us 36 sed -e 's/ (User error).*$//'` 37 echo 'Current LKMM ver 37 echo 'Current LKMM version does not know "'$badname'"' $2 38 fi 38 fi 39 badmacnam=`expr "$badmacnam" + 39 badmacnam=`expr "$badmacnam" + 1` 40 return 0 40 return 0 41 elif grep -q '^Command exited with non 41 elif grep -q '^Command exited with non-zero status 124' $1 || 42 grep -q '^Command exited with non 42 grep -q '^Command exited with non-zero status 124' $2 43 then 43 then 44 if grep -q '^Command exited wi 44 if grep -q '^Command exited with non-zero status 124' $1 && 45 grep -q '^Command exited wi 45 grep -q '^Command exited with non-zero status 124' $2 46 then 46 then 47 echo Both runs timed o 47 echo Both runs timed out: $2 48 elif grep -q '^Command exited 48 elif grep -q '^Command exited with non-zero status 124' $1 49 then 49 then 50 echo Old run timed out 50 echo Old run timed out: $2 51 elif grep -q '^Command exited 51 elif grep -q '^Command exited with non-zero status 124' $2 52 then 52 then 53 echo New run timed out 53 echo New run timed out: $2 54 fi 54 fi 55 timedout=`expr "$timedout" + 1 55 timedout=`expr "$timedout" + 1` 56 return 0 56 return 0 57 fi 57 fi 58 grep -v 'maxresident)k\|minor)pagefaul 58 grep -v 'maxresident)k\|minor)pagefaults\|^Time' $1 > $T/oldout 59 grep -v 'maxresident)k\|minor)pagefaul 59 grep -v 'maxresident)k\|minor)pagefaults\|^Time' $2 > $T/newout 60 if cmp -s $T/oldout $T/newout && grep 60 if cmp -s $T/oldout $T/newout && grep -q '^Observation' $1 61 then 61 then 62 echo Exact output match: $2 62 echo Exact output match: $2 63 perfect=`expr "$perfect" + 1` 63 perfect=`expr "$perfect" + 1` 64 return 0 64 return 0 65 fi 65 fi 66 66 67 grep '^Observation' $1 > $T/oldout 67 grep '^Observation' $1 > $T/oldout 68 grep '^Observation' $2 > $T/newout 68 grep '^Observation' $2 > $T/newout 69 if test -s $T/oldout -o -s $T/newout 69 if test -s $T/oldout -o -s $T/newout 70 then 70 then 71 if cmp -s $T/oldout $T/newout 71 if cmp -s $T/oldout $T/newout 72 then 72 then 73 echo Matching Observat 73 echo Matching Observation result and counts: $2 74 obsline=`expr "$obslin 74 obsline=`expr "$obsline" + 1` 75 return 0 75 return 0 76 fi 76 fi 77 else 77 else 78 echo Missing Observation line 78 echo Missing Observation line "(e.g., syntax error)": $2 79 noobsline=`expr "$noobsline" + 79 noobsline=`expr "$noobsline" + 1` 80 return 0 80 return 0 81 fi 81 fi 82 82 83 grep '^Observation' $1 | awk '{ print 83 grep '^Observation' $1 | awk '{ print $3 }' > $T/oldout 84 grep '^Observation' $2 | awk '{ print 84 grep '^Observation' $2 | awk '{ print $3 }' > $T/newout 85 if cmp -s $T/oldout $T/newout 85 if cmp -s $T/oldout $T/newout 86 then 86 then 87 echo Matching Observation Alwa 87 echo Matching Observation Always/Sometimes/Never result: $2 88 obsresult=`expr "$obsresult" + 88 obsresult=`expr "$obsresult" + 1` 89 return 0 89 return 0 90 fi 90 fi 91 echo ' !!!' Result changed: $2 91 echo ' !!!' Result changed: $2 92 badcompare=`expr "$badcompare" + 1` 92 badcompare=`expr "$badcompare" + 1` 93 return 1 93 return 1 94 } 94 } 95 95 96 sed -e 's/^.*$/comparetest &.out &.out.new/' > 96 sed -e 's/^.*$/comparetest &.out &.out.new/' > $T/cmpscript 97 . $T/cmpscript > $T/cmpscript.out 97 . $T/cmpscript > $T/cmpscript.out 98 cat $T/cmpscript.out 98 cat $T/cmpscript.out 99 99 100 echo ' ---' Summary: 1>&2 100 echo ' ---' Summary: 1>&2 101 grep '!!!' $T/cmpscript.out 1>&2 101 grep '!!!' $T/cmpscript.out 1>&2 102 if test "$perfect" -ne 0 102 if test "$perfect" -ne 0 103 then 103 then 104 echo Exact output matches: $perfect 1> 104 echo Exact output matches: $perfect 1>&2 105 fi 105 fi 106 if test "$obsline" -ne 0 106 if test "$obsline" -ne 0 107 then 107 then 108 echo Matching Observation result and c 108 echo Matching Observation result and counts: $obsline 1>&2 109 fi 109 fi 110 if test "$noobsline" -ne 0 110 if test "$noobsline" -ne 0 111 then 111 then 112 echo Missing Observation line "(e.g., 112 echo Missing Observation line "(e.g., syntax error)": $noobsline 1>&2 113 fi 113 fi 114 if test "$obsresult" -ne 0 114 if test "$obsresult" -ne 0 115 then 115 then 116 echo Matching Observation Always/Somet 116 echo Matching Observation Always/Sometimes/Never result: $obsresult 1>&2 117 fi 117 fi 118 if test "$timedout" -ne 0 118 if test "$timedout" -ne 0 119 then 119 then 120 echo "!!!" Timed out: $timedout 1>&2 120 echo "!!!" Timed out: $timedout 1>&2 121 fi 121 fi 122 if test "$badmacnam" -ne 0 122 if test "$badmacnam" -ne 0 123 then 123 then 124 echo "!!!" Unknown primitive: $badmacn 124 echo "!!!" Unknown primitive: $badmacnam 1>&2 125 fi 125 fi 126 if test "$badcompare" -ne 0 126 if test "$badcompare" -ne 0 127 then 127 then 128 echo "!!!" Result changed: $badcompare 128 echo "!!!" Result changed: $badcompare 1>&2 129 exit 1 129 exit 1 130 fi 130 fi 131 131 132 exit 0 132 exit 0
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.