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