xref: /freebsd/sys/contrib/openzfs/.github/workflows/scripts/qemu-7-prepare.sh (revision ee3960cba1068e12fb032a68c46d74841d9edab3)
1#!/usr/bin/env bash
2
3######################################################################
4# 7) prepare output of the results
5# - this script pre-creates all needed logfiles for later summary
6######################################################################
7
8set -eu
9
10# read our defined variables
11cd /var/tmp
12source env.txt
13
14mkdir -p $RESPATH
15
16# check if building the module has failed
17if [ -z ${VMs:-} ]; then
18  cd $RESPATH
19  echo ":exclamation: ZFS module didn't build successfully :exclamation:" \
20    | tee summary.txt | tee /tmp/summary.txt
21  cp /var/tmp/*.txt .
22  tar cf /tmp/qemu-$OS.tar -C $RESPATH -h . || true
23  exit 0
24fi
25
26# build was okay
27BASE="$HOME/work/zfs/zfs"
28MERGE="$BASE/.github/workflows/scripts/merge_summary.awk"
29
30# catch result files of testings (vm's should be there)
31for ((i=1; i<=VMs; i++)); do
32  rsync -arL zfs@vm$i:$RESPATH/current $RESPATH/vm$i || true
33  scp zfs@vm$i:"/var/tmp/*.txt" $RESPATH/vm$i || true
34  scp zfs@vm$i:"/var/tmp/*.rpm" $RESPATH/vm$i || true
35done
36cp -f /var/tmp/*.txt $RESPATH || true
37cd $RESPATH
38
39# prepare result files for summary
40for ((i=1; i<=VMs; i++)); do
41  file="vm$i/build-stderr.txt"
42  test -s $file && mv -f $file build-stderr.txt
43
44  file="vm$i/build-exitcode.txt"
45  test -s $file && mv -f $file build-exitcode.txt
46
47  file="vm$i/uname.txt"
48  test -s $file && mv -f $file uname.txt
49
50  file="vm$i/tests-exitcode.txt"
51  if [ ! -s $file ]; then
52    # XXX - add some tests for kernel panic's here
53    # tail -n 80 vm$i/console.txt | grep XYZ
54    echo 1 > $file
55  fi
56  rv=$(cat vm$i/tests-exitcode.txt)
57  test $rv != 0 && touch /tmp/have_failed_tests
58
59  file="vm$i/current/log"
60  if [ -s $file ]; then
61    cat $file >> log
62    awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; }; \
63      /\[SKIP\]|\[PASS\]/{ show=0; } show' \
64      $file > /tmp/vm${i}dbg.txt
65  fi
66
67  file="vm${i}log.txt"
68  fileC="/tmp/vm${i}log.txt"
69  if [ -s $file ]; then
70    cat $file >> summary
71    cat $file | $BASE/scripts/zfs-tests-color.sh > $fileC
72  fi
73done
74
75# create summary of tests
76if [ -s summary ]; then
77  $MERGE summary | grep -v '^/' > summary.txt
78  $MERGE summary | $BASE/scripts/zfs-tests-color.sh > /tmp/summary.txt
79  rm -f summary
80else
81  touch summary.txt /tmp/summary.txt
82fi
83
84# create file for debugging
85if [ -s log ]; then
86  awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; }; \
87    /\[SKIP\]|\[PASS\]/{ show=0; } show' \
88    log > summary-failure-logs.txt
89  rm -f log
90else
91  touch summary-failure-logs.txt
92fi
93
94# create debug overview for failed tests
95cat summary.txt \
96  | awk '/\(expected PASS\)/{ if ($1!="SKIP") print $2; next; } show' \
97  | while read t; do
98  cat summary-failure-logs.txt \
99    | awk '$0~/Test[: ]/{ show=0; } $0~v{ show=1; } show' v="$t" \
100    > /tmp/fail.txt
101  SIZE=$(stat --printf="%s" /tmp/fail.txt)
102  SIZE=$((SIZE/1024))
103  # Test Summary:
104  echo "##[group]$t ($SIZE KiB)" >> /tmp/failed.txt
105  cat /tmp/fail.txt | $BASE/scripts/zfs-tests-color.sh >> /tmp/failed.txt
106  echo "##[endgroup]" >> /tmp/failed.txt
107  # Job Summary:
108  echo -e "\n<details>\n<summary>$t ($SIZE KiB)</summary><pre>" >> failed.txt
109  cat /tmp/fail.txt >> failed.txt
110  echo "</pre></details>" >> failed.txt
111done
112
113if [ -e /tmp/have_failed_tests ]; then
114  echo ":warning: Some tests failed!" >> failed.txt
115else
116  echo ":thumbsup: All tests passed." >> failed.txt
117fi
118
119if [ ! -s uname.txt ]; then
120  echo ":interrobang: Panic - where is my uname.txt?" > uname.txt
121fi
122
123# artifact ready now
124tar cf /tmp/qemu-$OS.tar -C $RESPATH -h . || true
125