aboutsummaryrefslogtreecommitdiff
path: root/tests/drivers/genome_blob_test.py
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
commitecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch)
tree70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /tests/drivers/genome_blob_test.py
a
Diffstat (limited to 'tests/drivers/genome_blob_test.py')
-rw-r--r--tests/drivers/genome_blob_test.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/drivers/genome_blob_test.py b/tests/drivers/genome_blob_test.py
new file mode 100644
index 0000000..81533a7
--- /dev/null
+++ b/tests/drivers/genome_blob_test.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+# documentation precedes the symbol table; the boot header must skip those bytes.
+import pathlib
+import re
+
+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
+cursor = words[5] - org
+assert 7 <= cursor < length
+records = {}
+while words[cursor]:
+ kind, value, signature = words[cursor:cursor + 3]
+ assert kind in (1, 2, 3, 4, 6, 8), (cursor, kind)
+ cursor += 3
+ name = ''
+ while words[cursor]:
+ assert 0 < words[cursor] < 128, (cursor, words[cursor])
+ name += chr(words[cursor])
+ cursor += 1
+ 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 any(name.startswith('doc ') for name in records), 'the fixture contains documentation bytes'
+for name, (kind, value, _) in records.items():
+ if kind == 8:
+ assert org <= value < org + length and words[value - org] >= 0, name
+print('ok documented genome starts its symbol table at the header address')