Skip to content

Add coreutils test runner via lind_run (Fixes #53)#55

Open
moogchi wants to merge 10 commits intomainfrom
run-coreutils-tests-with-lind
Open

Add coreutils test runner via lind_run (Fixes #53)#55
moogchi wants to merge 10 commits intomainfrom
run-coreutils-tests-with-lind

Conversation

@moogchi
Copy link

@moogchi moogchi commented Feb 11, 2026

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.sh that has fixed path issues etc that existed in manual_coreutils_test.sh.
TOTAL TESTS : 27
TOTAL UTILITIES TESTED : 26
SUCCESS : 25/27
Failures : symlink and df

**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.wasm binaries precompiled to .opt.cwasm via lind-boot --precompile, copied into lindfs/ 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 uses PATH to find them. The test harness itself (test-lib.sh, Makefiles) also calls utilities like rm, cat, chmod to set up temp directories and clean up. If those are routed through the sandbox, they fail.

For each test directory (rm/, chmod/, cp/, etc.):

  1. Start with all utilities as native symlinks in src/
  2. Swap only the utility being tested to a Lind wrapper
  3. Run that directory's tests
  4. Swap it back to native

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.wasm files exist for them. Not a sandbox issue.

2. Syscall issues (rm, chmod, du)

  • rm: 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)
  • chmod: runs without error but does not actually change file permissions (stays 644) — the chmod syscall may not be fully implemented in the sandbox
  • du: Value too large for defined data type — likely a stat64/large file support issue in the sandbox

3. Missing system info (df)

  • df: cannot read table of mounted file systems — no /etc/mtab or /proc/mounts available inside lindfs

4. Symlink not supported (ln -s)

  • ln -s: symlink creation silently fails, no error output

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.wasm must be precompiled to .opt.cwasm using lind-boot --precompile (the old .cwasm from wasmtime compile are ELF binaries and incompatible with the new lind-boot)
  • Binaries must be copied into lindfs/ for lind-boot to access them
  • Bind mounts (mount --bind /home lindfs/home) allow the sandbox to access host files via absolute paths
  • 4 utilities (wc, sort, uniq, unexpand) failed to compile to WASM
  • Relative path resolution is blocked on Lind-boot: relative file paths fail due to cwd/chroot path mismatch lind-wasm#742

Files

  • run_coreutils_tests_lind.sh — Full test harness script
  • manual_coreutils_test.sh — Manual tests with absolute paths

How to run

# From lind-wasm-apps directory (with lind-wasm built):
make coreutils
./run_coreutils_tests_lind.sh          # Full suite (blocked on #742)
./manual_coreutils_test.sh             # Manual tests with absolute paths

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
@moogchi moogchi force-pushed the run-coreutils-tests-with-lind branch from 5c8262e to 64d54d8 Compare February 11, 2026 02:24
@moogchi moogchi changed the title feat: Add coreutils test runner via lind_run (Fixes #53) Add coreutils test runner via lind_run (Fixes #53) Feb 11, 2026
@vidyalakshmir
Copy link
Contributor

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.

@moogchi
Copy link
Author

moogchi commented Feb 11, 2026

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).
You're right that we should be testing all coreutils binaries through Lind. Currently, utilities like rm, chmod, and ls are excluded from Lind wrapping entirely. I focused on getting the split approach working with the simpler utilities first and didn't get to wrapping the ones that the harness also depends on. I'll work on making the wrappers context-aware so those utilities use native binaries during setup/cleanup but route through lind_run when they're the actual test target.

@vidyalakshmir
Copy link
Contributor

Sounds good, thanks!

@vidyalakshmir
Copy link
Contributor

vidyalakshmir commented Feb 13, 2026

@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'
and 'su' fails? If so, do we need to build it with the latest static glibc build branch?

/home/lind/lind-wasm/clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-18.04/bin/clang --target=wasm32-unknown-wasi --sysroot=/home/lind/lind-wasm-apps/build/sysroot_merged -pthread   -O2 -g -std=gnu99 -pthread -DHAVE_STRSIGNAL=1 -DHAVE_MKTIME=1 -DSLOW_BUT_NO_HACKS=1 -I/home/lind/lind-wasm-apps/build/sysroot_merged/include -I/home/lind/lind-wasm-apps/build/sysroot_merged/include/wasm32-wasi  -Wl,--import-memory,--export-memory,--max-memory=67108864,--export=__stack_pointer,--export=__stack_low -L/home/lind/lind-wasm-apps/build/sysroot_merged/lib/wasm32-wasi -L/home/lind/lind-wasm-apps/build/sysroot_merged/usr/lib/wasm32-wasi -o su su.o libver.a ../lib/libcoreutils.a  ../lib/libcoreutils.a  
/home/lind/lind-wasm/clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-18.04/bin/clang --target=wasm32-unknown-wasi --sysroot=/home/lind/lind-wasm-apps/build/sysroot_merged -pthread   -O2 -g -std=gnu99 -pthread -DHAVE_STRSIGNAL=1 -DHAVE_MKTIME=1 -DSLOW_BUT_NO_HACKS=1 -I/home/lind/lind-wasm-apps/build/sysroot_merged/include -I/home/lind/lind-wasm-apps/build/sysroot_merged/include/wasm32-wasi  -Wl,--import-memory,--export-memory,--max-memory=67108864,--export=__stack_pointer,--export=__stack_low -L/home/lind/lind-wasm-apps/build/sysroot_merged/lib/wasm32-wasi -L/home/lind/lind-wasm-apps/build/sysroot_merged/usr/lib/wasm32-wasi -o sort sort.o libver.a ../lib/libcoreutils.a  ../lib/libcoreutils.a    
wasm-ld: error: su.o: undefined symbol: crypt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [Makefile:2211: su] Error 1
make[4]: *** Waiting for unfinished jobs....
wasm-ld: error: /home/lind/lind-wasm-apps/build/sysroot_merged/lib/wasm32-wasi/libc.a(e_pow.o): undefined symbol: fmod
wasm-ld: error: /home/lind/lind-wasm-apps/build/sysroot_merged/lib/wasm32-wasi/libc.a(e_pow.o): undefined symbol: fmod
wasm-ld: error: /home/lind/lind-wasm-apps/build/sysroot_merged/lib/wasm32-wasi/libc.a(e_pow.o): undefined symbol: fmod
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [Makefile:2196: sort] Error 1

@rennergade
Copy link
Contributor

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

@rennergade
Copy link
Contributor

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" "\$@"
Copy link
Contributor

@vidyalakshmir vidyalakshmir Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
@rennergade What is the standard way to run? What you suggest?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work by using lind-wasm aka lind_run directly

@vidyalakshmir
Copy link
Contributor

vidyalakshmir commented Feb 17, 2026

@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
Text Processing: cat, echo, head (first lines), tail (last lines), wc (word count), sort, uniq (unique lines), cut (cut sections), paste, split.
System/File Permissions & Information: chmod, chown, chgrp, df (disk free), du (disk usage), pwd (print working directory), sync, dd (convert/copy).
Text Manipulation: echo, printf, tr (translate/delete characters), expand (tabs to spaces), unexpand (spaces to tabs).
Process/User Management (Often associated): kill, ps (though often part of procps-ng rather than coreutils, they are part of the daily toolset).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test Coreutils binaries Fix coreutils

3 participants