aboutsummaryrefslogtreecommitdiff
path: root/tests/drivers/genome_blob_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/drivers/genome_blob_test.py')
-rw-r--r--tests/drivers/genome_blob_test.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/drivers/genome_blob_test.py b/tests/drivers/genome_blob_test.py
index 81533a7..fea055b 100644
--- a/tests/drivers/genome_blob_test.py
+++ b/tests/drivers/genome_blob_test.py
@@ -1,13 +1,17 @@
#!/usr/bin/env python3
# documentation precedes the symbol table; the boot header must skip those bytes.
+# usage: python3 tests/drivers/genome_blob_test.py [build/lsp] (the documented language server image)
import pathlib
import re
+import struct
+import sys
-source = pathlib.Path('src/core/genome.h').read_text()
-org = int(re.search(r'#define GORG (\d+)', source)[1])
-length = int(re.search(r'#define GLEN (\d+)', source)[1])
-words = [int(word.strip()) for word in re.search(r'genome\[\]\s*=\s*\{([\s\S]*?)\};', source)[1].split(',') if word.strip()]
-assert len(words) == length and words[6] == org + length
+folder = pathlib.Path(sys.argv[1] if len(sys.argv) > 1 else 'build/lsp')
+image = (folder / 'lsp_genome.bin').read_bytes()
+org = int(re.search(r'#define GORG (?:0x)?([0-9A-Fa-f]+)', (folder / 'memmap.h').read_text())[1], 16)
+words = list(struct.unpack('<%dq' % (len(image) // 8), image))
+length = len(words)
+assert words[6] == org + length
cursor = words[5] - org
assert 7 <= cursor < length
records = {}
@@ -23,8 +27,8 @@ while words[cursor]:
cursor += 1
records[name] = (kind, value, signature)
assert cursor == length - 1
-assert len(records) > 1000 and records['start'][0] == 1
-assert records['reserve_code'][0] == 1 and records['build_image_grow'][0] == 1
+assert len(records) > 1000 and records['run.start'][0] == 1
+assert records['run.reserve_code'][0] == 1 and records['run.build_image'][0] == 1
assert any(name.startswith('doc ') for name in records), 'the fixture contains documentation bytes'
for name, (kind, value, _) in records.items():
if kind == 8: