cmplitmushist.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/sh
  2. # 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 by
  6. # a summary.
  7. #
  8. # sh cmplitmushist.sh
  9. T=/tmp/cmplitmushist.sh.$$
  10. trap 'rm -rf $T' 0
  11. mkdir $T
  12. # comparetest oldpath newpath
  13. badmacnam=0
  14. timedout=0
  15. perfect=0
  16. obsline=0
  17. noobsline=0
  18. obsresult=0
  19. badcompare=0
  20. comparetest () {
  21. if grep -q ': Unknown macro ' $1 || grep -q ': Unknown macro ' $2
  22. then
  23. if grep -q ': Unknown macro ' $1
  24. then
  25. badname=`grep ': Unknown macro ' $1 |
  26. sed -e 's/^.*: Unknown macro //' |
  27. sed -e 's/ (User error).*$//'`
  28. echo 'Current LKMM version does not know "'$badname'"' $1
  29. fi
  30. if grep -q ': Unknown macro ' $2
  31. then
  32. badname=`grep ': Unknown macro ' $2 |
  33. sed -e 's/^.*: Unknown macro //' |
  34. sed -e 's/ (User error).*$//'`
  35. echo 'Current LKMM version does not know "'$badname'"' $2
  36. fi
  37. badmacnam=`expr "$badmacnam" + 1`
  38. return 0
  39. elif grep -q '^Command exited with non-zero status 124' $1 ||
  40. grep -q '^Command exited with non-zero status 124' $2
  41. then
  42. if grep -q '^Command exited with non-zero status 124' $1 &&
  43. grep -q '^Command exited with non-zero status 124' $2
  44. then
  45. echo Both runs timed out: $2
  46. elif grep -q '^Command exited with non-zero status 124' $1
  47. then
  48. echo Old run timed out: $2
  49. elif grep -q '^Command exited with non-zero status 124' $2
  50. then
  51. echo New run timed out: $2
  52. fi
  53. timedout=`expr "$timedout" + 1`
  54. return 0
  55. fi
  56. grep -v 'maxresident)k\|minor)pagefaults\|^Time' $1 > $T/oldout
  57. grep -v 'maxresident)k\|minor)pagefaults\|^Time' $2 > $T/newout
  58. if cmp -s $T/oldout $T/newout && grep -q '^Observation' $1
  59. then
  60. echo Exact output match: $2
  61. perfect=`expr "$perfect" + 1`
  62. return 0
  63. fi
  64. grep '^Observation' $1 > $T/oldout
  65. grep '^Observation' $2 > $T/newout
  66. if test -s $T/oldout -o -s $T/newout
  67. then
  68. if cmp -s $T/oldout $T/newout
  69. then
  70. echo Matching Observation result and counts: $2
  71. obsline=`expr "$obsline" + 1`
  72. return 0
  73. fi
  74. else
  75. echo Missing Observation line "(e.g., syntax error)": $2
  76. noobsline=`expr "$noobsline" + 1`
  77. return 0
  78. fi
  79. grep '^Observation' $1 | awk '{ print $3 }' > $T/oldout
  80. grep '^Observation' $2 | awk '{ print $3 }' > $T/newout
  81. if cmp -s $T/oldout $T/newout
  82. then
  83. echo Matching Observation Always/Sometimes/Never result: $2
  84. obsresult=`expr "$obsresult" + 1`
  85. return 0
  86. fi
  87. echo ' !!!' Result changed: $2
  88. badcompare=`expr "$badcompare" + 1`
  89. return 1
  90. }
  91. sed -e 's/^.*$/comparetest &.out &.out.new/' > $T/cmpscript
  92. . $T/cmpscript > $T/cmpscript.out
  93. cat $T/cmpscript.out
  94. echo ' ---' Summary: 1>&2
  95. grep '!!!' $T/cmpscript.out 1>&2
  96. if test "$perfect" -ne 0
  97. then
  98. echo Exact output matches: $perfect 1>&2
  99. fi
  100. if test "$obsline" -ne 0
  101. then
  102. echo Matching Observation result and counts: $obsline 1>&2
  103. fi
  104. if test "$noobsline" -ne 0
  105. then
  106. echo Missing Observation line "(e.g., syntax error)": $noobsline 1>&2
  107. fi
  108. if test "$obsresult" -ne 0
  109. then
  110. echo Matching Observation Always/Sometimes/Never result: $obsresult 1>&2
  111. fi
  112. if test "$timedout" -ne 0
  113. then
  114. echo "!!!" Timed out: $timedout 1>&2
  115. fi
  116. if test "$badmacnam" -ne 0
  117. then
  118. echo "!!!" Unknown primitive: $badmacnam 1>&2
  119. fi
  120. if test "$badcompare" -ne 0
  121. then
  122. echo "!!!" Result changed: $badcompare 1>&2
  123. exit 1
  124. fi
  125. exit 0