Skip to content

Commit a8c35a5

Browse files
committed
[Test] Compare memory load from disk for BT Stage 1.
1 parent aa5f23e commit a8c35a5

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

src/bootloader/stage1.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
JMP label_exit
3232

3333
label_bts2_loaded:
34-
move_xy 06, 07, 00
34+
print_string_ext bls2_loaded, bls2_loaded_len, 06, 07, C_WHITE, C_BLACK, 0
3535
print_hex_string_ext 0x8000, 10, C_WHITE, 0
3636
; __TEST_INJECT_BT1__: mov eax, 0x9A11C824
3737
; __TEST_INJECT_BT1__: HLT
@@ -47,7 +47,7 @@ label_exit:
4747
bl_welcome_len equ ($-bl_welcome)
4848
bls1 db "Bootloader: Stage 1"
4949
bls1_len equ ($-bls1)
50-
bls2_loaded db "Stage 2 Loaded. Trying to launch..."
50+
bls2_loaded db "Stage 2 Loaded: "
5151
bls2_loaded_len equ ($-bls2_loaded)
5252
bls2_load_fail db "Stage 2 Load Failed!"
5353
bls2_load_fail_len equ ($-bls2_load_fail)

tests/bootloader_stage1_test.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ os_test_up "${TEST_MAGIC_WANT:?}" "${TEST_INJECT_WORD:?}" || exit -1
99

1010
# Test
1111
set -e
12+
set -x
13+
1214
echo "${SCREEN_CONTENT:?}" | grep "Bootloader: Stage 1" || \
13-
( echo "Test Failed!" && exit -1 )
15+
err $LINENO "Test Failed! "
16+
17+
echo "${SCREEN_CONTENT:?}" | grep "Stage 2 Loaded: `build_8hexbyte bootloader/stage2`" || \
18+
err $LINENO "Test Failed! "
1419

1520
wait ${QEMU_PID:?}
1621
echo "$0 passed!!!"

tests/lib.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,43 @@ MONITOR_PORT=55555
77
QEMU_SCREENSHOT="/tmp/qemu.ppm"
88

99

10+
##########################################
11+
# Raise error.
12+
# Arguments:
13+
# line number
14+
# error message
15+
# Output:
16+
# error to stderr
17+
##########################################
18+
function err() {
19+
echo -e "\e[01;31m[`basename $0`:$1] error\e[0m: $2" >&1
20+
exit -1
21+
}
22+
23+
24+
##########################################
25+
# Resolves filename from build target.
26+
# Arguments:
27+
# build target
28+
# Output:
29+
# filename
30+
##########################################
31+
function build_filename() {
32+
echo "${BUILD_TEST_DIR:?}/${1}"
33+
}
34+
35+
##########################################
36+
# Prints first 8 hex bytes of given file.
37+
# Arguments:
38+
# build target
39+
# Output:
40+
# first 8 byte
41+
##########################################
42+
function build_8hexbyte() {
43+
xxd -p -g1 -l 8 -u "`build_filename $1`"
44+
}
45+
46+
1047
##########################################
1148
# Activate Code for testing within source.
1249
# Arguments:

tests/run.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ set -e
44
# Execute Tests
55
timeout 2m bash tests/bootloader_stage1_test.sh
66
timeout 2m bash tests/bootloader_stage2_test.sh
7-
87
# TODO: Temporarily disabling following tests, until they are ready.
98
# timeout 2m bash tests/kernel_core_entry_test.sh
109

0 commit comments

Comments
 (0)