summaryrefslogtreecommitdiff
path: root/tests/run-qemu.sh.template
blob: aba8d68a616440357b7b7ab24451ea5ff5d06c5a (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
#!/bin/sh
# Copyright (C) 2024 Free Software Foundation
#
# This program is free software ; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation ; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY ; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the program ; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

set -e

cmd="QEMU_BIN QEMU_OPTS -cdrom tests/test-TESTNAME.iso"
log="tests/test-TESTNAME.raw"

echo "temp log $log"
if which QEMU_BIN >/dev/null ; then
    if ! timeout -v --foreground --kill-after=3 15s $cmd \
            | tee $log | sed -n "/TEST_START_MARKER/"',$p' ; then
        exit 10  # timeout
    fi
    if grep -qi 'TEST_FAILURE_MARKER' $log; then
        exit 99  # error marker found, test explicitely failed
    fi
    if ! grep -q 'TEST_SUCCESS_MARKER' $log; then
        exit 12  # missing reboot marker, maybe the kernel crashed
    fi
else
    echo "skipping, QEMU_BIN not found"
    exit 77
fi