Skip to content

NJS test262 runner - #1125

Open
xeioex wants to merge 8 commits into
nginx:masterfrom
xeioex:njs-test262-runner
Open

NJS test262 runner#1125
xeioex wants to merge 8 commits into
nginx:masterfrom
xeioex:njs-test262-runner

Conversation

@xeioex

@xeioex xeioex commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Adds build/njs_test262, a native runner for the official TC39 test262 suite. Unlike the existing make test262 shell harness, it embeds njs directly and executes the upstream suite without spawning one CLI process per test.

The runner:

  • parses test262 frontmatter and assembles harness sources;
  • supports strict scripts, modules, async tests, negative tests, feature filtering, exclusions, and targeted paths;
  • reports PASS, FAIL, SKIP, CRASH, and INFRA results;
  • supports process isolation and a per-variant CPU limit;
  • compares failures against a sorted path/variant baseline, reporting NEW, FIXED, and STALE entries;
  • refuses baseline updates after crashes or infrastructure errors.

The official suite is pinned in test/njs_test262.version; the configured profile and expected failures are stored in test/njs_test262.conf and test/njs_test262.failures.

A dedicated test262 GitHub Actions workflow runs the full profile in normal, ASan, and UBSan builds.

The lambda structure is allocated at the end of module compilation,
and if the allocation fails, lambda is NULL.  Since nothing fails after
a successful allocation, lambda is always NULL on the failed path.

Found by Coverity (CID 1701143).
Previously, a double was converted to uint32_t before its range was tested,
so a property key that is NaN, negative or larger than 2^31 made the
conversion undefined.  UndefinedBehaviorSanitizer reported it for every VM
creation, where an environment variable name is atomized.

The fix is to test the range first and to share one njs_number_is_atom_index()
helper between the four places that repeated the pattern.
The Date setters always converted their result as local time.  Use the
setter's UTC flag instead.

Remove the intermediate range check in njs_make_date().  TimeClip already
checks the result after local-to-UTC conversion, which can move a value
across the valid time range boundary.
@xeioex
xeioex force-pushed the njs-test262-runner branch 2 times, most recently from 352d4f1 to 48daaeb Compare September 12, 2026 03:43
@xeioex
xeioex marked this pull request as ready for review September 12, 2026 03:44
@xeioex xeioex changed the title Njs test262 runner NJS test262 runner Sep 12, 2026
The timezone offset helper converted a double to int64_t before checking
whether it was representable.  Check the range first.

UndefinedBehaviorSanitizer reports the out-of-range conversion.
Use adapters for memory pool allocators instead of casting their function
pointers to the generic chain buffer callback types.

Casting does not make an indirect call through an incompatible function
pointer type valid.  UndefinedBehaviorSanitizer reports these calls.
@xeioex
xeioex force-pushed the njs-test262-runner branch 3 times, most recently from 6aed19c to 6a705dd Compare September 12, 2026 05:47
Opaque values are cast to njs_value_t pointers by the public API.  Match
njs_value_t alignment while retaining the four uint32_t filler fields.

UndefinedBehaviorSanitizer reports unaligned njs_value_t accesses.
Build and run the base njs test suite with UndefinedBehaviorSanitizer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant