Skip to content
UNDER THE HOOD

Tests and gates

  • Unit tests (unittests/, GoogleTest). LibrarySpecTest.cpp (WeaveCCoreTests) checks every library entry against an independent, hand-written expectation table. GuardPassTest.cpp (WeaveCFrontendTests) runs the guard passes on IR text, each removal rule alone, and checks the IR and the ledger rows they leave.
  • The runtime test (runtime/test/rt_test.c, CTest runtime) is one C program linked with libweavec_rt.a and libweavec_alloc.a, so its malloc is the arena’s. It tests the shadow and its encoding, the size classes, alignment, reallocation, the sweep (recycling, retention, following the heap, stopping threads, pacing, the C library’s data through the image table), invalid releases (in child processes that must die), huge blocks, foreign pointers, the guards, strings, the checked calls, globals, dynamic allocas and the stack’s unpoisoning, ASan’s interface, the number parsers and limits, mappings, the array-bounds handlers, threads and fork. Test names as arguments run only those.
  • Lit tests (test/Guards, test/Driver) pin exact output and behaviour. test/Guards pins the passes’ IR (FileCheck on -emit-llvm: ir-*.c, among them ir-frames.c, and shared-frame.c) and, by building and running programs, the run-time behaviour, each report line, and the enforcement ledger; test/Driver pins the runtime’s link line and fallbacks (runtime-*.c), fortification (fortify.c), ASan’s macros (asan-compat*.c) and the globals of a dylib and a bundle (image-globals.c).
  • test/cases is one tree of executable C cases by feature, with expectations as line-comment markers (see its README). scripts/run-cases.py builds each case with weavec-cc (GUARDED, PROVEN, UNGUARDED and EXPECT-LEDGER on the enforcement ledger) and runs it, attributing every stop to a line and a kind (TRAP: <kind>, TRAP-AT: <unit>:<line>, and STOP in a DETECT case). test/cases/determinism holds a bug per class RFC 0036 makes deterministic, each with its correct twin (gate G1), and, as XFAIL, the bugs it leaves to a later RFC. --asan adds an oracle built with -fsanitize=address,array-bounds; --checks verify fails any weavec.proven report. CTest registers one cases-<suite> test per top-level directory, so ctest -j runs the suites in parallel.
  • test/corpus pins real projects, built and tested with weavec-cc by scripts/corpus-gate.py (--quick on every pull request); see its README.

RFC 0036’s acceptance gates (detection G1–G3, drop-in G4–G5, cost G6–G9, hygiene H1–H2) are measured with these tools. scripts/check-hygiene.py implements gate H1: no libc name comparisons outside the library table, no corpus project named under lib/, Core free of Clang and LLVM, the runtime’s includes, its entry points declared in weavec_rt.h, and the line budgets of the library (9,000) and of the runtime (6,000). scripts/codegen-identity.py checks that objects built with -fweavec-checks=none are byte-identical to Clang’s.