Skip to content

Commit 44fce29

Browse files
committed
test(ci): dogfood the C FFI CLI in CI (test-ffi-cli)
Builds src/printable_binary_ffi_main.c against the Zig static lib and round-trips 4 KiB of random data through encode/decode and through -X hexlike — exercising the C ABI boundary (incl. the new pb_hexlike_* exports) end to end. The FFI CLI was previously built only via the Makefile and never tested in CI.
1 parent 06a8901 commit 44fce29

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

flake.nix

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,26 @@
309309
installPhase = "mkdir -p $out && touch $out/passed";
310310
};
311311

312+
# Dogfood the C FFI boundary: build the C FFI CLI against the Zig static
313+
# lib and round-trip through it (encode/decode + hexlike).
314+
test-ffi-cli = pkgs.stdenv.mkDerivation {
315+
name = "test-ffi-cli";
316+
src = ./.;
317+
nativeBuildInputs = with pkgs; [ zig clang ];
318+
buildPhase = ''
319+
export HOME=$TMPDIR
320+
zig build
321+
clang -O2 -I. -o pb-ffi src/printable_binary_ffi_main.c zig-out/lib/libprintable_binary.a
322+
head -c 4096 /dev/urandom > in.bin
323+
./pb-ffi in.bin | ./pb-ffi -d > out.bin
324+
cmp in.bin out.bin || { echo "FFI CLI encode/decode roundtrip failed" >&2; exit 1; }
325+
./pb-ffi -X in.bin | ./pb-ffi -X -d > outx.bin
326+
cmp in.bin outx.bin || { echo "FFI CLI hexlike roundtrip failed" >&2; exit 1; }
327+
echo "FFI CLI smoke test passed (encode/decode + hexlike through the C ABI)"
328+
'';
329+
installPhase = "mkdir -p $out && touch $out/passed";
330+
};
331+
312332
# Guard against a stale generated C header: regenerating from
313333
# character_map.txt must reproduce the committed character_map_embedded.h.
314334
test-embedded-map-sync = pkgs.stdenv.mkDerivation {

0 commit comments

Comments
 (0)