aboutsummaryrefslogtreecommitdiff
path: root/tests/drivers/image_growth_test.py
blob: 064eae771bcefbd8b235563b3cc7b2211b1b20f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/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')