diff options
Diffstat (limited to 'tests/drivers/seed_growth_test.py')
| -rw-r--r-- | tests/drivers/seed_growth_test.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/drivers/seed_growth_test.py b/tests/drivers/seed_growth_test.py new file mode 100644 index 0000000..426c970 --- /dev/null +++ b/tests/drivers/seed_growth_test.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# stage 0 accepts long source streams and grows a tiny initial image reservation. +import pathlib +import subprocess +import tempfile + +root = pathlib.Path(__file__).resolve().parents[2] +with tempfile.TemporaryDirectory(prefix='seed-growth-', dir=root / 'build') as directory: + folder = pathlib.Path(directory) + subprocess.run(['bin/genmap', '--preset', 'run', '--grow', '--genome', '600000', '--heap', '1048576', '-o', directory], check=True, capture_output=True) + compiler = folder / 'zc0' + subprocess.run(['cc', '-O1', '-w', '-fwrapv', '-DMAXW=16', 'src/tools/zc0.c', '-I' + directory, '-Isrc/core', '-o', str(compiler)], check=True) + source = '/*' + 'x' * (5 << 20) + '*/\n' + source += (folder / 'rt.zc').read_text() + (root / 'src/runtime/run.zc').read_text() + source += 'let data[550000]; fn main() { data[549999] = 7; put_n(data[549999]); put_c(32); put_n(4611686018427387904); put_c(10); return 0; }\n' + with (folder / 'genome.h').open('w') as output: + subprocess.run([str(compiler)], input=source, text=True, stdout=output, check=True, timeout=30) + binary = folder / 'vm' + import shutil + for path in ['src/micro/micro.c', 'src/micro/micro_port.h', 'src/micro/port_linux.c', 'src/core/fops.h', 'src/core/bops.h', 'src/core/stack.h']: + shutil.copy(root / path, folder) + subprocess.run(['cc', '-O2', '-w', '-fwrapv', str(folder / 'micro.c'), str(folder / 'port_linux.c'), '-I' + directory, '-o', str(binary)], check=True) + result = subprocess.run([str(binary)], text=True, capture_output=True, timeout=20) + assert result.returncode == 0 and result.stdout == '7 4611686018427387904\n', (result.returncode, result.stdout, result.stderr) +print('ok stage 0 reads beyond four megabytes and grows beyond its initial image capacity') |
