You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Node CLI now understands the container: `-C <file>` emits a self-verifying
.pbf.json (filename + modified_ms + created_ms + mode from stat, plus crc32);
`-d -C <container>` restores the original bytes (self-verify; corrupt -> nonzero
exit). Reuses the JS lib's encodeToContainer/decodeText.
Adds test/test_container — a parameterized (IMPLEMENTATION_TO_TEST) CLI round-trip
+ non-vacuous self-verify oracle — wired into CI as test-container-node. The same
script will exercise the Zig/C/Lua CLIs as they gain -C.
src/zig/ffi.zig = C ABI (FFI) export surface: all 12 pb_* C functions; root of libprintable_binary.a; keeps C symbols OUT of the importable printable_binary module so static (musl) consumers don't collide
7
7
test/module_consumer.zig = Test fixture: minimal downstream importer of the printable_binary Zig module (mirrors how difz/blip consume it) for the FFI-symbol-leak test
test/test_module_no_ffi_symbols = Regression test (nm oracle): importing the module must emit 0 pb_* symbols while the FFI static lib keeps all 12 — guards the difz-blocking duplicate-symbol bug
if"$IMPL" -C "$TMP/orig.bin">"$TMP/orig.pbf.json"2>"$TMP/enc.err";then ok "encode -C exits 0";else bad "encode -C exits 0";echo"$(cat "$TMP/enc.err")";fi
23
+
24
+
# 3. container shape
25
+
grep -q '"format"'"$TMP/orig.pbf.json"2>/dev/null && grep -q 'printable-binary-file'"$TMP/orig.pbf.json"&& ok "container has format=printable-binary-file"|| bad "container has format=printable-binary-file"
26
+
grep -q '"filename"'"$TMP/orig.pbf.json"2>/dev/null && grep -q 'orig.bin'"$TMP/orig.pbf.json"&& ok "container carries filename"|| bad "container carries filename"
27
+
grep -q '"crc32"'"$TMP/orig.pbf.json"2>/dev/null && ok "container carries crc32"|| bad "container carries crc32"
28
+
29
+
# 4. decode -> original bytes
30
+
if"$IMPL" -d -C "$TMP/orig.pbf.json">"$TMP/restored.bin"2>"$TMP/dec.err";then ok "decode -d -C exits 0";else bad "decode -d -C exits 0";echo"$(cat "$TMP/dec.err")";fi
31
+
if cmp -s "$TMP/orig.bin""$TMP/restored.bin";then ok "round-trip bytes identical";else bad "round-trip bytes identical";fi
32
+
33
+
# 5. self-verify is non-vacuous: corrupt the data string -> decode MUST fail
34
+
sed 's/\("data": *"\)/\1ZZZ/'"$TMP/orig.pbf.json">"$TMP/corrupt.pbf.json"
35
+
if"$IMPL" -d -C "$TMP/corrupt.pbf.json"> /dev/null 2>&1;then bad "corrupt container rejected (nonzero exit)";else ok "corrupt container rejected (nonzero exit)";fi
36
+
37
+
echo"container CLI test [$IMPL]: $pass passed, $fail failed"
0 commit comments