xref: /qemu/tests/multiboot/run_test.sh (revision b43671f80cda8d0f11dcb929ed76fbd680c29cec)
1d1f3a23bSKevin Wolf#!/bin/bash
2d1f3a23bSKevin Wolf
3d1f3a23bSKevin Wolf# Copyright (c) 2013 Kevin Wolf <kwolf@redhat.com>
4d1f3a23bSKevin Wolf#
5d1f3a23bSKevin Wolf# Permission is hereby granted, free of charge, to any person obtaining a copy
6d1f3a23bSKevin Wolf# of this software and associated documentation files (the "Software"), to deal
7d1f3a23bSKevin Wolf# in the Software without restriction, including without limitation the rights
8d1f3a23bSKevin Wolf# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9d1f3a23bSKevin Wolf# copies of the Software, and to permit persons to whom the Software is
10d1f3a23bSKevin Wolf# furnished to do so, subject to the following conditions:
11d1f3a23bSKevin Wolf#
12d1f3a23bSKevin Wolf# The above copyright notice and this permission notice shall be included in
13d1f3a23bSKevin Wolf# all copies or substantial portions of the Software.
14d1f3a23bSKevin Wolf#
15d1f3a23bSKevin Wolf# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16d1f3a23bSKevin Wolf# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17d1f3a23bSKevin Wolf# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18d1f3a23bSKevin Wolf# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19d1f3a23bSKevin Wolf# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20d1f3a23bSKevin Wolf# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21d1f3a23bSKevin Wolf# THE SOFTWARE.
22d1f3a23bSKevin Wolf
23d1f3a23bSKevin WolfQEMU=${QEMU:-"../../x86_64-softmmu/qemu-system-x86_64"}
24d1f3a23bSKevin Wolf
25d1f3a23bSKevin Wolfrun_qemu() {
26d1f3a23bSKevin Wolf    local kernel=$1
27d1f3a23bSKevin Wolf    shift
28d1f3a23bSKevin Wolf
29*b43671f8SEric Blake    printf %b "\n\n=== Running test case: $kernel $@ ===\n\n" >> test.log
30d1f3a23bSKevin Wolf
31d1f3a23bSKevin Wolf    $QEMU \
32d1f3a23bSKevin Wolf        -kernel $kernel \
33d1f3a23bSKevin Wolf        -display none \
34d1f3a23bSKevin Wolf        -device isa-debugcon,chardev=stdio \
35d1f3a23bSKevin Wolf        -chardev file,path=test.out,id=stdio \
36d1f3a23bSKevin Wolf        -device isa-debug-exit,iobase=0xf4,iosize=0x4 \
37d1f3a23bSKevin Wolf        "$@"
38d1f3a23bSKevin Wolf    ret=$?
39d1f3a23bSKevin Wolf
40d1f3a23bSKevin Wolf    cat test.out >> test.log
41d1f3a23bSKevin Wolf}
42d1f3a23bSKevin Wolf
43d1f3a23bSKevin Wolfmmap() {
44d1f3a23bSKevin Wolf    run_qemu mmap.elf
45d1f3a23bSKevin Wolf    run_qemu mmap.elf -m 1.1M
46d1f3a23bSKevin Wolf    run_qemu mmap.elf -m 2G
47d1f3a23bSKevin Wolf    run_qemu mmap.elf -m 4G
48d1f3a23bSKevin Wolf    run_qemu mmap.elf -m 8G
49d1f3a23bSKevin Wolf}
50d1f3a23bSKevin Wolf
51a9c837d8SKevin Wolfmodules() {
52a9c837d8SKevin Wolf    run_qemu modules.elf
53a9c837d8SKevin Wolf    run_qemu modules.elf -initrd module.txt
54a9c837d8SKevin Wolf    run_qemu modules.elf -initrd "module.txt argument"
55a9c837d8SKevin Wolf    run_qemu modules.elf -initrd "module.txt argument,,with,,commas"
56a9c837d8SKevin Wolf    run_qemu modules.elf -initrd "module.txt,module.txt argument,module.txt"
57a9c837d8SKevin Wolf}
58d1f3a23bSKevin Wolf
59d1f3a23bSKevin Wolfmake all
60d1f3a23bSKevin Wolf
61a9c837d8SKevin Wolffor t in mmap modules; do
62d1f3a23bSKevin Wolf
63d1f3a23bSKevin Wolf    echo > test.log
64d1f3a23bSKevin Wolf    $t
65d1f3a23bSKevin Wolf
66d1f3a23bSKevin Wolf    debugexit=$((ret & 0x1))
67d1f3a23bSKevin Wolf    ret=$((ret >> 1))
68d1f3a23bSKevin Wolf    pass=1
69d1f3a23bSKevin Wolf
70d1f3a23bSKevin Wolf    if [ $debugexit != 1 ]; then
71*b43671f8SEric Blake        printf %b "\e[31m ?? \e[0m $t (no debugexit used, exit code $ret)\n"
72d1f3a23bSKevin Wolf        pass=0
73d1f3a23bSKevin Wolf    elif [ $ret != 0 ]; then
74*b43671f8SEric Blake        printf %b "\e[31mFAIL\e[0m $t (exit code $ret)\n"
75d1f3a23bSKevin Wolf        pass=0
76d1f3a23bSKevin Wolf    fi
77d1f3a23bSKevin Wolf
78d1f3a23bSKevin Wolf    if ! diff $t.out test.log > /dev/null 2>&1; then
79*b43671f8SEric Blake        printf %b "\e[31mFAIL\e[0m $t (output difference)\n"
80d1f3a23bSKevin Wolf        diff -u $t.out test.log
81d1f3a23bSKevin Wolf        pass=0
82d1f3a23bSKevin Wolf    fi
83d1f3a23bSKevin Wolf
84d1f3a23bSKevin Wolf    if [ $pass == 1 ]; then
85*b43671f8SEric Blake        printf %b "\e[32mPASS\e[0m $t\n"
86d1f3a23bSKevin Wolf    fi
87d1f3a23bSKevin Wolf
88d1f3a23bSKevin Wolfdone
89