Skip to content
pi-c Artifact [c260a8ace1]
Login

Artifact [c260a8ace1]

Artifact c260a8ace1ee530833a7d88b955ee83e1fde24520a3b678844f2f738190bed98:


# pic harness plus S0/S1 qualification gates.
CC ?= cc
PYTHON ?= python3
export CC

.PHONY: all check metadata test test-reporting replay dst sanitize coverage-mcdc \
        fuzz-smoke bench filc-remote qualify help assertion-guard local-evidence test-context test-context-sanitize test-remote \
        pic pic-dev test-pic

all: check

check: test-pic metadata test-reporting replay coverage-mcdc assertion-guard test-remote
	@printf '%s\n' 'PASS: pic crash/recovery suite and local qualification gates.'

metadata:
	$(PYTHON) -I -B test/test_contracts.py
	$(PYTHON) -I -B tools/check_contracts.py

test-reporting:
	$(PYTHON) -I -B test/test_toolchain.py

test:
	sh tools/test-native.sh normal

# The normal suite includes the fixed 100-seed deterministic replay campaign.
dst: test

replay: test
	sh tools/test-native.sh replay

sanitize:
	sh tools/test-native.sh sanitize

coverage-mcdc:
	sh tools/mcdc.sh

assertion-guard:
	sh tools/test-assertions.sh

fuzz-smoke:
	sh tools/test-native.sh fuzz

bench:
	sh tools/benchmark.sh

test-context:
	sh test/context/test-driver.sh normal

test-context-sanitize:
	sh test/context/test-driver.sh sanitize

test-remote:
	sh test/test_remote_lifecycle.sh
	$(PYTHON) -I -B test/remote/test_collect.py

# Run actual local gates before snapshotting metadata; never reuse a stale PASS.
local-evidence:
	mkdir -p build/qualification
	rm -f build/qualification/local-evidence.json
	$(MAKE) check sanitize fuzz-smoke bench > build/qualification/local-checks.log 2>&1
	$(PYTHON) -I -B tools/evidence.py --log build/qualification/local-checks.log
	$(PYTHON) -I -B tools/check_contracts.py --evidence build/qualification/local-evidence.json

# Remote evidence gate; actual host operations remain explicit.
filc-remote:
	@test -n "$(REMOTE_RUN)" || { printf '%s\n' 'GATED: supply REMOTE_RUN=/absolute/completed/filc-run; see docs/remote-lifecycle.md'; exit 2; }
	sh tools/remote/run.sh reconcile "$(REMOTE_RUN)" > "$(REMOTE_RUN)/operator-reconcile.log"
	$(PYTHON) -I -B tools/remote/report.py "$(REMOTE_RUN)"
	$(PYTHON) -I -B tools/check_contracts.py --evidence "$(REMOTE_RUN)/qualification.json"

qualify: check sanitize fuzz-smoke bench
	@printf '%s\n' 'GATED: local fixture evidence is not release qualification.' \
	 'Production runtime/release contracts remain unqualified; remote fixture evidence is a separate explicit gate.'
	@exit 2

help:
	@printf '%s\n' 'S0 only: check, metadata, test, dst, replay, sanitize, coverage-mcdc,' \
	 'fuzz-smoke, bench, test-context, test-context-sanitize, test-remote.' \
	 'filc-remote verifies an explicit REMOTE_RUN; full production qualify remains GATED.'

# ---- pic: the harness ------------------------------------------------------
# Release has no test code and no fault hooks; dev adds ASan/UBSan and crash points.
PIC_SRC := src/store.c src/loop.c src/provider_fake.c src/tools.c src/main.c
PIC_HDR := src/pic.h
PIC_VENDOR := vendor/libfossil
PIC_SQLITE := -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_THREADSAFE=1
PIC_WARN := -std=c11 -Wall -Wextra -Wpedantic -Werror -Wshadow -Wconversion \
	-Wstrict-prototypes -Wmissing-prototypes -Wvla -Wcast-qual -D_DEFAULT_SOURCE -D_DARWIN_C_SOURCE
PIC_INC := -Isrc -isystem $(PIC_VENDOR) -DHAVE_LIBFOSSIL_CONFIG_H
PIC_SAN := -O1 -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=all
ifeq ($(shell uname -s),Darwin)
PIC_LIBS := -lz -lm -lpthread -liconv
else
PIC_LIBS := -lz -lm -lpthread -ldl
endif

build/pic/release/vendor/%.o: $(PIC_VENDOR)/%.c
	@mkdir -p $(@D)
	$(CC) -O2 $(PIC_SQLITE) -DHAVE_LIBFOSSIL_CONFIG_H -w -I$(PIC_VENDOR) -c -o $@ $<

build/pic/dev/vendor/%.o: $(PIC_VENDOR)/%.c
	@mkdir -p $(@D)
	$(CC) $(PIC_SAN) $(PIC_SQLITE) -DHAVE_LIBFOSSIL_CONFIG_H -w -I$(PIC_VENDOR) -c -o $@ $<

PIC_REL_V := build/pic/release/vendor/sqlite3.o build/pic/release/vendor/libfossil.o
PIC_DEV_V := build/pic/dev/vendor/sqlite3.o build/pic/dev/vendor/libfossil.o

build/pic/release/pic: $(PIC_SRC) $(PIC_HDR) $(PIC_REL_V)
	@mkdir -p $(@D)
	$(CC) $(PIC_WARN) -O2 $(PIC_INC) -o $@ $(PIC_SRC) $(PIC_REL_V) $(PIC_LIBS)

build/pic/dev/pic: $(PIC_SRC) $(PIC_HDR) $(PIC_DEV_V)
	@mkdir -p $(@D)
	$(CC) $(PIC_WARN) $(PIC_SAN) -DPIC_FAULTS $(PIC_INC) -o $@ $(PIC_SRC) $(PIC_DEV_V) $(PIC_LIBS)

pic: build/pic/release/pic
pic-dev: build/pic/dev/pic

test-pic: build/pic/dev/pic build/pic/release/pic
	ASAN_OPTIONS=detect_leaks=0 PIC=$(CURDIR)/build/pic/dev/pic sh test/pic/crash.sh
	PIC=$(CURDIR)/build/pic/release/pic sh test/pic/crash.sh --no-faults