diff --git a/tests/test_hook_conflict_notice.sh b/tests/test_hook_conflict_notice.sh index 958f08c5f..a16c7dfee 100644 --- a/tests/test_hook_conflict_notice.sh +++ b/tests/test_hook_conflict_notice.sh @@ -16,6 +16,17 @@ if [[ ! -x "${BINARY}" ]]; then exit 2 fi +# PRECONDITION, not a skip (same doctrine as tests/test_worker_watchdog.sh): this +# test drives the hook-client build seam, which is compiled out of ordinary +# builds. Against a seam-less binary no conflict can ever occur and the failure +# would read as "the notice is missing" instead of "the capability is absent". +if ! LC_ALL=C grep -a -q -F 'CBM_TEST_HOOK_CLIENT_BUILD' "${BINARY}"; then + echo "binary lacks the hook-client build seam: ${BINARY}" >&2 + echo " rebuild it with: make -f Makefile.cbm cbm TEST_SEAMS=1" >&2 + echo " or run this test through scripts/test.sh, which does that for you." >&2 + exit 2 +fi + tmpdir="$(mktemp -d)" cleanup() { CBM_CACHE_DIR="${tmpdir}/cache" "${BINARY}" daemon stop >/dev/null 2>&1 || true @@ -29,7 +40,11 @@ if ! CBM_CACHE_DIR="${tmpdir}/cache" "${BINARY}" daemon start >"${tmpdir}/daemon exit 2 fi payload='{"session_id":"probe","hook_event_name":"PreToolUse","tool_name":"Grep","tool_input":{"pattern":"x","path":"/tmp"},"cwd":"/tmp"}' -forced_build="$(printf 'f%.0s' $(seq 1 64))" +forced_build="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" +if [[ ${#forced_build} -ne 64 ]]; then + echo "internal: forced fingerprint must be 64 hex chars, got ${#forced_build}" >&2 + exit 2 +fi # The daemon's cohort join completes asynchronously after `daemon start` # returns. Wait for the STATE the assertion needs - a probe that observes the @@ -62,8 +77,14 @@ if ! grep -q "conflicting CBM process" "${tmpdir}/probe.err"; then echo "never became active, or this is not a TEST_SEAMS=1 binary" >&2 echo "--- daemon-start.log ---" >&2 cat "${tmpdir}/daemon-start.log" >&2 - echo "--- last probe stderr ---" >&2 + echo "--- last probe stderr (empty means no conflict was raised) ---" >&2 cat "${tmpdir}/probe.err" >&2 + echo "--- last probe stdout ---" >&2 + printf '%s\n' "${out}" >&2 + echo "--- diagnosis ---" >&2 + echo "forced_build=${forced_build} (len ${#forced_build})" >&2 + echo "seam present in binary: yes (asserted above)" >&2 + CBM_CACHE_DIR="${tmpdir}/cache" "${BINARY}" daemon status >&2 2>&1 || true exit 2 fi if ! printf '%s' "${out}" | grep -q "systemMessage"; then