diff options
| author | 2026-10-12 08:46:23 +0330 | |
|---|---|---|
| committer | 2026-10-12 08:46:23 +0330 | |
| commit | ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch) | |
| tree | 70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /tests/drivers/memory_limits_test.py | |
a
Diffstat (limited to 'tests/drivers/memory_limits_test.py')
| -rw-r--r-- | tests/drivers/memory_limits_test.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/drivers/memory_limits_test.py b/tests/drivers/memory_limits_test.py new file mode 100644 index 0000000..a973480 --- /dev/null +++ b/tests/drivers/memory_limits_test.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# focused host memory configuration and growth checks. +import os +import subprocess + +source = '''fn main() { + int initial = syscall(9, 0, 0, 0); + put_n(syscall(9, 5, initial, 0) == initial); put_c(32); + put_n(syscall(9, 4, initial + 4096, 0) == -1); put_c(32); + put_n(syscall(9, 5, initial + 8192, 0) == initial + 8192); put_c(32); + put_n(syscall(9, 4, initial + 4096, 0) == initial + 4096); put_c(32); + put_n(syscall(9, 5, initial - 1, 0) == -1); put_c(10); + return 0; +} +''' +commands = [['bin/zy'], ['bin/zym'], ['node', 'src/js/tinyvm.js']] +environment = dict(os.environ, TINYVM_MAX_MEMORY_WORDS='16777216') +for command in commands: + result = subprocess.run(command, input=source, text=True, capture_output=True, env=environment, timeout=15) + assert result.returncode == 0 and result.stdout == '1 1 1 1 1\n', (command, result.stdout, result.stderr) + invalid = subprocess.run(command, input=source, text=True, capture_output=True, env=dict(environment, TINYVM_MEMORY_WORDS='1'), timeout=15) + assert invalid.returncode != 0 and invalid.stderr, (command, invalid.stdout) + print('ok runtime memory limits, denied growth, successful growth, and invalid startup: ' + command[0]) |
