Add coreutils test runner via lind_run (Fixes #53)#55
Conversation
Implements test infrastructure for running GNU coreutils test suite with binaries executing in Lind WASM sandbox via lind_run. Approach: - Configure coreutils natively to generate test infrastructure - Create wrapper scripts in src/ calling 'lind_run binary.cwasm' - Run 'make check' with PATH pointing to wrappers Results: 1 PASS, 16 FAIL, 6 SKIP Key findings: 1. ioctl syscall not supported - ls and terminal utils fail 2. Test infrastructure needs native filesystem access 3. Current wrapper approach sandboxes ALL utilities including test framework tools Files added: - run_coreutils_tests_lind.sh: Script to run coreutils tests via Lind - FINDINGS.md: Detailed analysis of errors and recommendations Closes #53
5c8262e to
64d54d8
Compare
|
Hi Sean @moogchi ! Thank you for your efforts in running the coreutils tests. Great that you could finish it so quickly. I had a question regarding the number of tests and success/fail. I see different number of tests tested in FINDINGS.md vs the description of the PR. Could you please explain which one is the correct one? It is a good design to use native version for rm, chmod when they are being used to do setup of the test environment. But I would recommend that tests which actually test these tools should be using the WASM version and run with lind_run. That is, ideally we should be testing ALL coreutils binaries. So there should be a way to use native binaries to do the test setup etc, but then we should WASM binaries while running the tests. |
|
The number discrepancy is because FINDINGS.md had results from an earlier run. I'm removing it and keeping everything in the PR description instead, which reflects the latest results (203 PASS, 158 FAIL, 55 SKIP). |
|
Sounds good, thanks! |
…dating moving test files over
|
@rennergade @moogchi I was trying to reproduce the coreutils build. It did produce the wasm binaries, but I also got the following error which is because of glibc math. @rennergade Did you see this error before, specifically 'sort' |
|
Yeah those should go away when the libm fixes are merged, but as you said it isnt fatal and still produces non-math related binaries for now |
…e creation in tmp
|
Awesome. Can you add a path to the top level Makefile to run this? Also we shouldn't merge findings.md, instead can you put up separate issues in the repo for each finding that needs to be addressed? As far as the relative path stuff, put up an issue for that too but its fine if it fails for now |
| /bin/rm -f "$target" 2>/dev/null || true | ||
| cat > "$target" <<WRAPPER | ||
| #!/bin/bash | ||
| exec sudo LINDFS_ROOT="$LINDFS_ROOT" "$LINDBOOT_BIN" "$wasm_path" "\$@" |
There was a problem hiding this comment.
@moogchi This line tries to run the wasm binary within lindfs right..
exec sudo LINDFS_ROOT="$LINDFS_ROOT" "$LINDBOOT_BIN" "$wasm_path" "\$@
expands to
If the binary that we test is ls.wasm, then the above expands to,
sudo LINDFS_ROOT=/home/lind-wasm/lindfs /home/lind-wasm/build/lind-boot /home/lind-wasm/lindfs/opt/coreutils/ls.wasm
Essentially, in this case "$LINDBOOT_BIN" is invoked to run the wasm binary. But to run wasm binaries we use either
/home/lind-wasm/scripts/lind-run or lind-wasm
@Yaxuan-w Could you pls verify this?
There was a problem hiding this comment.
lind_run already calls lind-boot under the hood. If you look at scripts/lind_run, it resolves REPO_ROOT, finds lind-boot, and does exec "${LINDBOOT_BIN}" "$@". We call lind-boot directly because lind_run re-execs with sudo which was causing issues with environment variable passing. The LINDFS_ROOT env var needs to be set for lind-boot to know where the sandbox filesystem is. But I can switch to using lind_run if that's more convinent.
There was a problem hiding this comment.
Thanks!
@rennergade What is the standard way to run? What you suggest?
There was a problem hiding this comment.
This should work by using lind-wasm aka lind_run directly
|
@moogchi Following up our discussion from here, could you please for now, try running the tests with the file paths hardcoded in the wrapper scripts. I would suggest if you could run at least 3 utilities in each category below. Thanks! File Management: ls, cp, mv, rm, mkdir, rmdir, ln (links), touch |
Test coreutils WASM binaries in Lind sandbox
Closes #53 Fixes Lind-Project/lind-wasm#28
Update (3/2/26)
Added a test file
coreutils/run_coreutils_tests.shthat has fixed path issues etc that existed inmanual_coreutils_test.sh.TOTAL TESTS : 27
TOTAL UTILITIES TESTED : 26
SUCCESS : 25/27
Failures :
symlinkanddf**Todo: ** Check failures
Summary
Built a test harness that runs the GNU coreutils test suite with all 91 available binaries executing inside the Lind WASM sandbox via
lind-boot. The script uses.opt.wasmbinaries precompiled to.opt.cwasmvialind-boot --precompile, copied intolindfs/with bind mounts to expose host directories to the sandbox.Approach
Per-directory swap strategy:
The coreutils test suite expects utilities in
coreutils/src/and usesPATHto find them. The test harness itself (test-lib.sh, Makefiles) also calls utilities likerm,cat,chmodto set up temp directories and clean up. If those are routed through the sandbox, they fail.For each test directory (
rm/,chmod/,cp/, etc.):src/For
misc/tests (which cover many utilities), all non-harness utilities are wrapped.Manual Test Results (absolute paths)
Ran manual tests with hardcoded absolute paths to work around the cwd issue (Lind-Project/lind-wasm#742). Tested 27 cases across 23 compiled utilities.
PASS: 18 | FAIL: 9 | TOTAL: 27
Pass rate on compiled utilities: 18/23 (78%)
Passing
touch, ls, mkdir, rmdir, cp, mv, cat, head, tail, cut, paste, pwd, dd, echo, printf, tr, expand
Failure Classes
1. Build failures (wc, sort, uniq, unexpand)
These utilities did not compile to WASM during the coreutils build. No
.opt.wasmfiles exist for them. Not a sandbox issue.2. Syscall issues (rm, chmod, du)
cannot remove '': Is a directory— file path argument is getting lost or mangled, likely related to the cwd/chroot issue (Lind-boot: relative file paths fail due to cwd/chroot path mismatch lind-wasm#742)chmodsyscall may not be fully implemented in the sandboxValue too large for defined data type— likely astat64/large file support issue in the sandbox3. Missing system info (df)
cannot read table of mounted file systems— no/etc/mtabor/proc/mountsavailable inside lindfs4. Symlink not supported (ln -s)
Current Status
The full test suite (361 tests) runs but most file-based tests fail due to a cwd/chroot path mismatch in
lind-boot. The sandbox's working directory is always the lindfs root (/), so relative paths used by tests (e.g.touch f && chmod f) resolve against lindfs root instead of the test's temp directory. Bind mounts fix absolute paths but not relative ones.This is tracked in Lind-Project/lind-wasm#742.
Key Findings
.opt.wasmmust be precompiled to.opt.cwasmusinglind-boot --precompile(the old.cwasmfromwasmtime compileare ELF binaries and incompatible with the new lind-boot)lindfs/forlind-bootto access themmount --bind /home lindfs/home) allow the sandbox to access host files via absolute pathsFiles
run_coreutils_tests_lind.sh— Full test harness scriptmanual_coreutils_test.sh— Manual tests with absolute pathsHow to run