Skip to content

feat: POSIX conformance test suite and implementation fixes (99.4%)#46

Merged
NathanFlurry merged 1 commit intomainfrom
ralph/posix-conformance-tests
Mar 23, 2026
Merged

feat: POSIX conformance test suite and implementation fixes (99.4%)#46
NathanFlurry merged 1 commit intomainfrom
ralph/posix-conformance-tests

Conversation

@NathanFlurry
Copy link
Member

Summary

  • Integrates the os-test POSIX.1-2024 conformance suite into WasmVM
  • Builds all os-test programs to both wasm32-wasip1 and native x86_64
  • Adds a Vitest-based conformance test runner with native parity comparison
  • Fixes 23 implementation gaps across libc, kernel, VFS, and device layer
  • Achieves 99.4% conformance (3330/3350 tests passing)

What changed

Infrastructure (US-001 → US-011)

  • make fetch-os-test / make os-test / make os-test-native build targets
  • posix-exclusions.json schema with honest categorization (wasm-limitation / wasi-gap / implementation-gap)
  • posix-conformance.test.ts test runner with native parity detection
  • validate-posix-exclusions.ts validation script
  • generate-posix-report.ts MDX report generator
  • import-os-test.ts upstream update script
  • .github/workflows/posix-conformance.yml CI workflow

Kernel & runtime fixes (US-012 → US-034)

  • stdout duplication — removed redundant callback wiring in spawnManaged()
  • VFS directory enumerationfdOpen detects directories by stat; VFS populated from native build
  • VFS stat metadatafstatat parent-relative path lookup
  • fcntl F_GETFD/F_SETFD — sysroot override tracks per-fd cloexec state
  • realloc(ptr, 0) — sysroot patch enables REALLOC_ZERO_BYTES_FREES in dlmalloc
  • namespace tests — stub main() for compile-only header conformance checks
  • POSIX directory hierarchy — kernel creates /tmp, /usr, /etc, /var, etc. at startup
  • glob/globfree — fixed by VFS directory enumeration fix
  • strfmon/strfmon_l — sysroot override for POSIX locale
  • open_wmemstream — sysroot override tracks wchar_t count
  • swprintf — sysroot override sets errno=EOVERFLOW
  • inet_ntop — sysroot override for RFC 5952 IPv6 formatting
  • pthread_condattr_getclock — sysroot patch fixes C operator precedence bug
  • pthread_mutex_trylock/timedlock/settype — sysroot override fixes lock tracking
  • pthread_attr_getguardsize/mutexattr_setrobust — sysroot override stores values
  • pthread_key_delete — sysroot override fixes NULL thread-list dereference
  • /dev/ptmx, /dev/random, /dev/tty, /dev/console, /dev/full — added to device layer
  • long-double printf/scanf — linked -lc-printscan-long-double
  • dev-ptc/dev-ptm — native parity detection (Sortix-specific paths)

Integrity fixes (US-023 → US-025, US-028, US-033)

  • All 5 C override fixes moved from test-only to patched sysroot
  • ffsll source replacement reverted — properly excluded as wasm-limitation
  • 7 pthread exclusions recategorized from wasm-limitation to implementation-gap
  • Suite-specific VFS special-casing removed

Remaining exclusions (20 tests)

Category Count Notes
implementation-gap 17 stdio/wchar pipe I/O, poll/select pipe FDs, fmtmsg
wasi-gap 2 statvfs/fstatvfs (not in WASI spec)
wasm-limitation 1 ffsll (32-bit long truncates 64-bit constant)

Test plan

  • make -C native/wasmvm/c os-test os-test-native compiles all tests
  • pnpm vitest run packages/wasmvm/test/posix-conformance.test.ts passes
  • pnpm tsx scripts/validate-posix-exclusions.ts passes
  • No regressions in existing test suites
  • Typecheck passes

🤖 Generated with Claude Code

@mintlify
Copy link

mintlify bot commented Mar 23, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
rivetgaminginc-db8c797a 🟢 Ready View Preview Mar 23, 2026, 12:02 AM

Integrate the os-test POSIX.1-2024 conformance suite into WasmVM:

- Add os-test fetch, WASM + native build targets to Makefile
- Create posix-conformance.test.ts test runner with native parity checks
- Create posix-exclusions.json schema and validation tooling
- Add CI workflow, report generation, and docs integration
- Fix 47 implementation gaps in wasi-libc (pthread, fcntl, strfmon,
  fmtmsg, inet_ntop, open_wmemstream, swprintf, realloc, pipe polling)
- Move all libc fixes to patched sysroot (not test-only overrides)
- Move POSIX directory hierarchy from test runner to kernel
- Add pipe FD polling support, /dev/full ENOSPC, /dev/ptmx device
- Centralize exclusion schema as shared TypeScript module
- Harden import-os-test.ts with safe extraction

Result: 3347/3350 tests passing (99.9%), 3 genuine exclusions remaining
(ffsll wasm-limitation, statvfs/fstatvfs wasi-gap).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@NathanFlurry NathanFlurry force-pushed the ralph/posix-conformance-tests branch from 6b165d7 to b1d7866 Compare March 23, 2026 19:31
@NathanFlurry NathanFlurry merged commit ebec353 into main Mar 23, 2026
1 of 4 checks passed
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.

1 participant