forked from oVirt/ovirt-tinycore-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
full-test.sh
executable file
·112 lines (87 loc) · 2.46 KB
/
full-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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
set -eao pipefail
. ./version
RET=0
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..."
nohup qemu-system-x86_64 \
-nographic \
-drive file=$(pwd)/output/oVirtTinyCore64-${VERSION}.qcow2,format=qcow2 \
-monitor telnet::2000,server,nowait >/tmp/qemu.log 2>/dev/null &
log 'Waiting for the VM to start...'
sleep 240
echo 'screendump /tmp/screendump.ppm' | nc localhost 2000 >/dev/null
sleep 1
echo -e "\033[2m"
cat /tmp/qemu.log
echo -e "\033[0m"
convert /tmp/screendump.ppm oVirtTinyCore.png
log "⚙️ Performing ACPI test..."
echo 'system_powerdown' | nc localhost 2000 >/dev/null
sleep 10
if [ -d /proc/$! ]; then
error "❌ Test failed: the virtual machine didn't properly respond to shutdown command."
echo 'Taking another screenshot...'
echo 'screendump /tmp/screendump-failed_shutdown.ppm' | nc localhost 2000 >/dev/null &
sleep 5
echo 'Forcing VM poweroff...'
echo 'quit' | nc localhost 2000 > /dev/null &
convert /tmp/screendump-failed_shutdown.ppm oVirtTinyCore-failed_shutdown.png
sleep 1
RET=1
else
success "✅ Test successful."
fi
log "⚙️ Performing OCR test..."
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."
RET=1
else
success "✅ Test successful."
fi
exit ${RET}