forked from oVirt/ovirt-tinycore-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·90 lines (71 loc) · 1.86 KB
/
test.sh
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
# SPDX-License-Identifier: GPL-2.0-or-later
set -eao pipefail
. ./version
if [ ! -f "qcowbuilddir/oVirtTinyCore64-${VERSION}.qcow2" ]; then
echo -e "\033[0;31mPlease run 'packer build .' first\033[0m" >&2
exit 1
fi
if ! command -v gocr &> /dev/null
then
echo -e "\033[0;31mPlease install gocr to run this test.\033[0m" >&2
exit 1
fi
if ! command -v qemu-system-x86_64 &> /dev/null
then
echo -e "\033[0;31mPlease install qemu to run this test.\033[0m" >&2
exit 1
fi
if ! command -v nc &> /dev/null
then
echo -e "\033[0;31mPlease install netcat to run this test.\033[0m" >&2
exit 1
fi
if ! command -v convert &> /dev/null
then
echo -e "\033[0;31mPlease install imagemagick to run this test.\033[0m" >&2
exit 1
fi
function group {
if [ -n "${GITHUB_ACTIONS}" ]; then
echo -n "::group::"
fi
echo -e $1
}
function endgroup {
if [ -n "${GITHUB_ACTIONS}" ]; then
echo "::endgroup::"
fi
}
function log {
echo -e "\033[0;33m$*\033[0m"
}
function error {
echo -e "\033[0;31m$*\033[0m"
}
function success {
MSG=$1
echo -e "\033[0;32m${MSG}\033[0m"
}
log "⚙️ Starting VM with image..."
(
qemu-system-x86_64 \
-nographic \
-serial mon:stdio \
-drive file=$(pwd)/output/oVirtTinyCore64-${VERSION}.qcow2,format=qcow2 \
-monitor telnet::2000,server,nowait >/tmp/qemu.log
) &
sleep 240
echo 'screendump /tmp/screendump.ppm
system_powerdown' | nc localhost 2000 >/dev/null
sleep 10
echo -e "\033[2m"
cat /tmp/qemu.log
echo -e "\033[0m"
convert /tmp/screendump.ppm oVirtTinyCore.png
log "⚙️ Performing OCR and evaluating results..."
if [ $(gocr -m 4 /tmp/screendump.ppm 2>/dev/null | grep 'Customized for oVirt by Lev Veyde' | wc -l) -ne 1 ]; then
error "❌ Test failed: the virtual machine did not print \"Customized for oVirt by Lev Veyde\" to the output when run."
exit 1
fi
success "✅ Test successful."