Skip to content

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

Open
NathanFlurry wants to merge 38 commits intomainfrom
ralph/posix-conformance-tests
Open

feat: POSIX conformance test suite and implementation fixes (99.4%)#46
NathanFlurry wants to merge 38 commits 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

NathanFlurry and others added 30 commits March 21, 2026 16:13
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…file

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…and wasm-limitation tests

- Populate posix-exclusions.json with 178 skip exclusions across categories:
  compile-error (namespace/*, posix-parse/*, basic/ and include/ subsuites
  without WASI sysroot support), wasm-limitation (io/*, process/*, signal/*,
  pthread runtime failures, mmap, spawn), wasi-gap (pty/*, udp/*, paths/*,
  sys_statvfs, shared memory, sockets, termios), timeout (pthread_key_delete)
- Switch test runner from kernel.exec() to kernel.spawn() to bypass sh -c
  wrapper and get real WASM binary exit codes (shell returned exit 17 for
  all child commands due to benign "could not retrieve pid" issue)
- Add crossterm-0.28.1 WASI patch (ratatui/reedline dependency) to fix
  WASM runtime build — adds WASI stubs for terminal, cursor, event, and
  TTY modules matching the existing crossterm 0.29.0 patch
- 35 remaining failures are implementation-gap tests for US-006

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Classify all 35 remaining os-test failures into 10 GitHub issues:
- #31: stdout duplication in WASM binaries (8 tests)
- #32: realloc(ptr,0) semantics (1 test)
- #33: VFS directory enumeration + nftw (6 tests)
- #34: VFS stat metadata (4 tests)
- #35: file descriptor operations (5 tests)
- #36: glob pattern matching (2 tests)
- #37: locale/monetary formatting (2 tests)
- #38: long double precision (3 tests)
- #39: wide character streams (2 tests)
- #40: missing libc functions ffsll/inet_ntop (2 tests)

Also fix fail-exclusion check to consider both exit code AND
native output parity (not just exit code), so tests that exit 0
but produce wrong stdout are correctly detected as still failing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…fix dev-ptc/dev-ptm exclusions

US-033: Verified no suite-specific special-casing remains (already removed in US-024).

US-034: Added native parity detection for tests where both WASM and native
fail identically. /dev/ptc and /dev/ptm are Sortix-specific paths that don't
exist on real Linux either — both WASM and native produce identical ENOENT
output. Removed both exclusions, conformance now 3330/3350 (99.4%).
@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

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