summaryrefslogtreecommitdiff
path: root/scripts/sr-ir.sh
blob: 7ad9b99b6dd8a9326f591ecbcba7581d77bbf123 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
. scripts/lava-common.sh

# urls
acs_img='ir-acs-live-image-generic-arm64.wic.xz'
acs_url='https://people.linaro.org/~ilias.apalodimas/'"$acs_img"
post_url='https://archive.validation.linaro.org/artifacts/team/ledge/'
UBOOT='https://gitlab.com/Linaro/blueprints/nightly-builds/-/jobs/artifacts/main/raw/images/flash.bin-qemu.gz?job=build-meta-ts-qemuarm64-secureboot'

# final log files
log_file_part='/media/acs_results/sct_results/Overall/Summary'
ekl="$log_file_part"'.ekl'
log="$log_file_part"'.log'

wget "$acs_url"
unxz $acs_img
acs_img='ir-acs-live-image-generic-arm64.wic'
wget $UBOOT -O flash.bin

# Ordering matters here keep variables.img first
tmux new-session -d -s qemu \
	"qemu-system-aarch64 \
    -bios flash.bin \
    -machine virt,secure=on \
    -cpu cortex-a57 -m 2G \
    -nographic -no-acpi \
    -drive id=disk0,file=$acs_img,if=none,format=raw \
    -device virtio-blk-device,drive=disk0"

echo '########################################'
echo '# Checking QEMU ACS for completion ... #'
echo '########################################'

part=$(losetup -f -P -r --show $acs_img)'p3'
[ -z "$part" ] && lava_result 'MOUNT_LOOPBACK' 'FAILED' 'yes'

el=0
while true; do
	sudo mount "$part" /media > /dev/null 2>&1
	# Since there's no indication in SCT, grep for a very late entry in FWTS
	# logs (FWTS executes after SCT)
	stop_compl=$(grep 'Other failures' /media/acs_results/fwts/FWTSResults.log 2>/dev/null)
	[ -n "$stop_compl" ] && echo "Found SCT logs. Parsing..." && break
	stop_qemu=$(pidof qemu-system-aarch64)
	[ -z "$stop_qemu" ] && lava_result 'QEMU_PROCESS' 'FAILED' 'yes' && break

	sudo umount /media > /dev/null 2>&1
	echo "Test running for $((el/60)) minutes ..."
	sleep 120
	el=$((el+120))
done

git clone --depth=1 https://gitlab.arm.com/systemready/edk2-test-parser
cd edk2-test-parser
./parser.py "$ekl" \
	/media/acs_results/sct_results/Sequence/EBBR.seq \
	--filter "x['result'] in ['DROPPED', 'FAILURE', 'WARNING']" --uniq \
	--fields 'count,result,name' --print

# Get the key
lava_test_dir="$(find /lava-* -maxdepth 0 -type d | grep -E '^/lava-[0-9]+' 2>/dev/null | sort | tail -1)"
[ -n "$lava_test_dir" ] && . $lava_test_dir/secrets
cat $lava_test_dir/secrets

results="qemu-aarch64-$(date +%d_%m_%Y_%H_%S).tar.xz"
tar cJf $results $ekl $log

# store files
upload_dir=$(curl -F "path=@$results" -F "token=$API_KEY" "$post_url")

final_dir=$(echo $upload_dir | awk 'BEGIN{FS=OFS="/"}NF--')
final_dir="$final_dir"'/'

# used for prints
title='Download Logs'
url_num_char=${#final_dir}
title_num_char=${#title}

# pretty print logs location
printc=$(printf '%*s' "$url_num_char" | tr ' ' '#')
start=$(((url_num_char-title_num_char)/2))
echo "$printc" | awk -v start="$start" \
	-v rep="$title_num_char" \
	-v title="$title" \
	'{target=substr($0,0,rep); gsub(/#############/,title,target); \
	trail=substr($0,0,start)
	print trail target trail}'
echo "$final_dir"
echo "$printc"

sudo umount /media > /dev/null 2>&1
sudo losetup -D > /dev/null 2>&1