@@ -5,19 +5,51 @@ SRC_TEST_DIR="src_test/"
55MONITOR_PORT=55555
66QEMU_SCREENSHOT=" /tmp/qemu.ppm"
77
8+
9+ # #########################################
10+ # Activate Code for testing within source.
11+ # Arguments:
12+ # Filename
13+ # Inject Keyword
14+ # #########################################
15+ function inject_test_code() {
16+ echo " Injecting Test Code in $1 (if any)"
17+ sed -i " s/;\s*${2} :\s*//g" " $1 "
18+ }
19+ export -f inject_test_code
20+
21+
22+ # #########################################
23+ # Copy SRC to Test Sorce and Inject Code.
24+ # Arguments:
25+ # Inject Keyword
26+ # #########################################
27+ function sync_to_src_test() {
28+ echo " HEREEEEEE!"
29+ # Prepare source code directory for tests.
30+ rsync -r " ${SRC_DIR:? } " " ${SRC_TEST_DIR:? } "
31+
32+ find " ${SRC_TEST_DIR:? } " -iname ' *.asm' -exec bash -c ' inject_test_code "$0" "$1"' {} " $1 " \;
33+ }
34+
35+
836# ##################################################
937# Turn up OS in QEMU and wait for $TEST_MAGIC_WANT.
1038# Globals:
1139# TEST_MAGIC_WANT
1240# COMMAND_OUTPUT
1341# SCREEN_CONTENT
1442# QEMU_PID
43+ # Arguments:
44+ # Inject Keyword
1545# Outputs:
1646# Logs
1747# Returns:
1848# 0 on success, non-zero on error.
1949# ##################################################
20- function os_up() {
50+ function os_test_up() {
51+ sync_to_src_test " $1 "
52+
2153 # Turn up QEMU in background
2254 make qemu SRC_DIR=" ${SRC_TEST_DIR:? } " \
2355 QEMU_SHUT_FLAGS=" " \
@@ -44,6 +76,7 @@ function os_up() {
4476 echo " Magic Word Found! Continuing the test..." && \
4577 break
4678 echo " Magic word not found! Got: $COMMAND_OUTPUT "
79+ sleep 1s
4780 done
4881
4982 if [ ! -f ${QEMU_SCREENSHOT:? } ]; then
0 commit comments