Path: blob/master/tools/memory-model/scripts/cmplitmushist.sh
29266 views
#!/bin/sh1# SPDX-License-Identifier: GPL-2.0+2#3# Compares .out and .out.new files for each name on standard input,4# one full pathname per line. Outputs comparison results followed by5# a summary.6#7# sh cmplitmushist.sh89T=/tmp/cmplitmushist.sh.$$10trap 'rm -rf $T' 011mkdir $T1213# comparetest oldpath newpath14badmacnam=015timedout=016perfect=017obsline=018noobsline=019obsresult=020badcompare=021comparetest () {22if grep -q ': Unknown macro ' $1 || grep -q ': Unknown macro ' $223then24if grep -q ': Unknown macro ' $125then26badname=`grep ': Unknown macro ' $1 |27sed -e 's/^.*: Unknown macro //' |28sed -e 's/ (User error).*$//'`29echo 'Current LKMM version does not know "'$badname'"' $130fi31if grep -q ': Unknown macro ' $232then33badname=`grep ': Unknown macro ' $2 |34sed -e 's/^.*: Unknown macro //' |35sed -e 's/ (User error).*$//'`36echo 'Current LKMM version does not know "'$badname'"' $237fi38badmacnam=`expr "$badmacnam" + 1`39return 040elif grep -q '^Command exited with non-zero status 124' $1 ||41grep -q '^Command exited with non-zero status 124' $242then43if grep -q '^Command exited with non-zero status 124' $1 &&44grep -q '^Command exited with non-zero status 124' $245then46echo Both runs timed out: $247elif grep -q '^Command exited with non-zero status 124' $148then49echo Old run timed out: $250elif grep -q '^Command exited with non-zero status 124' $251then52echo New run timed out: $253fi54timedout=`expr "$timedout" + 1`55return 056fi57grep -v 'maxresident)k\|minor)pagefaults\|^Time' $1 > $T/oldout58grep -v 'maxresident)k\|minor)pagefaults\|^Time' $2 > $T/newout59if cmp -s $T/oldout $T/newout && grep -q '^Observation' $160then61echo Exact output match: $262perfect=`expr "$perfect" + 1`63return 064fi6566grep '^Observation' $1 > $T/oldout67grep '^Observation' $2 > $T/newout68if test -s $T/oldout -o -s $T/newout69then70if cmp -s $T/oldout $T/newout71then72echo Matching Observation result and counts: $273obsline=`expr "$obsline" + 1`74return 075fi76else77echo Missing Observation line "(e.g., syntax error)": $278noobsline=`expr "$noobsline" + 1`79return 080fi8182grep '^Observation' $1 | awk '{ print $3 }' > $T/oldout83grep '^Observation' $2 | awk '{ print $3 }' > $T/newout84if cmp -s $T/oldout $T/newout85then86echo Matching Observation Always/Sometimes/Never result: $287obsresult=`expr "$obsresult" + 1`88return 089fi90echo ' !!!' Result changed: $291badcompare=`expr "$badcompare" + 1`92return 193}9495sed -e 's/^.*$/comparetest &.out &.out.new/' > $T/cmpscript96. $T/cmpscript > $T/cmpscript.out97cat $T/cmpscript.out9899echo ' ---' Summary: 1>&2100grep '!!!' $T/cmpscript.out 1>&2101if test "$perfect" -ne 0102then103echo Exact output matches: $perfect 1>&2104fi105if test "$obsline" -ne 0106then107echo Matching Observation result and counts: $obsline 1>&2108fi109if test "$noobsline" -ne 0110then111echo Missing Observation line "(e.g., syntax error)": $noobsline 1>&2112fi113if test "$obsresult" -ne 0114then115echo Matching Observation Always/Sometimes/Never result: $obsresult 1>&2116fi117if test "$timedout" -ne 0118then119echo "!!!" Timed out: $timedout 1>&2120fi121if test "$badmacnam" -ne 0122then123echo "!!!" Unknown primitive: $badmacnam 1>&2124fi125if test "$badcompare" -ne 0126then127echo "!!!" Result changed: $badcompare 1>&2128exit 1129fi130131exit 0132133134