xref: /freebsd/sys/contrib/openzfs/.github/workflows/scripts/qemu-8-summary.sh (revision f9590540c524607d22fa7e718c758725c4365375)
1#!/usr/bin/env bash
2
3######################################################################
4# 8) show colored output of results
5######################################################################
6
7set -eu
8
9# read our defined variables
10source /var/tmp/env.txt
11cd $RESPATH
12
13# helper function for showing some content with headline
14function showfile() {
15  content=$(dd if=$1 bs=1024 count=400k 2>/dev/null)
16  if [ -z "$2" ]; then
17    group1=""
18    group2=""
19  else
20    SIZE=$(stat --printf="%s" "$file")
21    SIZE=$((SIZE/1024))
22    group1="##[group]$2 ($SIZE KiB)"
23    group2="##[endgroup]"
24  fi
25cat <<EOF > tmp$$
26$group1
27$content
28$group2
29EOF
30  cat tmp$$
31  rm -f tmp$$
32}
33
34function showfile_tail() {
35  echo "##[group]$2 (final lines)"
36  tail -n 80 $1
37  echo "##[endgroup]"
38}
39
40# overview if available
41if [ -f /tmp/summary.txt -a -s /tmp/summary.txt ]; then
42  cat /tmp/summary.txt
43  echo ""
44fi
45
46if [ -f /tmp/have_failed_tests -a -s /tmp/failed.txt ]; then
47  echo "Debuginfo of failed tests:"
48  cat /tmp/failed.txt
49  echo ""
50  cat /tmp/summary.txt | grep -v '^/'
51  echo ""
52fi
53
54echo -e "\nFull logs for download:\n    $1\n"
55
56for ((i=1; i<=VMs; i++)); do
57
58  # Print Lustre build test results (the build is only done on vm2)
59  if [ -f vm$i/lustre-exitcode.txt ] ; then
60    rv=$(< vm$i/lustre-exitcode.txt)
61    if [ $rv = 0 ]; then
62      vm="vm$i"
63    else
64      vm="vm$i"
65      touch /tmp/have_failed_tests
66    fi
67    file="vm$i/lustre.txt"
68    test -s "$file" && showfile_tail "$file" "$vm: Lustre build"
69  fi
70
71  if [ -f vm$i/builtin-exitcode.txt ] ; then
72    rv=$(< vm$i/builtin-exitcode.txt)
73    if [ $rv = 0 ]; then
74      vm="vm$i"
75    else
76      vm="vm$i"
77      touch /tmp/have_failed_tests
78    fi
79    file="vm$i/builtin.txt"
80    test -s "$file" && showfile_tail "$file" "$vm: Linux built-in build"
81  fi
82
83  rv=$(cat vm$i/tests-exitcode.txt)
84
85  if [ $rv = 0 ]; then
86    vm="vm$i"
87  else
88    vm="vm$i"
89  fi
90
91  file="vm$i/dmesg-prerun.txt"
92  test -s "$file" && showfile "$file" "$vm: dmesg kernel"
93
94  file="/tmp/vm${i}log.txt"
95  test -s "$file" && showfile "$file" "$vm: test results"
96
97  file="vm$i/console.txt"
98  test -s "$file" && showfile "$file" "$vm: serial console"
99
100  file="/tmp/vm${i}dbg.txt"
101  test -s "$file" && showfile "$file" "$vm: failure logfile"
102done
103
104test -f /tmp/have_failed_tests && exit 1
105exit 0
106