parse-console.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0+
  3. #
  4. # Check the console output from an rcutorture run for oopses.
  5. # The "file" is a pathname on the local system, and "title" is
  6. # a text string for error-message purposes.
  7. #
  8. # Usage: parse-console.sh file title
  9. #
  10. # Copyright (C) IBM Corporation, 2011
  11. #
  12. # Authors: Paul E. McKenney <paulmck@linux.ibm.com>
  13. T="`mktemp -d ${TMPDIR-/tmp}/parse-console.sh.XXXXXX`"
  14. file="$1"
  15. title="$2"
  16. trap 'rm -f $T.seq $T.diags' 0
  17. . functions.sh
  18. # Check for presence and readability of console output file
  19. if test -f "$file" -a -r "$file"
  20. then
  21. :
  22. else
  23. echo $title unreadable console output file: $file
  24. exit 1
  25. fi
  26. if grep -Pq '\x00' < $file
  27. then
  28. print_warning Console output contains nul bytes, old qemu still running?
  29. fi
  30. cat /dev/null > $file.diags
  31. # Check for proper termination, except for rcuscale and refscale.
  32. if test "$TORTURE_SUITE" != rcuscale && test "$TORTURE_SUITE" != refscale
  33. then
  34. # check for abject failure
  35. if grep -q FAILURE $file || grep -q -e '-torture.*!!!' $file
  36. then
  37. nerrs=`grep --binary-files=text '!!!' $file |
  38. tail -1 |
  39. awk '
  40. {
  41. normalexit = 1;
  42. for (i=NF-8;i<=NF;i++) {
  43. if (i <= 0 || i !~ /^[0-9]*$/) {
  44. bangstring = $0;
  45. gsub(/^\[[^]]*] /, "", bangstring);
  46. print bangstring;
  47. normalexit = 0;
  48. exit 0;
  49. }
  50. sum+=$i;
  51. }
  52. }
  53. END {
  54. if (normalexit)
  55. print sum " instances"
  56. }'`
  57. print_bug $title FAILURE, $nerrs
  58. exit
  59. fi
  60. grep --binary-files=text 'torture:.*ver:' $file |
  61. grep -E --binary-files=text -v '\(null\)|rtc: 000000000* ' |
  62. sed -e 's/^(initramfs)[^]]*] //' -e 's/^\[[^]]*] //' |
  63. sed -e 's/^.*ver: //' |
  64. awk '
  65. BEGIN {
  66. ver = 0;
  67. badseq = 0;
  68. }
  69. {
  70. if (!badseq && ($1 + 0 != $1 || $1 <= ver)) {
  71. badseqno1 = ver;
  72. badseqno2 = $1;
  73. badseqnr = NR;
  74. badseq = 1;
  75. }
  76. ver = $1
  77. }
  78. END {
  79. if (badseq) {
  80. if (badseqno1 == badseqno2 && badseqno2 == ver)
  81. print "GP HANG at " ver " torture stat " badseqnr;
  82. else
  83. print "BAD SEQ " badseqno1 ":" badseqno2 " last:" ver " version " badseqnr;
  84. }
  85. }' > $T.seq
  86. if grep -q SUCCESS $file
  87. then
  88. if test -s $T.seq
  89. then
  90. print_warning $title `cat $T.seq`
  91. echo " " $file
  92. exit 2
  93. fi
  94. else
  95. if grep -q "_HOTPLUG:" $file
  96. then
  97. print_warning HOTPLUG FAILURES $title `cat $T.seq`
  98. echo " " $file
  99. exit 3
  100. fi
  101. echo $title no success message, `grep --binary-files=text 'ver:' $file | wc -l` successful version messages
  102. if test -s $T.seq
  103. then
  104. print_warning $title `cat $T.seq`
  105. fi
  106. exit 2
  107. fi
  108. fi | tee -a $file.diags
  109. console-badness.sh < $file > $T.diags
  110. if test -s $T.diags
  111. then
  112. print_warning "Assertion failure in $file $title"
  113. # cat $T.diags
  114. summary=""
  115. n_badness=`grep -c Badness $file`
  116. if test "$n_badness" -ne 0
  117. then
  118. summary="$summary Badness: $n_badness"
  119. fi
  120. n_warn=`grep -v 'Warning: unable to open an initial console' $file | grep -v 'Warning: Failed to add ttynull console. No stdin, stdout, and stderr for the init process' | grep -E -c 'WARNING:|Warn'`
  121. if test "$n_warn" -ne 0
  122. then
  123. summary="$summary Warnings: $n_warn"
  124. fi
  125. n_bugs=`grep -E -c '\bBUG|Oops:' $file`
  126. if test "$n_bugs" -ne 0
  127. then
  128. summary="$summary Bugs: $n_bugs"
  129. fi
  130. n_kcsan=`grep -E -c 'BUG: KCSAN: ' $file`
  131. if test "$n_kcsan" -ne 0
  132. then
  133. if test "$n_bugs" = "$n_kcsan"
  134. then
  135. summary="$summary (all bugs kcsan)"
  136. else
  137. summary="$summary KCSAN: $n_kcsan"
  138. fi
  139. fi
  140. n_calltrace=`grep -Ec 'Call Trace:|Call trace:' $file`
  141. if test "$n_calltrace" -ne 0
  142. then
  143. summary="$summary Call Traces: $n_calltrace"
  144. fi
  145. n_lockdep=`grep -c =========== $file`
  146. if test "$n_badness" -ne 0
  147. then
  148. summary="$summary lockdep: $n_badness"
  149. fi
  150. n_stalls=`grep -E -c 'detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state' $file`
  151. if test "$n_stalls" -ne 0
  152. then
  153. summary="$summary Stalls: $n_stalls"
  154. fi
  155. n_starves=`grep -c 'rcu_.*kthread starved for' $file`
  156. if test "$n_starves" -ne 0
  157. then
  158. summary="$summary Starves: $n_starves"
  159. fi
  160. print_warning Summary: $summary
  161. cat $T.diags >> $file.diags
  162. fi
  163. for i in $file.*.diags
  164. do
  165. if test -f "$i"
  166. then
  167. cat $i >> $file.diags
  168. fi
  169. done
  170. if ! test -s $file.diags
  171. then
  172. rm -f $file.diags
  173. fi
  174. # Call extract_ftrace_from_console function, if the output is empty,
  175. # don't create $file.ftrace. Otherwise output the results to $file.ftrace
  176. extract_ftrace_from_console $file > $file.ftrace
  177. if [ ! -s $file.ftrace ]; then
  178. rm -f $file.ftrace
  179. fi