Skip to content

Commit 5405e65

Browse files
committed
Add application based tests
1 parent ad7ae61 commit 5405e65

19 files changed

+204
-23
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
local_notes/
44
build/
55
src_test/
6-
build_test/
6+
build_test/
7+
__pycache__/
8+
.vscode/

before_install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22
apt-get update
33
apt install -y make nasm gcc cpulimit qemu-system-x86 gocr expect gdb graphicsmagick-imagemagick-compat
4+
5+
python3 -m pip install -r requirements.txt

emulator/Makefile.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
QEMU_SHUT_FLAGS= -no-shutdown -no-reboot
22
QEMU_EXTRA_FLAGS=
33
QEMU_GDB_PORT=9000
4+
QEMU_MONITOR_PORT=55555
45
GDB_EX='echo Use GDB_EX="<command>" to execute command on connect.\n'
56

67
qemu: $(image_vmdk)
@@ -9,6 +10,9 @@ qemu: $(image_vmdk)
910
qemu_vvv: $(image_vmdk)
1011
qemu-system-x86_64 -smp 1 -m 128M -hda $< $(QEMU_SHUT_FLAGS) $(QEMU_EXTRA_FLAGS) -d cpu,exec,in_asm
1112

13+
qemu_monitor: $(image_vmdk)
14+
qemu-system-x86_64 -smp 1 -m 128M -hda $< $(QEMU_SHUT_FLAGS) $(QEMU_EXTRA_FLAGS) -monitor telnet:127.0.0.1:$(QEMU_MONITOR_PORT),server,nowait
15+
1216
qemu_debug: $(image_vmdk)
1317
qemu-system-x86_64 -S -gdb tcp::$(QEMU_GDB_PORT) -smp 1 -m 128M -hda $< $(QEMU_SHUT_FLAGS) -d cpu,exec,in_asm
1418

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pexpect

tests/__init__.py

Whitespace-only changes.

tests/app/cat_test.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
# Test is supposed to be sourced from shell_test.sh
4+
5+
python3 -m tests.qemu.monitor -p ${MONITOR_PORT:?} -sc run cat
6+
7+
test_create_screen_dump
8+
test_screen_content $LINENO "Experimental OS"
9+
test_screen_content $LINENO "The project is still under development"

tests/app/ls_test.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Test is supposed to be sourced from shell_test.sh
4+
5+
python3 -m tests.qemu.monitor -p ${MONITOR_PORT:?} -sc run ls
6+
7+
test_create_screen_dump
8+
test_screen_content $LINENO "cat"
9+
test_screen_content $LINENO "calc"
10+
test_screen_content $LINENO "ls"
11+
test_screen_content $LINENO "tictactoe"

tests/app/shell_test.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Test is supposed to be sourced from fuzzy_app_test.sh
4+
5+
test_screen_content $LINENO "Simple Shell"
6+
7+
# Test applications
8+
source tests/app/ls_test.sh
9+
source tests/app/tictactoe_test.sh
10+
source tests/app/cat_test.sh

tests/app/tictactoe_test.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Test is supposed to be sourced from shell_test.sh
4+
5+
python3 -m tests.qemu.monitor -p ${MONITOR_PORT:?} -sc run tictactoe
6+
7+
test_create_screen_dump
8+
test_screen_content $LINENO "TicTacToe"
9+
test_screen_content $LINENO "Q to quit game"
10+
11+
python3 -m tests.qemu.monitor -p ${MONITOR_PORT:?} -sc 'q'

tests/bootloader_stage1_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ set -x
1414
test_screen_content $LINENO "Bootloader: Stage 1"
1515
test_screen_content $LINENO "Stage 2 Loaded: `build_8hexbyte bootloader/stage2`"
1616

17+
python -m tests.qemu.monitor --quit
1718
wait ${QEMU_PID:?}
1819
echo "$0 passed!!!"

0 commit comments

Comments
 (0)