Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 8de9148

Browse files
authored
Merge pull request #107 from bjones1/mdb-fix
Mdb fix
2 parents 8342e0a + 7088d4c commit 8de9148

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bookserver/internal/common_builder.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ def check_sim_out(out_list, verification_code):
175175
# Get lines, with fallback if they don't exist.
176176
second_to_last_line = sl[-2] if len(sl) >= 2 else ""
177177
last_line = sl[-1] if len(sl) >= 1 else ""
178-
return (second_to_last_line == "Correct.") and (last_line == str(verification_code))
178+
return (second_to_last_line == "Correct.") and (
179+
last_line.strip() == str(verification_code)
180+
)
179181

180182

181183
# Run MDB
@@ -194,7 +196,6 @@ def sim_run_mdb(
194196
# A path to the binary (typically in .elf format) to simulate.
195197
sim_binary_path,
196198
):
197-
198199
# Get or create an instance of the simulator.
199200
po = _tls.__dict__.get("po")
200201
if (
@@ -211,7 +212,7 @@ def sim_run_mdb(
211212
_tls.simout_path, "w+", encoding="utf-8", errors="backslashreplace"
212213
)
213214

214-
# Java, by default, doesn't free memory until it gets low, making it a memory hog. The `Java command-line flags <https://docs.oracle.com/en/java/javase/13/docs/specs/man/java.html>`_ ``-Xms750M -Xmx750M`` specify a heap size of 750 MB. However, these options must go before the ``--jar`` option when invoking ``java``, meaning they require hand edits to ``mdb.bat/sh``; they can't be passed as paramters (which are placed after ``--jar`` by ``mdb.bat/sh``). Therefore, use the `JAVA_TOOL_OPTIONS <https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars002.html>`_ env var to pass these parameters.
215+
# Java, by default, doesn't free memory until it gets low, making it a memory hog. The `Java command-line flags <https://docs.oracle.com/en/java/javase/13/docs/specs/man/java.html>`_ ``-Xms750M -Xmx750M`` specify a heap size of 750 MB. However, these options must go before the ``--jar`` option when invoking ``java``, meaning they require hand edits to ``mdb.bat/sh``; they can't be passed as parameters (which are placed after ``--jar`` by ``mdb.bat/sh``). Therefore, use the `JAVA_TOOL_OPTIONS <https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars002.html>`_ env var to pass these parameters.
215216
sim_env = os.environ.copy()
216217
sim_env["JAVA_TOOL_OPTIONS"] = "-Xms750M -Xmx750M"
217218
# Start the simulator.
@@ -256,7 +257,8 @@ def on_exit():
256257
end_time = time.time() + 15
257258
output = []
258259
while time.time() < end_time:
259-
if po.poll() is None:
260+
# If the process terminates (a not-``None`` return value), read the last output then exit the loop.
261+
if po.poll() is not None:
260262
output.append(po.communicate()[0])
261263
break
262264
line = po.stdout.readline()

0 commit comments

Comments
 (0)