133 lines · bash
1#!/bin/sh2# SPDX-License-Identifier: GPL-2.0+3#4# Compares .out and .out.new files for each name on standard input,5# one full pathname per line. Outputs comparison results followed by6# a summary.7#8# sh cmplitmushist.sh9 10T=/tmp/cmplitmushist.sh.$$11trap 'rm -rf $T' 012mkdir $T13 14# comparetest oldpath newpath15badmacnam=016timedout=017perfect=018obsline=019noobsline=020obsresult=021badcompare=022comparetest () {23 if grep -q ': Unknown macro ' $1 || grep -q ': Unknown macro ' $224 then25 if grep -q ': Unknown macro ' $126 then27 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'"' $131 fi32 if grep -q ': Unknown macro ' $233 then34 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'"' $238 fi39 badmacnam=`expr "$badmacnam" + 1`40 return 041 elif grep -q '^Command exited with non-zero status 124' $1 ||42 grep -q '^Command exited with non-zero status 124' $243 then44 if grep -q '^Command exited with non-zero status 124' $1 &&45 grep -q '^Command exited with non-zero status 124' $246 then47 echo Both runs timed out: $248 elif grep -q '^Command exited with non-zero status 124' $149 then50 echo Old run timed out: $251 elif grep -q '^Command exited with non-zero status 124' $252 then53 echo New run timed out: $254 fi55 timedout=`expr "$timedout" + 1`56 return 057 fi58 grep -v 'maxresident)k\|minor)pagefaults\|^Time' $1 > $T/oldout59 grep -v 'maxresident)k\|minor)pagefaults\|^Time' $2 > $T/newout60 if cmp -s $T/oldout $T/newout && grep -q '^Observation' $161 then62 echo Exact output match: $263 perfect=`expr "$perfect" + 1`64 return 065 fi66 67 grep '^Observation' $1 > $T/oldout68 grep '^Observation' $2 > $T/newout69 if test -s $T/oldout -o -s $T/newout70 then71 if cmp -s $T/oldout $T/newout72 then73 echo Matching Observation result and counts: $274 obsline=`expr "$obsline" + 1`75 return 076 fi77 else78 echo Missing Observation line "(e.g., syntax error)": $279 noobsline=`expr "$noobsline" + 1`80 return 081 fi82 83 grep '^Observation' $1 | awk '{ print $3 }' > $T/oldout84 grep '^Observation' $2 | awk '{ print $3 }' > $T/newout85 if cmp -s $T/oldout $T/newout86 then87 echo Matching Observation Always/Sometimes/Never result: $288 obsresult=`expr "$obsresult" + 1`89 return 090 fi91 echo ' !!!' Result changed: $292 badcompare=`expr "$badcompare" + 1`93 return 194}95 96sed -e 's/^.*$/comparetest &.out &.out.new/' > $T/cmpscript97. $T/cmpscript > $T/cmpscript.out98cat $T/cmpscript.out99 100echo ' ---' Summary: 1>&2101grep '!!!' $T/cmpscript.out 1>&2102if test "$perfect" -ne 0103then104 echo Exact output matches: $perfect 1>&2105fi106if test "$obsline" -ne 0107then108 echo Matching Observation result and counts: $obsline 1>&2109fi110if test "$noobsline" -ne 0111then112 echo Missing Observation line "(e.g., syntax error)": $noobsline 1>&2113fi114if test "$obsresult" -ne 0115then116 echo Matching Observation Always/Sometimes/Never result: $obsresult 1>&2117fi118if test "$timedout" -ne 0119then120 echo "!!!" Timed out: $timedout 1>&2121fi122if test "$badmacnam" -ne 0123then124 echo "!!!" Unknown primitive: $badmacnam 1>&2125fi126if test "$badcompare" -ne 0127then128 echo "!!!" Result changed: $badcompare 1>&2129 exit 1130fi131 132exit 0133