#!/usr/bin/env python3 # image output can grow past its first buffer and the building host's genome slot. import pathlib import subprocess import sys root = pathlib.Path(__file__).resolve().parents[2] source = '''fn main() { int retained = 7; int n = build_image_grow(GORG, 8); gc(); put_n(n > FBOT - GORG); put_c(32); put_n(image_size == n && image_words[6] == GORG + n); put_c(32); put_n(image_words[5] > GORG && image_words[5] < image_words[6]); put_c(32); put_n(retained); put_c(10); return 0; } `''' source += (root / 'src/runtime/rt.zc').read_text() source += (root / 'src/runtime/run.zc').read_text() source += 'let padding[350000]; fn main() { return padding[349999]; }\n' result = subprocess.run(sys.argv[1:], input=source, capture_output=True, text=True, timeout=40) assert result.returncode == 0, (result.stdout, result.stderr) assert result.stdout == '1 1 1 7\n', result.stdout[:1000] print('ok growing image output keeps logical addresses and older frames intact')