summaryrefslogtreecommitdiff
path: root/scripts/sr-ir.sh
blob: 5cc6e735cf9fa301a33f1cf72882aa7c1cb04d61 (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
#!/bin/bash
. scripts/lava-common.sh

# urls
acs_img='ir_acs_live_image.img'
acs_url='https://people.linaro.org/~ilias.apalodimas/qemu/debian/'"$acs_img"
post_url='https://archive.validation.linaro.org/artifacts/team/systemready/'

# 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"
wget https://people.linaro.org/~ilias.apalodimas/images/ubuntu-21.04/variables.img
# FIXME compile this from source
wget https://people.linaro.org/~ilias.apalodimas/qemu/debian/u-boot.bin

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

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

part=$(losetup -f -P -r --show $acs_img)'p2'
[ -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
git clone --branch vincent/master 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

# store files
ekl=$(curl -F "path=@$ekl" -F "token=$API_KEY" "$post_url")
log=$(curl -F "path=@$log" -F "token=$API_KEY" "$post_url")
final_dir=$(echo $ekl | 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