Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0+
0003 #
0004 # Compares .out and .out.new files for each name on standard input,
0005 # one full pathname per line.  Outputs comparison results followed by
0006 # a summary.
0007 #
0008 # sh cmplitmushist.sh
0009 
0010 T=/tmp/cmplitmushist.sh.$$
0011 trap 'rm -rf $T' 0
0012 mkdir $T
0013 
0014 # comparetest oldpath newpath
0015 perfect=0
0016 obsline=0
0017 noobsline=0
0018 obsresult=0
0019 badcompare=0
0020 comparetest () {
0021         grep -v 'maxresident)k\|minor)pagefaults\|^Time' $1 > $T/oldout
0022         grep -v 'maxresident)k\|minor)pagefaults\|^Time' $2 > $T/newout
0023         if cmp -s $T/oldout $T/newout && grep -q '^Observation' $1
0024         then
0025                 echo Exact output match: $2
0026                 perfect=`expr "$perfect" + 1`
0027                 return 0
0028         fi
0029 
0030         grep '^Observation' $1 > $T/oldout
0031         grep '^Observation' $2 > $T/newout
0032         if test -s $T/oldout -o -s $T/newout
0033         then
0034                 if cmp -s $T/oldout $T/newout
0035                 then
0036                         echo Matching Observation result and counts: $2
0037                         obsline=`expr "$obsline" + 1`
0038                         return 0
0039                 fi
0040         else
0041                 echo Missing Observation line "(e.g., herd7 timeout)": $2
0042                 noobsline=`expr "$noobsline" + 1`
0043                 return 0
0044         fi
0045 
0046         grep '^Observation' $1 | awk '{ print $3 }' > $T/oldout
0047         grep '^Observation' $2 | awk '{ print $3 }' > $T/newout
0048         if cmp -s $T/oldout $T/newout
0049         then
0050                 echo Matching Observation Always/Sometimes/Never result: $2
0051                 obsresult=`expr "$obsresult" + 1`
0052                 return 0
0053         fi
0054         echo ' !!!' Result changed: $2
0055         badcompare=`expr "$badcompare" + 1`
0056         return 1
0057 }
0058 
0059 sed -e 's/^.*$/comparetest &.out &.out.new/' > $T/cmpscript
0060 . $T/cmpscript > $T/cmpscript.out
0061 cat $T/cmpscript.out
0062 
0063 echo ' ---' Summary: 1>&2
0064 grep '!!!' $T/cmpscript.out 1>&2
0065 if test "$perfect" -ne 0
0066 then
0067         echo Exact output matches: $perfect 1>&2
0068 fi
0069 if test "$obsline" -ne 0
0070 then
0071         echo Matching Observation result and counts: $obsline 1>&2
0072 fi
0073 if test "$noobsline" -ne 0
0074 then
0075         echo Missing Observation line "(e.g., herd7 timeout)": $noobsline 1>&2
0076 fi
0077 if test "$obsresult" -ne 0
0078 then
0079         echo Matching Observation Always/Sometimes/Never result: $obsresult 1>&2
0080 fi
0081 if test "$badcompare" -ne 0
0082 then
0083         echo "!!!" Result changed: $badcompare 1>&2
0084         exit 1
0085 fi
0086 
0087 exit 0