|
1 | 1 | #!/usr/bin/env bash
|
2 | 2 |
|
3 |
| -# for runtime reasons we split functional testings into N parts |
4 |
| -# - use a define to check for missing tarfiles |
5 |
| -FUNCTIONAL_PARTS="4" |
6 |
| - |
7 |
| -ZTS_REPORT="tests/test-runner/bin/zts-report.py" |
8 |
| -chmod +x $ZTS_REPORT |
| 3 | +###################################################################### |
| 4 | +# generate github summary page of all the testings |
| 5 | +# /tr 2024-06-17 |
| 6 | +###################################################################### |
9 | 7 |
|
10 | 8 | function output() {
|
11 |
| - echo -e $* >> Summary.md |
12 |
| -} |
13 |
| - |
14 |
| -function error() { |
15 |
| - output ":bangbang: $* :bangbang:\n" |
| 9 | + echo -e $* >> "out-$logfile.md" |
16 | 10 | }
|
17 | 11 |
|
18 |
| -# this function generates the real summary |
19 |
| -# - expects a logfile "log" in current directory |
20 |
| -function generate() { |
21 |
| - # we issued some error already |
22 |
| - test ! -s log && return |
23 |
| - |
24 |
| - # for overview and zts-report |
25 |
| - cat log | grep '^Test' > list |
26 |
| - |
27 |
| - # error details |
28 |
| - awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; } |
29 |
| - /\[SKIP\]|\[PASS\]/{ show=0; } show' log > err |
30 |
| - |
31 |
| - # summary of errors |
32 |
| - if [ -s err ]; then |
33 |
| - output "<pre>" |
34 |
| - $ZTS_REPORT --no-maybes ./list >> Summary.md |
35 |
| - output "</pre>" |
36 |
| - |
37 |
| - # generate seperate error logfile |
38 |
| - ERRLOGS=$((ERRLOGS+1)) |
39 |
| - errfile="err-$ERRLOGS.md" |
40 |
| - echo -e "\n## $headline (debugging)\n" >> $errfile |
41 |
| - echo "<details><summary>Error Listing - with dmesg and dbgmsg</summary><pre>" >> $errfile |
42 |
| - dd if=err bs=999k count=1 >> $errfile |
43 |
| - echo "</pre></details>" >> $errfile |
44 |
| - else |
45 |
| - output "All tests passed :thumbsup:" |
| 12 | +function outfile() { |
| 13 | + if [ -f $1 ]; then |
| 14 | + CUR=`stat --printf="%s" "out-$logfile.md"` |
| 15 | + ADD=`stat --printf="%s" "$1"` |
| 16 | + X=$((CUR+ADD)) |
| 17 | + if [ $X -lt $((1024*1023)) ]; then |
| 18 | + cat "$1" >> "out-$logfile.md" |
| 19 | + else |
| 20 | + logfile=$((logfile+1)) |
| 21 | + cat "$1" >> "out-$logfile.md" |
| 22 | + fi |
46 | 23 | fi
|
47 |
| - |
48 |
| - output "<details><summary>Full Listing</summary><pre>" |
49 |
| - cat list >> Summary.md |
50 |
| - output "</pre></details>" |
51 |
| - |
52 |
| - # remove tmp files |
53 |
| - rm -f err list log |
54 | 24 | }
|
55 | 25 |
|
56 |
| -# check tarfiles and untar |
57 |
| -function check_tarfile() { |
58 |
| - if [ -f "$1" ]; then |
59 |
| - tar xf "$1" || error "Tarfile $1 returns some error" |
60 |
| - else |
61 |
| - error "Tarfile $1 not found" |
62 |
| - fi |
| 26 | +function showfile() { |
| 27 | + filename="$1" |
| 28 | + headline="$2" |
| 29 | + echo "<details><summary>$headline</summary><pre>" > tmp |
| 30 | + cat $filename >> tmp |
| 31 | + echo "</pre></details>" >> tmp |
| 32 | + outfile tmp |
| 33 | + rm -f tmp |
63 | 34 | }
|
64 | 35 |
|
65 |
| -# check logfile and concatenate test results |
66 |
| -function check_logfile() { |
67 |
| - if [ -f "$1" ]; then |
68 |
| - cat "$1" >> log |
69 |
| - else |
70 |
| - error "Logfile $1 not found" |
71 |
| - fi |
| 36 | +function send2github() { |
| 37 | + test -f "$1" && dd if="$1" bs=1023k count=1 >> $GITHUB_STEP_SUMMARY |
72 | 38 | }
|
73 | 39 |
|
74 |
| -# sanity |
75 |
| -function summarize_s() { |
76 |
| - headline="$1" |
| 40 | +# generate summary of one test |
| 41 | +function generate() { |
| 42 | + VMs=3 |
| 43 | + #################################################################### |
| 44 | + # osname.txt -> used for headline |
| 45 | + # disk-before.txt -> used together with uname |
| 46 | + # disk-afterwards.txt -> used together with uname |
| 47 | + # vm{1,2,3}log.txt (colored, used when current/log isn't there) |
| 48 | + #################################################################### |
| 49 | + # vm{1,2,3}/uname.txt -> used once |
| 50 | + # vm{1,2,3}/build-stderr.txt -> used once |
| 51 | + # vm{1,2,3}/dmesg-prerun.txt -> used once |
| 52 | + # vm{1,2,3}/dmesg-module-load.txt -> used once |
| 53 | + # vm{1,2,3}/console.txt -> all 3 used |
| 54 | + #################################################################### |
| 55 | + # vm{1,2,3}/current/log -> if not there, kernel panic loading |
| 56 | + # vm{1,2,3}/current/results -> if not there, kernel panic testings |
| 57 | + # vm{1,2,3}/exitcode.txt |
| 58 | + #################################################################### |
| 59 | + |
| 60 | + # headline of this summary |
77 | 61 | output "\n## $headline\n"
|
78 |
| - rm -rf testfiles |
79 |
| - check_tarfile "$2/sanity.tar" |
80 |
| - check_logfile "testfiles/log" |
81 |
| - generate |
| 62 | + |
| 63 | + for i in `seq 1 $VMs`; do |
| 64 | + if [ -s vm$i/uname.txt ]; then |
| 65 | + output "<pre>" |
| 66 | + outfile vm$i/uname.txt |
| 67 | + output "\nVM disk usage before:" |
| 68 | + outfile disk-afterwards.txt |
| 69 | + output "\nand afterwards:" |
| 70 | + outfile disk-before.txt |
| 71 | + output "</pre>" |
| 72 | + break |
| 73 | + fi |
| 74 | + done |
| 75 | + |
| 76 | + for i in `seq 1 $VMs`; do |
| 77 | + if [ -s vm$i/build-stderr.txt ]; then |
| 78 | + showfile "vm$i/build-stderr.txt" "Module build (stderr output)" |
| 79 | + break |
| 80 | + fi |
| 81 | + done |
| 82 | + |
| 83 | + for i in `seq 1 $VMs`; do |
| 84 | + if [ -s vm$i/dmesg-prerun.txt ]; then |
| 85 | + showfile "vm$i/dmesg-prerun.txt" "Dmesg output - before tests" |
| 86 | + break |
| 87 | + fi |
| 88 | + done |
| 89 | + |
| 90 | + for i in `seq 1 $VMs`; do |
| 91 | + if [ -s vm$i/dmesg-module-load.txt ]; then |
| 92 | + showfile "vm$i/dmesg-module-load.txt" "Dmesg output - module loading" |
| 93 | + break |
| 94 | + fi |
| 95 | + done |
| 96 | + |
| 97 | + for i in `seq 1 $VMs`; do |
| 98 | + log="vm$i/current/log" |
| 99 | + if [ ! -f $log ]; then |
| 100 | + output ":exclamation: Logfile of vm$i tests is missing :exclamation:" |
| 101 | + |
| 102 | + # some out may be generated |
| 103 | + if [ -s vm${i}log.txt ]; then |
| 104 | + cat vm${i}log.txt | \ |
| 105 | + sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" > "vm${i}log" |
| 106 | + showfile "vm${i}log" "Generated tests output of vm$i" |
| 107 | + fi |
| 108 | + |
| 109 | + # output the console contents and continue with next vm |
| 110 | + if [ -s "vm$i/console.txt" ]; then |
| 111 | + cat "vm$i/console.txt" | \ |
| 112 | + sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" > "vm${i}log" |
| 113 | + showfile "vm${i}log" "Serial console output of vm$i" |
| 114 | + fi |
| 115 | + |
| 116 | + rm -f "vm${i}log" |
| 117 | + continue |
| 118 | + fi |
| 119 | + |
| 120 | + cat $log | grep '^Test[: ]' > tests.txt |
| 121 | + results="vm$i/current/results" |
| 122 | + if [ ! -s "$results" ]; then |
| 123 | + output ":exclamation: Results file of vm$i tests is missing :exclamation:" |
| 124 | + # generate results file from log |
| 125 | + ./zts-report.py --no-maybes ./tests.txt > $results |
| 126 | + # Running Time: 01:30:09 |
| 127 | + # Running Time: not finished!! |
| 128 | + echo -e "\nRunning Time:\tKernel panic!" >> $results |
| 129 | + fi |
| 130 | + cat $results | awk '/Results Summary/ { show=1; print; next; } show' > summary.txt |
| 131 | + runtime=`cat $results | grep '^Running Time:' | cut -f2` |
| 132 | + |
| 133 | + awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; } \ |
| 134 | + /\[SKIP\]|\[PASS\]/{ show=0; } show' $log > debug.txt |
| 135 | + |
| 136 | + output "\n### Tests on vm$i ($runtime)\n\n" |
| 137 | + |
| 138 | + if [ -s summary.txt ]; then |
| 139 | + showfile "summary.txt" "Summary of all tests" |
| 140 | + fi |
| 141 | + |
| 142 | + if [ -s "vm$i/console.txt" ]; then |
| 143 | + showfile "vm$i/console.txt" "Serial console output" |
| 144 | + fi |
| 145 | + |
| 146 | + if [ -s tests.txt ]; then |
| 147 | + showfile "tests.txt" "List of all tests" |
| 148 | + fi |
| 149 | + |
| 150 | + MAX="300" |
| 151 | + if [ -s debug.txt ]; then |
| 152 | + S=`stat --printf="%s" "debug.txt"` |
| 153 | + if [ $S -gt $((1024*$MAX)) ]; then |
| 154 | + dd if=debug.txt of=debug.txt2 count=$MAX bs=1024 2>/dev/null |
| 155 | + mv -f debug.txt2 debug.txt |
| 156 | + echo "..." >> debug.txt |
| 157 | + echo "!!! THIS FILE IS BIGGER !!!" >> debug.txt |
| 158 | + echo "Please download the zip archiv for full content!" >> debug.txt |
| 159 | + fi |
| 160 | + showfile "debug.txt" "Debug list for failed tests (vm$i, $runtime)" |
| 161 | + fi |
| 162 | + done |
82 | 163 | }
|
83 | 164 |
|
84 |
| -# functional |
85 |
| -function summarize_f() { |
86 |
| - headline="$1" |
87 |
| - output "\n## $headline\n" |
88 |
| - rm -rf testfiles |
89 |
| - for i in $(seq 1 $FUNCTIONAL_PARTS); do |
90 |
| - tarfile="$2-part$i/part$i.tar" |
91 |
| - check_tarfile "$tarfile" |
92 |
| - check_logfile "testfiles/log" |
| 165 | +# functional tests via qemu |
| 166 | +function summarize() { |
| 167 | + for tarfile in Logs-functional-*/qemu-*.tar; do |
| 168 | + rm -rf vm* *.txt |
| 169 | + tar xf "$tarfile" |
| 170 | + osname=`cat osname.txt` |
| 171 | + headline="Functional Tests: $osname" |
| 172 | + generate |
93 | 173 | done
|
94 |
| - generate |
95 | 174 | }
|
96 | 175 |
|
97 | 176 | # https://docs.github.com/en/[email protected]/actions/using-workflows/workflow-commands-for-github-actions#step-isolation-and-limits
|
98 | 177 | # Job summaries are isolated between steps and each step is restricted to a maximum size of 1MiB.
|
99 | 178 | # [ ] can not show all error findings here
|
100 | 179 | # [x] split files into smaller ones and create additional steps
|
101 | 180 |
|
102 |
| -ERRLOGS=0 |
103 |
| -if [ ! -f Summary/Summary.md ]; then |
104 |
| - # first call, we do the default summary (~500k) |
105 |
| - echo -n > Summary.md |
106 |
| - summarize_s "Sanity Tests Ubuntu 20.04" Logs-20.04-sanity |
107 |
| - summarize_s "Sanity Tests Ubuntu 22.04" Logs-22.04-sanity |
108 |
| - summarize_f "Functional Tests Ubuntu 20.04" Logs-20.04-functional |
109 |
| - summarize_f "Functional Tests Ubuntu 22.04" Logs-22.04-functional |
110 |
| - |
111 |
| - cat Summary.md >> $GITHUB_STEP_SUMMARY |
112 |
| - mkdir -p Summary |
113 |
| - mv *.md Summary |
| 181 | +# first call, generate all summaries |
| 182 | +if [ ! -f out-0.md ]; then |
| 183 | + # create ./zts-report.py for generate() |
| 184 | + TEMPLATE="tests/test-runner/bin/zts-report.py.in" |
| 185 | + cat $TEMPLATE| sed -e 's|@PYTHON_SHEBANG@|python3|' > ./zts-report.py |
| 186 | + chmod +x ./zts-report.py |
| 187 | + |
| 188 | + logfile="0" |
| 189 | + summarize |
| 190 | + send2github out-0.md |
114 | 191 | else
|
115 |
| - # here we get, when errors where returned in first call |
116 |
| - test -f Summary/err-$1.md && cat Summary/err-$1.md >> $GITHUB_STEP_SUMMARY |
| 192 | + send2github out-$1.md |
117 | 193 | fi
|
118 | 194 |
|
119 | 195 | exit 0
|
0 commit comments