-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest
executable file
·37 lines (31 loc) · 858 Bytes
/
test
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
#!/bin/bash
if [ "$#" -eq 0 ]; then
printf "Usage: $0 [filename] [any other nasm args].\nEx: $0 bootstrap-asm.asm -DDVORAK\n"
exit 1
fi
file=${@: -1}
name="${file%%.*}"
binfile="bin/$name.bin"
HEADLESS_ARGS=""
if [ "$1" = "-DHEADLESS" ]; then
HEADLESS_ARGS="-display none"
fi
PID=$$
compile() {
nasm $file -f bin -o $binfile -DDEBUGCON ${@:2:$(($#-2))} && \
qemu-system-x86_64 $QEMU_ARGS $HEADLESS_ARGS -debugcon stdio -drive file=$binfile,format=raw,if=ide
# Kill the process if we had a compile error so that we exit with non-zero
# status even though we used a pipe which exits with the tee status
ERR=$?
if [ $ERR -ne 0 ]; then
echo "Exit code: $ERR"
kill $PID
sleep 1
fi
return $ERR
}
mkdir -p `dirname $binfile`
OUTPUT=$(compile ERROR $@ | tee /dev/tty)
if grep -q "FAIL" - <<< "$OUTPUT"; then
exit 1
fi