From ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Mon, 12 Oct 2026 08:46:23 +0330 Subject: a --- tests/drivers/layout_config_test.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/drivers/layout_config_test.py (limited to 'tests/drivers/layout_config_test.py') diff --git a/tests/drivers/layout_config_test.py b/tests/drivers/layout_config_test.py new file mode 100644 index 0000000..469e7dd --- /dev/null +++ b/tests/drivers/layout_config_test.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# generated layouts expose initial reservations and reject arithmetic overflow. +import pathlib +import subprocess +import tempfile + +root = pathlib.Path(__file__).resolve().parents[2] +tool = root / 'bin/genmap' +result = subprocess.run([tool, '--help'], capture_output=True, text=True) +assert result.returncode == 0 and '--generated-text' in result.stderr +invalid = [ + ['--symbols', '2147483647'], ['--code', '2147483647'], + ['--frame', '2147483647'], ['--return', '2147483647'], + ['--asm-labels', '2147483647'], ['--enum-members', '2147483647'], + ['--regions', '2147483647'], ['--heap', '7'], ['--hash', '3'], +] +for options in invalid: + result = subprocess.run([tool, '--preset', 'default', *options], capture_output=True, text=True) + assert result.returncode != 0 and result.stderr, options +with tempfile.TemporaryDirectory(dir=root / 'build') as directory: + options = ['--asm-labels', '4', '--asm-refs', '8', '--exit', '32', '--enum-members', '8', '--tagged-enums', '2', '--methods', '2', '--generated-text', '64', '--facts', '2', '--paths', '2', '--regions', '2'] + subprocess.run([tool, '--preset', 'default', *options, '-o', directory], check=True, capture_output=True) + source = (pathlib.Path(directory) / 'compiler.zc').read_text() + for name, value in [('ASM_LABELS', '4'), ('ASM_REFS', '8'), ('EXIT_WORDS', '20'), ('ENUM_MEMBERS', '8'), ('TAGGED_ENUMS', '2'), ('STRUCT_METHODS', '2'), ('GENERATED_WORDS', '40'), ('RANGE_FACTS', '2'), ('JOIN_PATHS', '2'), ('O3_REGIONS', '2')]: + assert f'const {name} = 0x{value};' in source, name +print('ok parser layout controls and invalid configuration checks') -- cgit v1.2.3