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 in $(seq 1 $VMs); do 32 rsync -arL zfs@192.168.122.1$i:$RESPATH/current $RESPATH/vm$i || true 33 scp zfs@192.168.122.1$i:"/var/tmp/*.txt" $RESPATH/vm$i || true 34done 35cp -f /var/tmp/*.txt $RESPATH || true 36cd $RESPATH 37 38# prepare result files for summary 39for i in $(seq 1 $VMs); do 40 file="vm$i/build-stderr.txt" 41 test -s $file && mv -f $file build-stderr.txt 42 43 file="vm$i/build-exitcode.txt" 44 test -s $file && mv -f $file build-exitcode.txt 45 46 file="vm$i/uname.txt" 47 test -s $file && mv -f $file uname.txt 48 49 file="vm$i/tests-exitcode.txt" 50 if [ ! -s $file ]; then 51 # XXX - add some tests for kernel panic's here 52 # tail -n 80 vm$i/console.txt | grep XYZ 53 echo 1 > $file 54 fi 55 rv=$(cat vm$i/tests-exitcode.txt) 56 test $rv != 0 && touch /tmp/have_failed_tests 57 58 file="vm$i/current/log" 59 if [ -s $file ]; then 60 cat $file >> log 61 awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; }; \ 62 /\[SKIP\]|\[PASS\]/{ show=0; } show' \ 63 $file > /tmp/vm${i}dbg.txt 64 fi 65 66 file="vm${i}log.txt" 67 fileC="/tmp/vm${i}log.txt" 68 if [ -s $file ]; then 69 cat $file >> summary 70 cat $file | $BASE/scripts/zfs-tests-color.sh > $fileC 71 fi 72done 73 74# create summary of tests 75if [ -s summary ]; then 76 $MERGE summary | grep -v '^/' > summary.txt 77 $MERGE summary | $BASE/scripts/zfs-tests-color.sh > /tmp/summary.txt 78 rm -f summary 79else 80 touch summary.txt /tmp/summary.txt 81fi 82 83# create file for debugging 84if [ -s log ]; then 85 awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; }; \ 86 /\[SKIP\]|\[PASS\]/{ show=0; } show' \ 87 log > summary-failure-logs.txt 88 rm -f log 89else 90 touch summary-failure-logs.txt 91fi 92 93# create debug overview for failed tests 94cat summary.txt \ 95 | awk '/\(expected PASS\)/{ if ($1!="SKIP") print $2; next; } show' \ 96 | while read t; do 97 cat summary-failure-logs.txt \ 98 | awk '$0~/Test[: ]/{ show=0; } $0~v{ show=1; } show' v="$t" \ 99 > /tmp/fail.txt 100 SIZE=$(stat --printf="%s" /tmp/fail.txt) 101 SIZE=$((SIZE/1024)) 102 # Test Summary: 103 echo "##[group]$t ($SIZE KiB)" >> /tmp/failed.txt 104 cat /tmp/fail.txt | $BASE/scripts/zfs-tests-color.sh >> /tmp/failed.txt 105 echo "##[endgroup]" >> /tmp/failed.txt 106 # Job Summary: 107 echo -e "\n<details>\n<summary>$t ($SIZE KiB)</summary><pre>" >> failed.txt 108 cat /tmp/fail.txt >> failed.txt 109 echo "</pre></details>" >> failed.txt 110done 111 112if [ -e /tmp/have_failed_tests ]; then 113 echo ":warning: Some tests failed!" >> failed.txt 114else 115 echo ":thumbsup: All tests passed." >> failed.txt 116fi 117 118if [ ! -s uname.txt ]; then 119 echo ":interrobang: Panic - where is my uname.txt?" > uname.txt 120fi 121 122# artifact ready now 123tar cf /tmp/qemu-$OS.tar -C $RESPATH -h . || true 124