-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtest.sh
executable file
·92 lines (83 loc) · 1.72 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
91
92
#!/usr/bin/env bash
build="$(dirname $0)/build"
assets="$(dirname $0)/assets"
vga="-vga none"
log=""
kvm=""
cpu="Broadwell,+pdpe1gb,-check"
smp=4
mem=2048
clean=""
while true; do
case "$1" in
-c | --clean)
clean="yes"
shift
;;
-v | --vga)
vga=""
shift
;;
-k | --kvm)
kvm="-enable-kvm"
cpu="host"
shift
;;
-c | --cpus)
smp=$2
shift 2
;;
-m | --memory)
mem=$2
shift 2
;;
-l | --log)
log="-d mmu,int,guest_errors -D jsix.log"
shift
;;
*)
if [ -d "$1" ]; then
build="$1"
shift
fi
break
;;
esac
done
if [[ ! -c /dev/kvm ]]; then
kvm=""
fi
if [[ -n $clean ]]; then
ninja -C "${build}" -t clean
fi
if ! ninja -C "${build}"; then
exit 255
fi
qemu-system-x86_64 \
-drive "if=pflash,format=raw,readonly,file=${assets}/ovmf/x64/ovmf_code.fd" \
-drive "if=pflash,format=raw,file=${build}/ovmf_vars.fd" \
-drive "format=raw,file=${build}/jsix.img" \
-serial "file:${build}/qemu_test_com1.txt" \
-debugcon "file:${build}/qemu_debugcon.txt" \
-smp "${smp}" \
-m $mem \
-cpu "${cpu}" \
-M q35 \
-no-reboot \
-nographic \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
$log $vga $kvm $debug > "${build}/qemu_test_out.txt"
result=$?
if [[ $result -eq 0 ]]; then
echo "Somehow exited with status 0" > /dev/stderr
exit 1
fi
if [[ $result -eq 1 ]]; then
echo "QEMU returned an error status" > /dev/stderr
exit 1
fi
((result = ($result >> 1) - 1))
if [[ $result -gt 0 ]]; then
cat "${build}/qemu_test_com1.txt"
fi
exit $result