Files
Martin Vogel 6d80cce23c test: stop hashing the test runner in the copied-image and install tests
The daemon_runtime copied-image probes and the CLI install/update tests
made full SHA-256 passes over the sanitized test runner (about 520 MB on
macOS arm64, about 790 MB on hosted x86) or over copies of it: about 10
passes per daemon_runtime run and 66 passes plus 31 staged, fsync'd
copies in the cli suite. On hosted x86 jobs that draw an Intel Xeon
runner one pass takes 70-95 s (1-3 s on AMD EPYC), so the copied-image
probes ran out of their 60 s budget and the cli suite ran past its
3600 s wall clock: the verdict depended on the CPU the job drew.

A small dedicated executable, the image probe, now takes the runner's
place in those tests. It links only the daemon runtime, the foundation
layer and mimalloc (about 2 MB) and carries the roles the tests need
(serve, the HELLO and activation clients, --version for installs); the
role code moved from tests/test_main.c. Makefile.cbm builds
<runner>-image-probe beside each runner flavour with that flavour's
flags as an order-only prerequisite of the runner, leaving out
workspace.c and slab_alloc.c, which serve the indexer. The copied-image
tests run the daemon from the probe and the clients from identical or
changed copies of it; the install tests stage and publish the probe
through the existing self-path seam. Production verification is
unchanged.

macOS arm64 ASan/UBSan: runner 518,227,624 bytes, probe 1,981,480 bytes;
daemon_runtime, daemon_bootstrap, daemon_frontend, cli,
activation_transaction and agent_clients: 575 passed, 1 skipped, 1
host-specific failure that also fails on main here; contracts pass.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-18 21:04:57 +01:00

57 lines
1.7 KiB
C

/*
* image_probe_main.c — entry point of the image probe (tests/test_image_probe.h),
* the small executable that copied-image and install tests run instead of the
* test runner. Its roles live in tests/image_probe_roles.c.
*/
#include "test_image_probe.h"
#include <stdio.h>
#include <string.h>
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
#define PROBE_MSAN_MIMALLOC_OUTPUT 1
#endif
#endif
#ifdef PROBE_MSAN_MIMALLOC_OUTPUT
#include <mimalloc.h>
#include <sanitizer/msan_interface.h>
/* MSan lane only, exactly as the runner's tf_msan_mi_output (tests/test_main.c):
* mimalloc is uninstrumented there, so text it formats on its own stack must
* be marked initialized before it reaches an MSan interceptor. */
static bool probe_msan_mi_output_live;
static void probe_msan_mi_output(const char *msg, void *arg) {
(void)arg;
if (!probe_msan_mi_output_live || !msg) {
return;
}
__msan_unpoison_string(msg);
if (!msg[0]) {
return;
}
(void)fputs(msg, stderr);
}
#endif
int main(int argc, char **argv) {
#ifdef PROBE_MSAN_MIMALLOC_OUTPUT
mi_register_output(probe_msan_mi_output, NULL);
probe_msan_mi_output_live = true;
#endif
/* An install verifies the candidate it staged by running it with
* --version (src/cli/cli.c); the probe stands in for that binary. */
if (argc == 2 && strcmp(argv[1], "--version") == 0) {
(void)puts("codebase-memory-mcp test image probe");
return 0;
}
int role_rc = tf_image_probe_dispatch(argc, argv);
if (role_rc >= 0) {
return role_rc;
}
(void)fprintf(stderr, "image probe: no role named by argv[1] (tests/test_image_probe.h)\n");
return 2;
}