From 8e8b23b7a51e418a92e717129cccade669719aa3 Mon Sep 17 00:00:00 2001 From: diviocity Date: Tue, 1 Dec 2026 00:00:09 +0100 Subject: [PATCH] Allow desktop transaction tests to set QEMU memory --- tests/busybox/README.md | 3 +++ tests/busybox/boot.v | 33 ++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/tests/busybox/README.md b/tests/busybox/README.md index 6a32d16..c5a4183 100644 --- a/tests/busybox/README.md +++ b/tests/busybox/README.md @@ -22,6 +22,9 @@ bootloader. It uses a diskless QEMU virt machine with GICv3. The probe checks BusyBox init, shell arithmetic, applet links, `uname -o`, and the Vinix allocator's `malloc_trim`. It compares the SHA-256 of the executable and the dynamic loader printed in the guest with their installed files. +For a full desktop transaction, set `VINIX_QEMU_MEMORY_MIB=2048` to use the +same guest memory as the default desktop smoke test. Userland fixtures use +512 MiB by default. For the full release applet check, install `busybox`, `busybox-init` and their runtime dependencies into a separate root. The fixture checks the target diff --git a/tests/busybox/boot.v b/tests/busybox/boot.v index 3a4b510..dadbb1e 100644 --- a/tests/busybox/boot.v +++ b/tests/busybox/boot.v @@ -23,6 +23,19 @@ fn boot_image(root string, iso string, output string, mode string, fixture strin shell := mode == '--shell' arm := mode.starts_with('--aarch64-') userland := mode in ['--userland', '--aarch64-userland'] || fixture != '' + default_memory := if userland { + '512' + } else if arm { + '384' + } else { + '1024' + } + memory := strconv.atoi(os.getenv_opt('VINIX_QEMU_MEMORY_MIB') or { default_memory }) or { + return error('VINIX_QEMU_MEMORY_MIB must be a positive integer in MiB') + } + if memory <= 0 { + return error('VINIX_QEMU_MEMORY_MIB must be a positive integer in MiB') + } musl := mode in ['--musl', '--aarch64-musl'] machine := if arm { 'aarch64' } else { 'x86_64' } acceleration := os.getenv_opt('VINIX_QEMU_ACCEL') or { 'tcg' } @@ -67,7 +80,11 @@ fn boot_image(root string, iso string, output string, mode string, fixture strin os.write_file(os.join_path(additions, 'etc/inittab'), inittab + '\n')! mut loader_digest := '' if userland { - source := if fixture != '' { fixture } else { os.join_path(os.dir(@FILE), '..', 'userland', 'check.sh') } + source := if fixture != '' { + fixture + } else { + os.join_path(os.dir(@FILE), '..', 'userland', 'check.sh') + } os.cp(source, os.join_path(additions, helper))! } else { source := if shell { 'serial-line.v' } else { 'guest.v' } @@ -124,21 +141,15 @@ fn boot_image(root string, iso string, output string, mode string, fixture strin if disk != '' { drive := 'format=raw,snapshot=on,file=' + disk.replace(',', ',,') if arm { - emulator << ['-drive', 'if=none,id=ports,' + drive, '-device', 'virtio-blk-device,drive=ports'] + emulator << ['-drive', 'if=none,id=ports,' + drive, '-device', + 'virtio-blk-device,drive=ports'] } else { // The x86 release kernel probes ATA and AHCI before choosing the root. emulator << ['-drive', 'if=ide,' + drive] } } - memory := if userland { - '512' - } else if arm { - '384' - } else { - '1024' - } - emulator << ['-accel', acceleration, '-cpu', cpu, '-m', memory, '-smp', '2', '-nic', 'none', '-display', - 'none', '-monitor', 'none', '-serial', 'file:' + log, '-no-reboot'] + emulator << ['-accel', acceleration, '-cpu', cpu, '-m', memory.str(), '-smp', '2', '-nic', + 'none', '-display', 'none', '-monitor', 'none', '-serial', 'file:' + log, '-no-reboot'] run(['timeout', '${deadline}s', ...emulator])! lines := os.read_lines(log)!.map(it.trim_space()) if disk != '' { -- 2.56.1