From 58d367c2cbc49f4d3266769da629f7287d46adb4 Mon Sep 17 00:00:00 2001 From: Guillaume Demay Date: Sun, 6 Dec 2026 20:11:22 +0100 Subject: [PATCH] perf(tests): split long-tail suites, reuse image probe, and stub self-image hashes Split out from #3210 per maintainer review (Piece 4: suite splits and hash stubs). - Split 10 long-tail test suites into 14 additional suites (complexity_b, test_impact_git_b/c, mcp_supervisor, pipeline_c/d, pipeline_semantic_manifest_repro_b, c_lsp_b, java_type_scope_b, doc_mentions_b/d/e, cli_b, grammar_probe_f_b) so heavy tests run concurrently across parallel workers and shards. Exact RUN_TEST multiset match verified across all 3,001 entries in 13 files. - Separate the 22 fork/worker/deadline tests of SUITE(mcp) into SUITE(mcp_supervisor) so the 420+ in-process MCP tests run in the parallel wave while supervisor tests stay in the serial tail. - Reuse the ~2 MB test-runner-image-probe binary instead of copying/hashing the 500-800 MB sanitized test-runner in macOS cli update tests, daemon_runtime blocking-git probe, and test_impact_git diff-driver probes. - Arm the existing runtime fingerprint hash stub for same-binary lifecycle tests in daemon_bootstrap, daemon_frontend, cli_scope, and daemon_runtime Phase 1 while keeping full real SHA-256 verification in the dedicated cache-reset tests at the end of daemon_runtime. - Cache immutable SHA-1/SHA-256 template repos in test_impact_git and add a 10 s TSParseOptions progress_callback cap on Windows so_parse_crashes matching POSIX alarm(10). - Update TEST_TSAN_SUITES (pipeline_d, mcp_supervisor), scripts/msan.sh (MSAN_EXCLUDE cli cli_b), and scripts/run-tests-parallel.sh (SERIAL_SUITES and heavy shard list) for full parity. Signed-off-by: Guillaume Demay --- Makefile.cbm | 4 +- scripts/msan.sh | 2 +- scripts/run-tests-parallel.sh | 11 ++- tests/image_probe_main.c | 114 ++++++++++++++++++++++++++++ tests/image_probe_roles.c | 18 +++++ tests/test_c_lsp.c | 6 ++ tests/test_cli.c | 90 +++++++++++++++------- tests/test_complexity.c | 5 ++ tests/test_daemon_bootstrap.c | 11 +++ tests/test_daemon_frontend.c | 12 +++ tests/test_daemon_runtime.c | 95 ++++++++++++----------- tests/test_doc_mentions.c | 17 +++++ tests/test_grammar_probe_f.c | 5 ++ tests/test_image_probe.h | 5 +- tests/test_java_type_scope.c | 5 ++ tests/test_main.c | 28 +++++++ tests/test_mcp.c | 56 +++++++------- tests/test_pipeline.c | 16 ++++ tests/test_stack_overflow.c | 48 +++++++++++- tests/test_test_impact_git.c | 138 ++++++++++++++++++++++++++++++---- 20 files changed, 558 insertions(+), 128 deletions(-) diff --git a/Makefile.cbm b/Makefile.cbm index 6fcc6aef7d..54ddb083d5 100644 --- a/Makefile.cbm +++ b/Makefile.cbm @@ -1317,8 +1317,8 @@ test-repro: $(BUILD_DIR)/test-repro-runner # written by the configuring thread, read AND CALLED by connection # workers), now fixed with atomics in log.c. Excluding the suite is what # had hidden it. -TEST_TSAN_SUITES ?= mem slab_alloc parallel worker_pool watcher httpd pipeline \ - diagnostics mcp mcp_mutation_guard subprocess daemon daemon_application \ +TEST_TSAN_SUITES ?= mem slab_alloc parallel worker_pool watcher httpd pipeline pipeline_d \ + diagnostics mcp mcp_supervisor mcp_mutation_guard subprocess daemon daemon_application \ daemon_runtime daemon_ipc daemon_frontend # halt_on_error: a race is a bug, stop at the first one. # diff --git a/scripts/msan.sh b/scripts/msan.sh index 20bb8fafe7..182f88faa2 100755 --- a/scripts/msan.sh +++ b/scripts/msan.sh @@ -150,7 +150,7 @@ echo "=== MSan lane: $(clang --version | head -1) ===" # LESSON FROM (A): an MSan abort that is not a use-of-uninitialized-value # report is a reporting failure until proven otherwise. Look for the read # first (fast unwinding prints it), not for a stack limit. -MSAN_EXCLUDE="${MSAN_EXCLUDE-cli}" +MSAN_EXCLUDE="${MSAN_EXCLUDE-cli cli_b}" if [ "$#" -gt 0 ]; then ./build/msan/test-runner "$@" diff --git a/scripts/run-tests-parallel.sh b/scripts/run-tests-parallel.sh index b52c514122..82575637ad 100644 --- a/scripts/run-tests-parallel.sh +++ b/scripts/run-tests-parallel.sh @@ -215,9 +215,14 @@ fi shard_filter() { awk -v idx="$SHARD_INDEX" -v total="$SHARD_TOTAL" ' BEGIN { - nh = split("store_arch daemon_runtime incremental cli extraction " \ + nh = split("store_arch daemon_runtime incremental cli cli_b extraction " \ "watcher daemon_ipc subprocess httpd py_lsp_stress " \ - "grammar_regression mcp daemon_frontend pipeline pipeline_b", h, " ") + "grammar_regression mcp mcp_supervisor daemon_frontend " \ + "pipeline pipeline_b pipeline_c pipeline_d " \ + "c_lsp c_lsp_b doc_mentions doc_mentions_b doc_mentions_d doc_mentions_e " \ + "test_impact_git test_impact_git_b test_impact_git_c " \ + "complexity complexity_b grammar_probe_f grammar_probe_f_b " \ + "java_type_scope java_type_scope_b pipeline_semantic_manifest_repro_b", h, " ") } { present[$0] = NR; lines[NR] = $0 } END { @@ -261,7 +266,7 @@ shard_filter() { # that 40 sits >=2x from both the linear and quadratic signals, so inflating it # would move the test toward the very thing it exists to catch. Quiet is the # fix, and at ~22s the suite is cheap to run alone. -SERIAL_SUITES="cli subprocess watcher incremental httpd ui index_resilience mcp \ +SERIAL_SUITES="cli cli_b subprocess watcher incremental httpd ui index_resilience mcp_supervisor \ extraction \ stack_overflow_a stack_overflow_b stack_overflow_c \ index_supervisor daemon_application daemon_runtime daemon_frontend \ diff --git a/tests/image_probe_main.c b/tests/image_probe_main.c index 636e789fd4..5382199baf 100644 --- a/tests/image_probe_main.c +++ b/tests/image_probe_main.c @@ -4,10 +4,120 @@ * test runner. Its roles live in tests/image_probe_roles.c. */ #include "test_image_probe.h" +#include "foundation/compat.h" +#include "foundation/compat_fs.h" +#include "foundation/platform.h" +#include #include +#include #include +#ifdef _WIN32 +#include +#else +#include +#include +#endif + +#define PROBE_BLOCKING_GIT_MARKER_ENV "CBM_TEST_RUNTIME_BLOCKING_GIT_PID_FILE" + +#ifdef _WIN32 +static bool probe_invoked_as_windows_git_module(void) { + wchar_t image[32768]; + DWORD image_length = GetModuleFileNameW(NULL, image, (DWORD)(sizeof(image) / sizeof(image[0]))); + if (image_length == 0 || image_length >= (DWORD)(sizeof(image) / sizeof(image[0]))) { + return false; + } + const wchar_t *base = image; + for (const wchar_t *cursor = image; *cursor; cursor++) { + if (*cursor == L'/' || *cursor == L'\\') { + base = cursor + 1; + } + } + return CompareStringOrdinal(base, -1, L"git.exe", -1, TRUE) == CSTR_EQUAL; +} + +static BOOL WINAPI probe_blocking_git_control_handler(DWORD event) { + return event == CTRL_C_EVENT || event == CTRL_BREAK_EVENT; +} +#endif + +static bool probe_invoked_as_blocking_git(const char *argv0) { + if (!getenv(PROBE_BLOCKING_GIT_MARKER_ENV)) { + return false; + } +#ifdef _WIN32 + (void)argv0; + return probe_invoked_as_windows_git_module(); +#else + if (!argv0 || !argv0[0]) { + return false; + } + const char *base = argv0; + for (const char *cursor = argv0; *cursor; cursor++) { + if (*cursor == '/' || *cursor == '\\') { + base = cursor + 1; + } + } + return strcmp(base, "git") == 0 || strcmp(base, "git.exe") == 0 || strcmp(base, "GIT.EXE") == 0; +#endif +} + +static int probe_maybe_run_blocking_git(int argc, char **argv) { + (void)argc; +#ifdef _WIN32 + bool windows_git_module = probe_invoked_as_windows_git_module(); + if (windows_git_module && !getenv(PROBE_BLOCKING_GIT_MARKER_ENV)) { + (void)puts("TF_BLOCKING_GIT_DIAGNOSTIC marker_environment_missing"); + (void)fflush(stdout); + return 32; + } +#endif + if (!argv || !probe_invoked_as_blocking_git(argv[0])) { + return -1; + } + const char *marker_path = getenv(PROBE_BLOCKING_GIT_MARKER_ENV); + errno = 0; +#ifdef _WIN32 + SetLastError(ERROR_SUCCESS); +#endif + FILE *marker = cbm_fopen(marker_path, "wbx"); + if (!marker) { +#ifdef _WIN32 + int marker_errno = errno; + DWORD marker_error = GetLastError(); + bool marker_exists = cbm_file_exists(marker_path); + (void)printf("TF_BLOCKING_GIT_DIAGNOSTIC marker_open_failed errno=%d win_error=%lu " + "exists=%d\n", + marker_errno, (unsigned long)marker_error, marker_exists ? 1 : 0); + (void)fflush(stdout); + return marker_exists ? 0 : 30; +#else + return cbm_file_exists(marker_path) ? 0 : 30; +#endif + } +#ifdef _WIN32 + unsigned long long process_id = (unsigned long long)GetCurrentProcessId(); +#else + unsigned long long process_id = (unsigned long long)getpid(); +#endif + bool published = + fprintf(marker, "%llu\n", process_id) > 0 && fflush(marker) == 0 && fclose(marker) == 0; + if (!published) { + return 31; + } +#ifdef _WIN32 + (void)SetConsoleCtrlHandler(probe_blocking_git_control_handler, TRUE); +#else + (void)signal(SIGTERM, SIG_IGN); + (void)signal(SIGINT, SIG_IGN); +#endif + for (;;) { + cbm_usleep(100000); + } +} + #if defined(__has_feature) #if __has_feature(memory_sanitizer) #define PROBE_MSAN_MIMALLOC_OUTPUT 1 @@ -41,6 +151,10 @@ int main(int argc, char **argv) { mi_register_output(probe_msan_mi_output, NULL); probe_msan_mi_output_live = true; #endif + int git_rc = probe_maybe_run_blocking_git(argc, argv); + if (git_rc >= 0) { + return git_rc; + } /* 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) { diff --git a/tests/image_probe_roles.c b/tests/image_probe_roles.c index 918b504efc..1b9b1d90b4 100644 --- a/tests/image_probe_roles.c +++ b/tests/image_probe_roles.c @@ -318,6 +318,21 @@ static int probe_role_serve(int argc, char **argv) { return freed ? 0 : 34; } +static int probe_role_git_facts_diff_probe(int argc, char **argv) { + if (argc < 3 || !argv[2]) { + return 96; + } + FILE *file = cbm_fopen(argv[2], "wb"); + if (!file) { + return 96; + } + bool ok = fwrite("invoked\n", 1, 8, file) == 8; + if (fclose(file) != 0) { + ok = false; + } + return ok ? 0 : 96; +} + int tf_image_probe_dispatch(int argc, char **argv) { if (argc < 2 || !argv || !argv[1]) { return -1; @@ -338,5 +353,8 @@ int tf_image_probe_dispatch(int argc, char **argv) { if (strcmp(role, "__cbm_runtime_mapped_hello_client") == 0) { return probe_role_mapped_hello(argc, argv); } + if (strcmp(role, "__cbm_git_facts_diff_probe") == 0) { + return probe_role_git_facts_diff_probe(argc, argv); + } return -1; } diff --git a/tests/test_c_lsp.c b/tests/test_c_lsp.c index a7a46eb556..6009e6390c 100644 --- a/tests/test_c_lsp.c +++ b/tests/test_c_lsp.c @@ -17168,6 +17168,12 @@ SUITE(c_lsp) { RUN_TEST(clsp_issue1527_cross_file_memo_failures_propagate); RUN_TEST(clsp_issue1546_cross_entry_points_read_crlf_string_splice); RUN_TEST(clsp_issue1527_long_binary_chain_is_not_nesting); +} + +/* Second half of the C/C++ LSP suite, run as its own parallel unit so the + * two heaviest chain-resolution stress tests execute on separate workers + * instead of serializing in one suite (matches pipeline_b). */ +SUITE(c_lsp_b) { RUN_TEST(clsp_issue1527_long_receiver_chain_is_not_nesting); RUN_TEST(clsp_c_reassigned_function_pointer_calls_join_exact_occurrences); RUN_TEST(clsp_c_nested_function_pointer_shadow_restores_outer_target); diff --git a/tests/test_cli.c b/tests/test_cli.c index 4fba446f50..c325eb1d06 100644 --- a/tests/test_cli.c +++ b/tests/test_cli.c @@ -1384,6 +1384,11 @@ TEST(cli_activation_quiesce_does_not_wait_on_bootstrap_startup) { cbm_version_cohort_lease_t *lease = NULL; cbm_daemon_conflict_t conflict; cbm_daemon_ipc_startup_lock_t *startup = NULL; +#ifdef CBM_ENABLE_TEST_SEAMS + static const char participant_stub_digest[CBM_DAEMON_BUILD_FINGERPRINT_SIZE] = + "4444444444444444444444444444444444444444444444444444444444444444"; + cbm_daemon_runtime_fingerprint_cache_set_hash_stub_for_testing(participant_stub_digest); +#endif bool setup = endpoint && manager && cbm_daemon_runtime_process_build_fingerprint((uint64_t)getpid(), fingerprint) && @@ -1673,8 +1678,9 @@ typedef struct { char *old_home; char *old_cache; char *old_shell; - bool env_saved; /* HOME, CBM_CACHE_DIR and SHELL were saved for finish */ - char failed_step[160]; /* the setup step that failed, "" when ready */ + bool env_saved; /* HOME, CBM_CACHE_DIR and SHELL were saved for finish */ + bool fingerprint_stub_armed; /* runtime hash stub active for this fixture */ + char failed_step[160]; /* the setup step that failed, "" when ready */ } cli_scope_fixture_t; static _Noreturn void cli_scope_host_child(const cli_scope_fixture_t *fixture, int ready_fd, @@ -1791,6 +1797,12 @@ static char cli_scope_wait_ready(int fd) { * ASSERT_TRUE(ready) is never a silent failure. Returns false. */ static bool cli_scope_setup_failed(cli_scope_fixture_t *fixture, const char *tag, const char *step, int os_error) { +#ifdef CBM_ENABLE_TEST_SEAMS + if (fixture->fingerprint_stub_armed) { + cbm_daemon_runtime_fingerprint_cache_reset_for_testing(); + fixture->fingerprint_stub_armed = false; + } +#endif snprintf(fixture->failed_step, sizeof(fixture->failed_step), "%s", step); if (os_error != 0) { (void)fprintf(stderr, "cli scope fixture %s: setup failed at %s: %s\n", tag, step, @@ -1878,6 +1890,16 @@ static bool cli_scope_fixture_start(cli_scope_fixture_t *fixture, const char *ta } cbm_normalize_path_sep(canonical_cache); cbm_sha256_hex(canonical_cache, strlen(canonical_cache), fixture->host_cache_fingerprint); +#ifdef CBM_ENABLE_TEST_SEAMS + /* Both the parent and the forked host child execute this same runner + * binary; stubbing only the full-image SHA-256 avoids hashing hundreds of + * MB per cli_scope fixture while keeping all kernel PID/path/cohort checks. */ + static const char scope_stub_digest[CBM_DAEMON_BUILD_FINGERPRINT_SIZE] = + "5555555555555555555555555555555555555555555555555555555555555555"; + cbm_daemon_runtime_fingerprint_cache_reset_for_testing(); + cbm_daemon_runtime_fingerprint_cache_set_hash_stub_for_testing(scope_stub_digest); + fixture->fingerprint_stub_armed = true; +#endif if (!cbm_daemon_runtime_process_build_fingerprint((uint64_t)getpid(), fixture->self_build)) { /* Fails when the runner's file no longer matches its running image, * e.g. a rebuild replaced it mid-run. */ @@ -2018,6 +2040,12 @@ static int cli_scope_fixture_finish(cli_scope_fixture_t *fixture) { if (fixture->previous_supervisor_build[0]) { cbm_index_supervisor_set_build_fingerprint_for_test(fixture->previous_supervisor_build); } +#ifdef CBM_ENABLE_TEST_SEAMS + if (fixture->fingerprint_stub_armed) { + cbm_daemon_runtime_fingerprint_cache_reset_for_testing(); + fixture->fingerprint_stub_armed = false; + } +#endif /* Restore only what start saved: a setup that failed before saving left * HOME, CBM_CACHE_DIR and SHELL untouched, and restoring "nothing saved" * would unset them for every later test in the suite. */ @@ -3840,22 +3868,13 @@ TEST(cli_update_agent_configs_finish_before_guard_release) { const char *asset_name = "codebase-memory-mcp-linux-amd64-portable.tar.gz"; #endif #endif -#ifdef __APPLE__ - /* Use the structurally real test runner rather than re-signing an Apple - * platform binary. Turning /usr/bin/true's arm64e/platform signature into - * an ad-hoc signature is OS-policy-dependent on older macOS runners. */ - char native_fixture_path[CBM_SZ_4K] = {0}; - uint32_t native_fixture_size = (uint32_t)sizeof(native_fixture_path); - ASSERT_EQ(_NSGetExecutablePath(native_fixture_path, &native_fixture_size), 0); - const char *native_fixture = native_fixture_path; -#else - /* The image probe built beside this runner (tests/test_image_probe.h) - * answers --version under any name. /bin/true does not on every host: a - * multicall coreutils (Nix) or BusyBox (Alpine) selects its applet from - * argv[0], so a copy staged as codebase-memory-mcp fails the check. */ + /* Use the small image probe built beside this runner (tests/test_image_probe.h) + * on both Linux and macOS: it is a real, locally built executable that + * answers --version under any name (unlike multicall /bin/true or Apple + * platform binaries) without gzipping, SHA-256 hashing, and re-signing the + * ~500 MB sanitized test runner. */ char native_fixture[1024] = {0}; ASSERT_TRUE(th_image_probe_path(native_fixture, sizeof(native_fixture))); -#endif FILE *native_file = fopen(native_fixture, "rb"); ASSERT_NOT_NULL(native_file); ASSERT_EQ(fseek(native_file, 0, SEEK_END), 0); @@ -3990,20 +4009,16 @@ TEST(cli_update_names_the_failing_staging_step_and_os_error) { #else const char *asset_name = "codebase-memory-mcp-darwin-amd64.tar.gz"; #endif - char native_fixture_path[CBM_SZ_4K] = {0}; - uint32_t native_fixture_size = (uint32_t)sizeof(native_fixture_path); - ASSERT_EQ(_NSGetExecutablePath(native_fixture_path, &native_fixture_size), 0); - const char *native_fixture = native_fixture_path; #else #if defined(__aarch64__) const char *asset_name = "codebase-memory-mcp-linux-arm64-portable.tar.gz"; #else const char *asset_name = "codebase-memory-mcp-linux-amd64-portable.tar.gz"; +#endif #endif /* The image probe, as in cli_update_agent_configs_finish_before_guard_release. */ char native_fixture[1024] = {0}; ASSERT_TRUE(th_image_probe_path(native_fixture, sizeof(native_fixture))); -#endif FILE *native_file = fopen(native_fixture, "rb"); ASSERT_NOT_NULL(native_file); ASSERT_EQ(fseek(native_file, 0, SEEK_END), 0); @@ -21795,15 +21810,28 @@ TEST(cli_index_exit_partial_without_denominator_is_not_graded) { PASS(); } -SUITE(cli) { +static bool cli_suite_setup(const char *tag) { if (!th_secure_runtime_parent_new(g_cli_suite_runtime_parent, - sizeof(g_cli_suite_runtime_parent), "cli-suite")) { + sizeof(g_cli_suite_runtime_parent), tag)) { printf(" %sFAIL%s: could not create private CLI activation runtime\n", tf_red(), tf_reset()); tf_fail_count++; - return; + return false; } cbm_cli_set_activation_runtime_parent_for_test(g_cli_suite_runtime_parent); + return true; +} + +static void cli_suite_teardown(void) { + cbm_cli_set_activation_runtime_parent_for_test(NULL); + test_rmdir_r(g_cli_suite_runtime_parent); + g_cli_suite_runtime_parent[0] = '\0'; +} + +SUITE(cli) { + if (!cli_suite_setup("cli-suite")) { + return; + } RUN_TEST(cli_suite_uses_private_activation_runtime); RUN_TEST(cli_update_only_names_an_installer_that_exists_issue1632); @@ -21897,6 +21925,16 @@ SUITE(cli) { RUN_TEST(cli_windows_update_hands_off_to_install_script); RUN_TEST(cli_uninstall_removes_only_its_own_windows_user_path_entry_issue2117); #endif + cli_suite_teardown(); +} + +/* Second half of the CLI suite, split right after the daemon-activation + * battery so both halves balance evenly across x86, arm64, and Intel macOS + * CI shards instead of serializing all 415 CLI tests onto one runner. */ +SUITE(cli_b) { + if (!cli_suite_setup("cli-suite-b")) { + return; + } /* Version (2 tests — selfupdate_test.go) */ RUN_TEST(cli_compare_versions); @@ -22329,7 +22367,5 @@ SUITE(cli) { RUN_TEST(cli_index_exit_negative_threshold_disables_the_check); RUN_TEST(cli_index_exit_unreadable_threshold_falls_back_to_default); RUN_TEST(cli_index_exit_partial_without_denominator_is_not_graded); - cbm_cli_set_activation_runtime_parent_for_test(NULL); - test_rmdir_r(g_cli_suite_runtime_parent); - g_cli_suite_runtime_parent[0] = '\0'; + cli_suite_teardown(); } diff --git a/tests/test_complexity.c b/tests/test_complexity.c index f314e66fd5..d2227cf30e 100644 --- a/tests/test_complexity.c +++ b/tests/test_complexity.c @@ -2471,6 +2471,11 @@ SUITE(complexity) { RUN_TEST(complexity_go_route_bindings_are_near_linear); RUN_TEST(complexity_name_rows_answer_as_a_scan_does); RUN_TEST(complexity_python_pass_import_join_is_linear); +} + +/* Second half of complexity, split so the 41-test scaling battery runs across + * two parallel workers/shards instead of straggling on sanitizer legs. */ +SUITE(complexity_b) { RUN_TEST(complexity_python_pass_wide_from_import_is_linear); RUN_TEST(complexity_go_import_uses_are_linear); RUN_TEST(complexity_go_pass_registration_is_linear); diff --git a/tests/test_daemon_bootstrap.c b/tests/test_daemon_bootstrap.c index 040459c7b4..7b9badc25d 100644 --- a/tests/test_daemon_bootstrap.c +++ b/tests/test_daemon_bootstrap.c @@ -1088,6 +1088,14 @@ TEST(daemon_bootstrap_fails_fast_when_daemon_dies_at_publication) { cbm_mkdir_p(cache, 0700) && cbm_setenv("CBM_CACHE_DIR", cache, 1) == 0; char self_build[CBM_DAEMON_BUILD_FINGERPRINT_SIZE] = {0}; +#ifdef CBM_ENABLE_TEST_SEAMS + /* Avoid full-image SHA-256 of the multi-hundred-MB sanitized runner in both + * parent and forked host; kernel identity checks still run unchanged. */ + static const char enospc_stub_digest[CBM_DAEMON_BUILD_FINGERPRINT_SIZE] = + "2222222222222222222222222222222222222222222222222222222222222222"; + cbm_daemon_runtime_fingerprint_cache_reset_for_testing(); + cbm_daemon_runtime_fingerprint_cache_set_hash_stub_for_testing(enospc_stub_digest); +#endif bool identity_ready = environment_ready && cbm_daemon_runtime_process_build_fingerprint( (uint64_t)getpid(), self_build); static bootstrap_enospc_host_t host; @@ -1115,6 +1123,9 @@ TEST(daemon_bootstrap_fails_fast_when_daemon_dies_at_publication) { } int nonzero_exits = 0; bootstrap_enospc_reap(&host, &nonzero_exits); +#ifdef CBM_ENABLE_TEST_SEAMS + cbm_daemon_runtime_fingerprint_cache_reset_for_testing(); +#endif static char log[BOOTSTRAP_ENOSPC_LOG_CAP]; log[0] = '\0'; diff --git a/tests/test_daemon_frontend.c b/tests/test_daemon_frontend.c index 7e5c540ba3..b15388682f 100644 --- a/tests/test_daemon_frontend.c +++ b/tests/test_daemon_frontend.c @@ -2001,6 +2001,15 @@ TEST(daemon_local_participant_monitor_joins_before_manager_teardown) { } SUITE(daemon_frontend) { +#ifdef CBM_ENABLE_TEST_SEAMS + /* Every daemon_frontend test runs in-process or forks this same runner; + * stubbing only the full-image SHA-256 avoids repeatedly hashing hundreds + * of MB per fork while keeping all kernel identity checks live. */ + static const char frontend_stub_digest[CBM_DAEMON_BUILD_FINGERPRINT_SIZE] = + "3333333333333333333333333333333333333333333333333333333333333333"; + cbm_daemon_runtime_fingerprint_cache_reset_for_testing(); + cbm_daemon_runtime_fingerprint_cache_set_hash_stub_for_testing(frontend_stub_digest); +#endif RUN_TEST(daemon_frontend_recognizes_exact_cancellation_notification); RUN_TEST(daemon_frontend_correlates_cancellation_to_exact_request); RUN_TEST(daemon_frontend_cancelled_index_reply_offers_async_issue2144); @@ -2025,4 +2034,7 @@ SUITE(daemon_frontend) { RUN_TEST(daemon_frontend_stdout_backpressure_maintenance_stops_and_cancels_session); #endif RUN_TEST(daemon_local_participant_monitor_joins_before_manager_teardown); +#ifdef CBM_ENABLE_TEST_SEAMS + cbm_daemon_runtime_fingerprint_cache_reset_for_testing(); +#endif } diff --git a/tests/test_daemon_runtime.c b/tests/test_daemon_runtime.c index e58a92aec8..66c2cf998d 100644 --- a/tests/test_daemon_runtime.c +++ b/tests/test_daemon_runtime.c @@ -245,18 +245,6 @@ typedef struct { wchar_t file_name[1]; } runtime_test_windows_rename_info_t; -static bool runtime_test_windows_copy_self(const char *destination) { - wchar_t source[32768]; - DWORD source_length = - GetModuleFileNameW(NULL, source, (DWORD)(sizeof(source) / sizeof(source[0]))); - wchar_t *destination_wide = cbm_path_to_wide(destination); - bool copied = source_length > 0 && - source_length < (DWORD)(sizeof(source) / sizeof(source[0])) && destination_wide && - CopyFileW(source, destination_wide, TRUE) != 0; - free(destination_wide); - return copied; -} - static bool runtime_test_windows_wait_image_probe(HANDLE process) { if (!process) { return false; @@ -494,19 +482,6 @@ static bool runtime_test_self_image_path(char source[RUNTIME_TEST_PATH_CAP]) { } #endif -static bool runtime_test_copy_self_image(const char *destination) { -#ifdef _WIN32 - return runtime_test_windows_copy_self(destination); -#elif defined(__APPLE__) || defined(__linux__) - char source[RUNTIME_TEST_PATH_CAP]; - return runtime_test_self_image_path(source) && - runtime_test_copy_executable(source, destination); -#else - (void)destination; - return false; -#endif -} - /* The image probe beside this runner (tests/test_image_probe.h): the small * executable the copied-image tests copy, hash and run instead of this runner. * NULL, said once on stderr, when it was not built. */ @@ -4386,7 +4361,7 @@ TEST(daemon_runtime_disconnect_cancels_blocked_non_index_child_and_preserves_oth git_written < (int)sizeof(fake_git) && marker_written > 0 && marker_written < (int)sizeof(marker) && cbm_mkdir_p(root, 0700) && cbm_mkdir_p(cache, 0700) && cbm_mkdir_p(bin, 0700) && - runtime_test_copy_self_image(fake_git); + runtime_test_copy_probe_image(fake_git); char path_bin[RUNTIME_TEST_PATH_CAP] = {0}; #ifdef _WIN32 @@ -5956,6 +5931,17 @@ TEST(daemon_runtime_stop_refuses_while_committed_clients_exist) { } SUITE(daemon_runtime) { +#ifdef CBM_ENABLE_TEST_SEAMS + /* Phase 1: in-process and same-binary lifecycle/IPC/cancellation tests. + * Stubbing only the full-image SHA-256 avoids hashing the multi-hundred-MB + * sanitized runner during fixture startup while keeping every kernel + * process/image-identity check live. Disarmed before Phase 2 below. */ + static const char runtime_stub_digest[CBM_DAEMON_BUILD_FINGERPRINT_SIZE] = + "6666666666666666666666666666666666666666666666666666666666666666"; + runtime_self_build[0] = '\0'; + cbm_daemon_runtime_fingerprint_cache_reset_for_testing(); + cbm_daemon_runtime_fingerprint_cache_set_hash_stub_for_testing(runtime_stub_digest); +#endif RUN_TEST(daemon_runtime_permanent_service_survives_last_disconnect_until_stop); RUN_TEST(daemon_runtime_stop_refuses_while_committed_clients_exist); RUN_TEST(daemon_host_early_coordination_failure_is_durable); @@ -5967,37 +5953,14 @@ SUITE(daemon_runtime) { RUN_TEST(daemon_host_failed_listener_reservation_starts_no_background_work); RUN_TEST(daemon_host_persistent_cleanup_release_failure_is_process_bounded); RUN_TEST(daemon_host_forced_shutdown_is_logged_flushed_and_process_bounded); -#endif - RUN_TEST(daemon_runtime_kernel_process_fingerprint_is_stable_and_fail_closed); -#ifdef _WIN32 - RUN_TEST(daemon_runtime_process_fingerprint_supports_extended_length_image); -#endif -#ifdef __APPLE__ - RUN_TEST(daemon_runtime_mac_fast_path_rejects_foreign_main_image_mapping_active); -#endif - RUN_TEST(daemon_runtime_copied_image_fallback_accepts_identical_and_rejects_changed); -#if defined(_WIN32) || defined(__APPLE__) || defined(__linux__) - RUN_TEST(daemon_runtime_process_fingerprint_never_hashes_replacement_path); -#endif - RUN_TEST(daemon_runtime_fingerprint_cache_hit_miss_key_roll); - RUN_TEST(daemon_runtime_fingerprint_cache_skips_image_changed_under_hash); - RUN_TEST(daemon_runtime_process_fingerprint_hashes_own_image_once_per_process); -#if defined(__APPLE__) || defined(__linux__) - RUN_TEST(daemon_runtime_process_fingerprint_caches_only_own_image); #endif RUN_TEST(daemon_runtime_convenience_service_owns_participant_guard); RUN_TEST(daemon_runtime_host_loop_stops_on_coordination_file_loss); RUN_TEST(daemon_runtime_rendezvous_layout_is_frozen_and_detailed_abi_independent); RUN_TEST(daemon_runtime_exact_hello_issues_connection_bound_identity); - RUN_TEST(daemon_runtime_image_rejection_reaches_client_issue1383); - RUN_TEST(daemon_runtime_unverifiable_image_is_admitted_issue1539); - RUN_TEST(daemon_runtime_verified_peer_copy_is_hashed_once_issue1955); RUN_TEST(daemon_runtime_unexpected_frame_payload_is_freed_once); RUN_TEST(daemon_runtime_activation_rejects_forged_and_malformed_without_stop); RUN_TEST(daemon_runtime_activation_ack_snapshots_then_interrupts_all_clients); -#if defined(_WIN32) || defined(__APPLE__) || defined(__linux__) - RUN_TEST(daemon_runtime_activation_accepts_authenticated_different_build); -#endif RUN_TEST(daemon_runtime_future_generation_gets_stable_explicit_conflict); RUN_TEST(daemon_runtime_matching_clients_share_one_service_endpoint); RUN_TEST(daemon_runtime_same_version_different_build_is_visible_and_logged); @@ -6031,4 +5994,38 @@ SUITE(daemon_runtime) { RUN_TEST(daemon_runtime_mute_endpoint_holder_pid_is_reported); RUN_TEST(daemon_runtime_application_busy_cap_and_malformed_are_isolated); RUN_TEST(daemon_runtime_malformed_and_zero_cancel_close_only_offending_connections); + +#ifdef CBM_ENABLE_TEST_SEAMS + /* Phase 2: real-image and cross-binary (image-probe) authentication tests. + * Disarm the stub and clear runtime_self_build so the own-image hash is + * computed once for real and cached across all Phase 2 tests. */ + cbm_daemon_runtime_fingerprint_cache_reset_for_testing(); + runtime_self_build[0] = '\0'; +#endif + RUN_TEST(daemon_runtime_kernel_process_fingerprint_is_stable_and_fail_closed); +#ifdef _WIN32 + RUN_TEST(daemon_runtime_process_fingerprint_supports_extended_length_image); +#endif +#ifdef __APPLE__ + RUN_TEST(daemon_runtime_mac_fast_path_rejects_foreign_main_image_mapping_active); +#endif + RUN_TEST(daemon_runtime_copied_image_fallback_accepts_identical_and_rejects_changed); +#if defined(_WIN32) || defined(__APPLE__) || defined(__linux__) + RUN_TEST(daemon_runtime_process_fingerprint_never_hashes_replacement_path); +#endif + RUN_TEST(daemon_runtime_image_rejection_reaches_client_issue1383); + RUN_TEST(daemon_runtime_unverifiable_image_is_admitted_issue1539); + RUN_TEST(daemon_runtime_verified_peer_copy_is_hashed_once_issue1955); +#if defined(_WIN32) || defined(__APPLE__) || defined(__linux__) + RUN_TEST(daemon_runtime_activation_accepts_authenticated_different_build); +#endif + + /* Phase 3: fingerprint-cache reset/key-roll unit tests run last so they + * never evict the own-image fingerprint cached for Phase 2. */ + RUN_TEST(daemon_runtime_fingerprint_cache_hit_miss_key_roll); + RUN_TEST(daemon_runtime_fingerprint_cache_skips_image_changed_under_hash); + RUN_TEST(daemon_runtime_process_fingerprint_hashes_own_image_once_per_process); +#if defined(__APPLE__) || defined(__linux__) + RUN_TEST(daemon_runtime_process_fingerprint_caches_only_own_image); +#endif } diff --git a/tests/test_doc_mentions.c b/tests/test_doc_mentions.c index 43259fc024..fbe9608075 100644 --- a/tests/test_doc_mentions.c +++ b/tests/test_doc_mentions.c @@ -10495,6 +10495,12 @@ SUITE(doc_mentions) { RUN_TEST(doc_mentions_cs_control_scopes); RUN_TEST(doc_mentions_cs_control_publication); RUN_TEST(doc_mentions_cs_utf8_surfaces); +} + +/* Second half of doc_mentions, split after doc_mentions_cs_utf8_surfaces so + * doc_mentions_cs_control_publication and doc_mentions_cs_namespace_publication + * run concurrently across Windows and Unix CI shards. */ +SUITE(doc_mentions_e) { RUN_TEST(doc_mentions_cs_namespace_publication); RUN_TEST(doc_mentions_cs_scope_parse_errors); RUN_TEST(doc_mentions_cs_norm_type); @@ -10512,6 +10518,11 @@ SUITE(doc_mentions) { RUN_TEST(doc_mentions_incremental_equals_full); RUN_TEST(doc_mentions_parallel_equals_sequential); RUN_TEST(doc_mentions_cs_scan_dollar_run); +} + +/* Second half of doc_mentions, split at the ~50%-runtime boundary for parallel + * scheduling parity across CI shards (matches pipeline_b). */ +SUITE(doc_mentions_b) { RUN_TEST(doc_mentions_cs_shared_doc_sources); RUN_TEST(doc_mentions_cs_shared_doc_once); RUN_TEST(doc_mentions_cs_shared_doc_replay); @@ -10519,6 +10530,12 @@ SUITE(doc_mentions) { RUN_TEST(doc_mentions_cs_scan_header_reads); RUN_TEST(doc_mentions_cs_scan_nested_holes); RUN_TEST(doc_mentions_cs_scan_holes_stack); +} + +/* Continuation of doc_mentions_b, split right after doc_mentions_cs_scan_holes_stack + * so that heavy scanner stress test runs concurrently with the remaining 40 + * resolver/incremental tests under MSan and across CI shards. */ +SUITE(doc_mentions_d) { RUN_TEST(doc_mentions_incremental_project_files); RUN_TEST(doc_mentions_cs_lookup_order); RUN_TEST(doc_mentions_cs_type_parameters); diff --git a/tests/test_grammar_probe_f.c b/tests/test_grammar_probe_f.c index f28aeddc7e..741698bcbe 100644 --- a/tests/test_grammar_probe_f.c +++ b/tests/test_grammar_probe_f.c @@ -8198,6 +8198,11 @@ SUITE(grammar_probe_f) { RUN_TEST(probe_terragrunt_stack_reads); RUN_TEST(probe_terragrunt_stack_includes); RUN_TEST(probe_ansible_files_import_what_they_name); +} + +/* Second half of grammar_probe_f, split so the 206-test infra/config probe + * does not bottleneck Windows CI shards (matches pipeline_b). */ +SUITE(grammar_probe_f_b) { RUN_TEST(probe_terraform_kubernetes_objects_are_resources); RUN_TEST(probe_kustomize_name_prefix_makes_variants); RUN_TEST(probe_ansible_tasks_are_functions); diff --git a/tests/test_image_probe.h b/tests/test_image_probe.h index be975dc68d..4f0267e53f 100644 --- a/tests/test_image_probe.h +++ b/tests/test_image_probe.h @@ -22,7 +22,10 @@ * __cbm_runtime_activation_client * __cbm_runtime_mapped_hello_client * __cbm_runtime_image_holder [] - * The probe's main also answers --version (install verification runs it). + * __cbm_git_facts_diff_probe + * The probe's main also answers --version (install verification runs it) and + * the blocking-git probe when invoked as git/git.exe with + * CBM_TEST_RUNTIME_BLOCKING_GIT_PID_FILE set. */ #include "foundation/compat_fs.h" /* cbm_fopen: the probe path may be non-ASCII */ diff --git a/tests/test_java_type_scope.c b/tests/test_java_type_scope.c index 2649781e46..cd41a0d684 100644 --- a/tests/test_java_type_scope.c +++ b/tests/test_java_type_scope.c @@ -2890,6 +2890,11 @@ SUITE(java_type_scope) { RUN_TEST(java_type_scope_owner_spelled_supertype_parallel); RUN_TEST(java_type_scope_library_split_package_sequential); RUN_TEST(java_type_scope_library_split_package_parallel); +} + +/* Second half of java_type_scope, split so both halves run concurrently across + * workers and shards (matches pipeline_b). */ +SUITE(java_type_scope_b) { RUN_TEST(java_type_scope_interface_call_sequential); RUN_TEST(java_type_scope_interface_call_parallel); RUN_TEST(java_type_scope_inherited_overload_sequential); diff --git a/tests/test_main.c b/tests/test_main.c index e3ef07cd76..b625fb7e93 100644 --- a/tests/test_main.c +++ b/tests/test_main.c @@ -1597,6 +1597,7 @@ extern void suite_workspace(void); extern void suite_platform(void); extern void suite_diagnostics(void); extern void suite_complexity(void); +extern void suite_complexity_b(void); extern void suite_subprocess(void); extern void suite_private_file_lock(void); extern void suite_lock_registry(void); @@ -1621,6 +1622,8 @@ extern void suite_test_impact_profiles(void); extern void suite_test_impact_changes(void); extern void suite_test_impact_origins(void); extern void suite_test_impact_git(void); +extern void suite_test_impact_git_b(void); +extern void suite_test_impact_git_c(void); extern void suite_test_impact_tree(void); extern void suite_test_impact_tree_read(void); extern void suite_test_impact_inventory(void); @@ -1633,6 +1636,7 @@ extern void suite_test_impact_runner_filter(void); extern void suite_store_search(void); extern void suite_cypher(void); extern void suite_mcp(void); +extern void suite_mcp_supervisor(void); extern void suite_mcp_mutation_guard(void); extern void suite_index_supervisor(void); extern void suite_daemon(void); @@ -1663,12 +1667,15 @@ extern void suite_discover(void); extern void suite_graph_buffer(void); extern void suite_registry(void); extern void suite_pipeline(void); +extern void suite_pipeline_d(void); extern void suite_pipeline_b(void); +extern void suite_pipeline_c(void); extern void suite_pipeline_objectscript_timeout(void); extern void suite_pipeline_conventions(void); extern void suite_pipeline_frozen(void); extern void suite_importance(void); extern void suite_pipeline_semantic_manifest_repro(void); +extern void suite_pipeline_semantic_manifest_repro_b(void); extern void suite_cross_repo(void); extern void suite_index_resilience(void); extern void suite_index_format(void); @@ -1687,6 +1694,7 @@ extern void suite_artifact(void); extern void suite_sqlite_writer(void); extern void suite_go_lsp(void); extern void suite_c_lsp(void); +extern void suite_c_lsp_b(void); extern void suite_php_lsp(void); extern void suite_member_walk(void); extern void suite_php_member_walk(void); @@ -1705,6 +1713,7 @@ extern void suite_java_lsp(void); extern void suite_java_lsp_coverage(void); extern void suite_java_typed_calls(void); extern void suite_java_type_scope(void); +extern void suite_java_type_scope_b(void); extern void suite_kotlin_lsp(void); extern void suite_kotlin_typed_calls(void); extern void suite_rust_lsp(void); @@ -1717,6 +1726,9 @@ extern void suite_traces(void); extern void suite_configlink(void); extern void suite_doclinks(void); extern void suite_doc_mentions(void); +extern void suite_doc_mentions_e(void); +extern void suite_doc_mentions_b(void); +extern void suite_doc_mentions_d(void); extern void suite_doc_mentions_cost(void); extern void suite_doc_mentions_msbuild(void); extern void suite_doc_links_md(void); @@ -1734,6 +1746,7 @@ extern void suite_diagrams(void); extern void suite_openapi(void); extern void suite_infrascan(void); extern void suite_cli(void); +extern void suite_cli_b(void); extern void suite_runtime_settings(void); extern void suite_agent_clients(void); extern void suite_agent_profiles(void); @@ -1786,6 +1799,7 @@ extern void suite_grammar_probe_c(void); extern void suite_grammar_probe_d(void); extern void suite_grammar_probe_e(void); extern void suite_grammar_probe_f(void); +extern void suite_grammar_probe_f_b(void); extern void suite_grammar_probe_g(void); extern void suite_incremental(void); extern void suite_semantic(void); @@ -2437,6 +2451,7 @@ int main(int argc, char **argv) { RUN_SELECTED_SUITE(platform); RUN_SELECTED_SUITE(diagnostics); RUN_SELECTED_SUITE(complexity); + RUN_SELECTED_SUITE(complexity_b); RUN_SELECTED_SUITE(subprocess); RUN_SELECTED_SUITE(private_file_lock); RUN_SELECTED_SUITE(lock_registry); @@ -2466,6 +2481,8 @@ int main(int argc, char **argv) { RUN_SELECTED_SUITE(test_impact_changes); RUN_SELECTED_SUITE(test_impact_origins); RUN_SELECTED_SUITE(test_impact_git); + RUN_SELECTED_SUITE(test_impact_git_b); + RUN_SELECTED_SUITE(test_impact_git_c); RUN_SELECTED_SUITE(test_impact_tree); RUN_SELECTED_SUITE(test_impact_tree_read); RUN_SELECTED_SUITE(test_impact_inventory); @@ -2486,6 +2503,7 @@ int main(int argc, char **argv) { /* MCP Server (M9) */ RUN_SELECTED_SUITE(mcp); + RUN_SELECTED_SUITE(mcp_supervisor); RUN_SELECTED_SUITE(mcp_mutation_guard); RUN_SELECTED_SUITE(index_supervisor); @@ -2521,13 +2539,16 @@ int main(int argc, char **argv) { /* Pipeline (M8) */ RUN_SELECTED_SUITE(registry); RUN_SELECTED_SUITE(pipeline); + RUN_SELECTED_SUITE(pipeline_d); RUN_SELECTED_SUITE(pipeline_b); + RUN_SELECTED_SUITE(pipeline_c); RUN_SELECTED_SUITE(pipeline_objectscript_timeout); RUN_SELECTED_SUITE(pipeline_conventions); RUN_SELECTED_SUITE(pipeline_frozen); RUN_SELECTED_SUITE(importance); RUN_SELECTED_SUITE(index_format); RUN_SELECTED_SUITE(pipeline_semantic_manifest_repro); + RUN_SELECTED_SUITE(pipeline_semantic_manifest_repro_b); RUN_SELECTED_SUITE(call_reference_contract); RUN_SELECTED_SUITE(call_reference_language_complex_contract); RUN_SELECTED_SUITE(repro_call_scope_usages); @@ -2570,6 +2591,7 @@ int main(int argc, char **argv) { RUN_SELECTED_SUITE(type_rep); RUN_SELECTED_SUITE(go_lsp); RUN_SELECTED_SUITE(c_lsp); + RUN_SELECTED_SUITE(c_lsp_b); RUN_SELECTED_SUITE(php_lsp); RUN_SELECTED_SUITE(member_walk); RUN_SELECTED_SUITE(php_member_walk); @@ -2589,6 +2611,7 @@ int main(int argc, char **argv) { RUN_SELECTED_SUITE(java_lsp_coverage); RUN_SELECTED_SUITE(java_typed_calls); RUN_SELECTED_SUITE(java_type_scope); + RUN_SELECTED_SUITE(java_type_scope_b); /* Architecture + ADR + Louvain */ RUN_SELECTED_SUITE(store_arch); @@ -2607,6 +2630,9 @@ int main(int argc, char **argv) { /* Doc-comment references -> MENTIONS */ RUN_SELECTED_SUITE(doc_mentions); + RUN_SELECTED_SUITE(doc_mentions_e); + RUN_SELECTED_SUITE(doc_mentions_b); + RUN_SELECTED_SUITE(doc_mentions_d); RUN_SELECTED_SUITE(doc_mentions_cost); RUN_SELECTED_SUITE(doc_mentions_msbuild); RUN_SELECTED_SUITE(doc_links_md); @@ -2628,6 +2654,7 @@ int main(int argc, char **argv) { /* CLI (install, update, config) */ RUN_SELECTED_SUITE(cli); + RUN_SELECTED_SUITE(cli_b); RUN_SELECTED_SUITE(runtime_settings); RUN_SELECTED_SUITE(agent_clients); RUN_SELECTED_SUITE(agent_profiles); @@ -2699,6 +2726,7 @@ int main(int argc, char **argv) { RUN_SELECTED_SUITE(grammar_probe_d); RUN_SELECTED_SUITE(grammar_probe_e); RUN_SELECTED_SUITE(grammar_probe_f); + RUN_SELECTED_SUITE(grammar_probe_f_b); RUN_SELECTED_SUITE(grammar_probe_g); RUN_SELECTED_SUITE_PERF(incremental); diff --git a/tests/test_mcp.c b/tests/test_mcp.c index 257151107e..f59aa85047 100644 --- a/tests/test_mcp.c +++ b/tests/test_mcp.c @@ -29313,22 +29313,15 @@ SUITE(mcp) { RUN_TEST(search_graph_oversized_name_pattern_is_tool_error); RUN_TEST(search_code_file_pattern_prefilter_boundaries); RUN_TEST(search_code_windows_scope_prefilter_removes_pipeline_filter); - RUN_TEST(search_code_cancel_cleans_supervised_scan); RUN_TEST(search_code_unscoped_argv_scans_metachar_filenames_issue2634); RUN_TEST(search_code_unscoped_argv_no_match_is_success_issue2634); RUN_TEST(search_code_unscoped_argv_honours_file_pattern_issue2634); RUN_TEST(server_handle_logs_timeout_without_query); RUN_TEST(search_code_output_limit_fails_closed_and_cleans_scan); - RUN_TEST(search_code_scan_deadline_fails_closed_and_resets); - RUN_TEST(search_code_scan_deadline_override_is_per_server); RUN_TEST(search_code_scan_setup_failures_respect_cause_precedence); - RUN_TEST(search_code_scan_live_child_deadline_is_bounded_and_fails_closed); RUN_TEST(search_code_scan_in_process_writes_grep_records); RUN_TEST(search_code_scan_in_process_binary_and_crlf); RUN_TEST(search_code_scan_in_process_limits_and_failures); - RUN_TEST(search_code_scan_cancellation_precedes_zero_deadline); - RUN_TEST(search_code_scan_deadline_precedes_output_limit); - RUN_TEST(search_code_scan_hook_rejection_is_contained_and_cleans_up); RUN_TEST(search_code_scratch_creation_error_releases_path_filter); RUN_TEST(search_code_scoped_exit_one_is_not_no_match); RUN_TEST(search_code_no_match_is_empty_for_direct_and_scoped_routes); @@ -29365,22 +29358,9 @@ SUITE(mcp) { RUN_TEST(tool_index_repository_unknown_project_name_still_requires_repo_path); RUN_TEST(tool_index_repository_dot_uses_absolute_project_key_and_preserves_adr); RUN_TEST(index_repository_relative_path_uses_explicit_session_root); - RUN_TEST(index_repository_supervisor_uses_canonical_session_path); RUN_TEST(index_repository_cli_name_override_issue823); RUN_TEST(index_repository_over_budget_reports_named_reason); - RUN_TEST(index_supervisor_unsafe_clean_is_never_fallback_or_recovery); - RUN_TEST(index_supervisor_gate_requires_marked_host_issue845); - RUN_TEST(index_supervisor_start_failure_is_fail_closed_in_real_host); - RUN_TEST(index_supervisor_clean_exit_without_response_response_issue1300); - RUN_TEST(index_worker_resource_limit_is_trusted_structured_and_not_retried); - RUN_TEST(index_worker_limit_never_reported_after_its_own_publication); - RUN_TEST(index_worker_resource_response_reports_preservation_for_the_request); - RUN_TEST(index_bg_paths_route_through_supervisor_issue832); RUN_TEST(sequential_service_edge_props_are_valid_json_issue898); - RUN_TEST(index_second_inprocess_run_survives_issue773); - RUN_TEST(index_recovery_parallel_quarantines_crasher); - RUN_TEST(index_recovery_quarantines_exit_nonzero); - RUN_TEST(index_recovery_systemic_exit_nonzero_gives_up); RUN_TEST(tool_manage_adr_not_found_rich_error); RUN_TEST(tool_manage_adr_get_accepts_abs_path); RUN_TEST(tool_manage_adr_get_accepts_symlink_path); @@ -29441,11 +29421,6 @@ SUITE(mcp) { RUN_TEST(parse_file_uri_null_out_path); RUN_TEST(parse_file_uri_zero_size); - /* Poll/getline FILE* buffering fix */ -#ifndef _WIN32 - RUN_TEST(mcp_server_run_rapid_messages); -#endif - /* Snippet resolution (port of snippet_test.go) */ RUN_TEST(snippet_exact_qn); RUN_TEST(snippet_doc_candidates_both_directions); @@ -29473,7 +29448,6 @@ SUITE(mcp) { /* auto_watch gate (distilled from PR #625) */ RUN_TEST(mcp_auto_watch_default_registers_watcher_on_connect); RUN_TEST(mcp_auto_watch_false_skips_watcher_on_connect); - RUN_TEST(mcp_auto_watch_false_skips_supervised_autoindex_issue853); RUN_TEST(autoindex_skip_reports_numeric_limit_issue1466); RUN_TEST(autoindex_limit_guards_non_git_root_issue713); RUN_TEST(autoindex_limit_admits_non_git_root_under_limit_issue713); @@ -29502,6 +29476,36 @@ SUITE(mcp) { RUN_TEST(search_code_drops_walker_hits_that_resolve_outside_root); } +/* Subprocess, fork, supervisor, recovery, and deadline-sensitive MCP tests. + * Kept separate from the ~400 pure in-process tests in SUITE(mcp) so `mcp` + * runs in the full parallel wave while these run in the quiet FLEX tail. */ +SUITE(mcp_supervisor) { + RUN_TEST(search_code_cancel_cleans_supervised_scan); + RUN_TEST(search_code_scan_deadline_fails_closed_and_resets); + RUN_TEST(search_code_scan_deadline_override_is_per_server); + RUN_TEST(search_code_scan_live_child_deadline_is_bounded_and_fails_closed); + RUN_TEST(search_code_scan_cancellation_precedes_zero_deadline); + RUN_TEST(search_code_scan_deadline_precedes_output_limit); + RUN_TEST(search_code_scan_hook_rejection_is_contained_and_cleans_up); + RUN_TEST(index_repository_supervisor_uses_canonical_session_path); + RUN_TEST(index_supervisor_unsafe_clean_is_never_fallback_or_recovery); + RUN_TEST(index_supervisor_gate_requires_marked_host_issue845); + RUN_TEST(index_supervisor_start_failure_is_fail_closed_in_real_host); + RUN_TEST(index_supervisor_clean_exit_without_response_response_issue1300); + RUN_TEST(index_worker_resource_limit_is_trusted_structured_and_not_retried); + RUN_TEST(index_worker_limit_never_reported_after_its_own_publication); + RUN_TEST(index_worker_resource_response_reports_preservation_for_the_request); + RUN_TEST(index_bg_paths_route_through_supervisor_issue832); + RUN_TEST(index_second_inprocess_run_survives_issue773); + RUN_TEST(index_recovery_parallel_quarantines_crasher); + RUN_TEST(index_recovery_quarantines_exit_nonzero); + RUN_TEST(index_recovery_systemic_exit_nonzero_gives_up); + RUN_TEST(mcp_auto_watch_false_skips_supervised_autoindex_issue853); +#ifndef _WIN32 + RUN_TEST(mcp_server_run_rapid_messages); +#endif +} + /* Kept separate so daemon-coordination regressions can be iterated without * running the much larger MCP behavior suite. */ SUITE(mcp_mutation_guard) { diff --git a/tests/test_pipeline.c b/tests/test_pipeline.c index 785895ec82..dc068d8ac5 100644 --- a/tests/test_pipeline.c +++ b/tests/test_pipeline.c @@ -40272,6 +40272,12 @@ SUITE(pipeline) { RUN_TEST(pipeline_jvm_tail_lookup_work_grows_linearly); RUN_TEST(pipeline_needs_engine_lookup_work_grows_linearly); RUN_TEST(pipeline_kotlin_operator_lookup_work_grows_linearly); +} + +/* Second half of SUITE(pipeline), split at the ~50%-runtime boundary so both + * halves execute concurrently across CI shards and TSan Phase 1 without + * leaving a single long-tail pipeline process on Windows/MSan/TSan. */ +SUITE(pipeline_d) { RUN_TEST(pipeline_lsp_index_find_agrees_with_the_matcher); RUN_TEST(pipeline_lsp_index_built_without_tail_asks_the_matcher); RUN_TEST(pipeline_lsp_index_own_caller_disagreement_ends_the_lookup); @@ -40493,6 +40499,11 @@ SUITE(pipeline_b) { RUN_TEST(pipeline_python_base_rebound_in_compound_class_is_a_stated_limit_parallel); RUN_TEST(pipeline_python_base_type_checking_import_binds_nothing); RUN_TEST(pipeline_python_base_type_checking_import_binds_nothing_parallel); +} + +/* Third slice of the pipeline suite, split at the ~50%-runtime boundary of + * pipeline_b so each slice stays well under ~200s on Windows ASan shards. */ +SUITE(pipeline_c) { RUN_TEST(pipeline_python_base_type_checking_reimport_is_matched_by_position); RUN_TEST(pipeline_python_base_type_checking_reimport_is_matched_by_position_parallel); RUN_TEST(pipeline_python_base_type_checking_import_dropped_from_the_list); @@ -40852,6 +40863,11 @@ SUITE(pipeline_semantic_manifest_repro) { RUN_TEST(helm_parse_error_spoils); RUN_TEST(helm_captures_after_a_huge_capture); RUN_TEST(helm_includes_of_one_name_in_a_loop); +} + +/* Second half of pipeline_semantic_manifest_repro, split for parallel + * scheduling parity across CI shards. */ +SUITE(pipeline_semantic_manifest_repro_b) { RUN_TEST(incremental_compose_dotenv_change_rebuilds); RUN_TEST(incremental_dockerfile_edit_keeps_docker_build_edges); RUN_TEST(incremental_second_build_declarer_keeps_the_edge); diff --git a/tests/test_stack_overflow.c b/tests/test_stack_overflow.c index 8402b0f683..081a3ef94a 100644 --- a/tests/test_stack_overflow.c +++ b/tests/test_stack_overflow.c @@ -11,6 +11,7 @@ */ #include "test_framework.h" #include "cbm.h" +#include "foundation/compat.h" #include "lang_specs.h" /* cbm_ts_language — direct-parse GLR cap regression (#913) */ #include "lsp/ts_lsp.h" @@ -460,16 +461,57 @@ static void so_parse_alarm_exit(int sig) { * the extract-level guard skips pathologically nested Perl before it reaches the * parser, so only a direct parse exercises the cap. Windows runs in-process (a * real crash aborts the runner — a visible failure), mirroring so_extract_crashes. */ +#if defined(_WIN32) +typedef struct { + const char *data; + uint32_t length; +} so_win_input_t; + +static const char *so_win_input_read(void *payload, uint32_t byte_index, TSPoint position, + uint32_t *bytes_read) { + (void)position; + const so_win_input_t *in = (const so_win_input_t *)payload; + if (byte_index >= in->length) { + *bytes_read = 0; + return NULL; + } + *bytes_read = in->length - byte_index; + return in->data + byte_index; +} + +static bool so_win_parse_deadline_reached(TSParseState *state) { + const uint64_t *deadline_ms = (const uint64_t *)state->payload; + return cbm_now_ms() >= *deadline_ms; +} +#endif + static bool so_parse_crashes(const char *content, CBMLanguage lang) { const TSLanguage *ts_lang = cbm_ts_language(lang); if (!ts_lang) { return false; } #if defined(_WIN32) + /* Match POSIX's 10 s ceiling: when CBM_TS_STACK_MERGE_MAX_DEPTH regresses, + * recursive stack merge overflows Windows' ~1 MB native stack within the + * first second and aborts immediately; past the cap, cancelling the + * ambiguity-exploded GLR grind at 10 s keeps Windows coverage identical to + * POSIX without burning ~200 s of pointless post-cap grind. */ TSParser *parser = ts_parser_new(); if (parser) { ts_parser_set_language(parser, ts_lang); - TSTree *tree = ts_parser_parse_string(parser, NULL, content, (uint32_t)strlen(content)); + so_win_input_t input_buf = {.data = content, .length = (uint32_t)strlen(content)}; + TSInput input = { + .payload = &input_buf, + .read = so_win_input_read, + .encoding = TSInputEncodingUTF8, + .decode = NULL, + }; + uint64_t deadline_ms = cbm_now_ms() + 10000U; + TSParseOptions options = { + .payload = &deadline_ms, + .progress_callback = so_win_parse_deadline_reached, + }; + TSTree *tree = ts_parser_parse_with_options(parser, NULL, input, options); if (tree) { ts_tree_delete(tree); } @@ -901,8 +943,6 @@ SUITE(stack_overflow_b) { RUN_TEST(lsp_ts_inherited_method_lookup); RUN_TEST(lsp_python_deep_nesting_no_crash); RUN_TEST(lsp_go_deep_nesting_no_crash); - RUN_TEST(lsp_php_deep_nesting_no_crash); - RUN_TEST(lsp_kotlin_deep_nesting_no_crash); cbm_shutdown(); } @@ -910,6 +950,8 @@ SUITE(stack_overflow_b) { SUITE(stack_overflow_c) { cbm_init(); + RUN_TEST(lsp_php_deep_nesting_no_crash); + RUN_TEST(lsp_kotlin_deep_nesting_no_crash); RUN_TEST(js_calls_exceed_512); RUN_TEST(python_calls_exceed_512); RUN_TEST(go_calls_exceed_1024); diff --git a/tests/test_test_impact_git.c b/tests/test_test_impact_git.c index 4f9fe1cc2b..ad8e830ed4 100644 --- a/tests/test_test_impact_git.c +++ b/tests/test_test_impact_git.c @@ -2,12 +2,15 @@ * No implementation helpers or command-count assumptions are used. */ #include "test_framework.h" #include "test_helpers.h" +#include "test_image_probe.h" #include #include +#include #include #include #include #include +#include #include enum { GF_PATH = 4096, GF_SMALL = 512 }; @@ -254,18 +257,66 @@ static bool gf_config(gf_fixture_t *fx, const char *key, const char *value) { return gf_git(fx, argv, NULL, 0); } -/* A--P---M(topic/HEAD) - * \ / - * Q--+--B(base) - * merge-base(M,B)=Q, which deliberately differs from first-parent(M)=P. - * Raw commit objects give fixed timestamps/identities without changing env. */ -static bool gf_fixture_open(gf_fixture_t *fx, bool sha256) { +/* Cache the immutable base repository (once for SHA-1 and once for SHA-256 per + * test-runner process) so every test gets its own fresh, isolated copy in <1ms + * instead of spawning 53 git subprocesses ~50 times (~2,600 spawns/run). */ +typedef struct { + bool ready; + gf_fixture_t base; +} gf_template_t; + +static gf_template_t gf_templates[2]; +static bool gf_atexit_registered; + +static void gf_cleanup_templates(void) { + for (int i = 0; i < 2; i++) { + if (gf_templates[i].base.home[0]) { + (void)th_rmtree(gf_templates[i].base.home); + gf_templates[i].base.home[0] = '\0'; + } + gf_templates[i].ready = false; + } +} + +static bool gf_copy_tree(const char *src, const char *dst, int depth) { + if (depth > 16 || th_mkdir_p(dst) != 0) { + return false; + } + cbm_dir_t *dir = cbm_opendir(src); + if (!dir) { + return false; + } + char *child_src = malloc(GF_PATH); + char *child_dst = malloc(GF_PATH); + bool ok = child_src != NULL && child_dst != NULL; + cbm_dirent_t *ent; + while (ok && (ent = cbm_readdir(dir)) != NULL) { + if (strcmp(ent->name, ".") == 0 || strcmp(ent->name, "..") == 0) { + continue; + } + ok = gf_path(child_src, src, ent->name) && gf_path(child_dst, dst, ent->name); + if (!ok) { + break; + } + if (ent->is_dir) { + ok = gf_copy_tree(child_src, child_dst, depth + 1); + } else { + ok = cbm_clone_or_copy_file(child_src, child_dst) == 0; + } + } + free(child_src); + free(child_dst); + cbm_closedir(dir); + return ok; +} + +static bool gf_fixture_build_raw(gf_fixture_t *fx, bool sha256, const char *prefix) { memset(fx, 0, sizeof(*fx)); const char *resolved = cbm_find_cli("git", cbm_get_home_dir()); if (!resolved || !gf_absolute(resolved) || strlen(resolved) >= sizeof(fx->git)) return false; memcpy(fx->git, resolved, strlen(resolved) + 1); - const char *home = th_mktempdir("cbm-git-facts"); + const char *home = th_mktempdir(prefix); if (!home || strlen(home) >= sizeof(fx->home)) return false; memcpy(fx->home, home, strlen(home) + 1); @@ -305,6 +356,42 @@ static bool gf_fixture_open(gf_fixture_t *fx, bool sha256) { fprintf(stderr, "Git facts fixture setup failed (%s, native Git: %s)\n", sha256 ? "required SHA-256" : "SHA-1", fx->git); (void)th_rmtree(fx->home); + fx->home[0] = '\0'; + } + return ok; +} + +/* A--P---M(topic/HEAD) + * \ / + * Q--+--B(base) + * merge-base(M,B)=Q, which deliberately differs from first-parent(M)=P. + * Raw commit objects give fixed timestamps/identities without changing env. */ +static bool gf_fixture_open(gf_fixture_t *fx, bool sha256) { + int slot = sha256 ? 1 : 0; + if (!gf_templates[slot].ready) { + if (!gf_fixture_build_raw(&gf_templates[slot].base, sha256, "cbm-git-facts-tpl")) { + return false; + } + gf_templates[slot].ready = true; + if (!gf_atexit_registered) { + (void)atexit(gf_cleanup_templates); + gf_atexit_registered = true; + } + } + *fx = gf_templates[slot].base; + fx->home[0] = '\0'; + const char *home = th_mktempdir("cbm-git-facts"); + if (!home || strlen(home) >= sizeof(fx->home)) + return false; + memcpy(fx->home, home, strlen(home) + 1); + bool ok = gf_path(fx->repo, fx->home, "repo") && gf_path(fx->capture, fx->home, "stdout.bin") && + gf_path(fx->log, fx->home, "stderr.log") && + gf_path(fx->object_file, fx->home, "object.bin") && + gf_copy_tree(gf_templates[slot].base.repo, fx->repo, 0) && + gf_config(fx, "core.worktree", fx->repo); + if (!ok) { + (void)th_rmtree(fx->home); + fx->home[0] = '\0'; } return ok; } @@ -640,7 +727,7 @@ TEST(test_git_facts_required_sha256_objects_and_identity) { TEST(test_git_facts_never_runs_external_diff_or_textconv) { gf_fixture_t fx; ASSERT_TRUE(gf_fixture_open(&fx, false)); - char binary[GF_PATH], marker[GF_PATH], command[GF_PATH * 3]; + char binary[GF_PATH], marker[GF_PATH], command[GF_PATH * 3], probe_src[GF_PATH]; bool prepared = gf_path(binary, fx.home, #ifdef _WIN32 "diff-probe.exe" @@ -648,11 +735,12 @@ TEST(test_git_facts_never_runs_external_diff_or_textconv) { "diff-probe" #endif ) && - gf_path(marker, fx.home, "driver-invoked") && gf_runner_binary; + gf_path(marker, fx.home, "driver-invoked") && + th_image_probe_path(probe_src, sizeof(probe_src)); if (prepared) { cbm_normalize_path_sep(binary); cbm_normalize_path_sep(marker); - prepared = cbm_copy_file(gf_runner_binary, binary) == 0; + prepared = cbm_clone_or_copy_file(probe_src, binary) == 0; } if (prepared) th_make_executable(binary); @@ -1712,15 +1800,22 @@ TEST(test_git_ancestor_changes_history_and_external_driver_guards_apply) { } ASSERT_TRUE(gfa_topology_stays_pinned()); gf_fixture_t fx;ASSERT_TRUE(gf_fixture_open(&fx,false)); - char binary[GF_PATH],marker[GF_PATH],command[GF_PATH*3],attributes_path[GF_PATH]; - bool prepared=gf_path(binary,fx.home, + char binary[GF_PATH], marker[GF_PATH], command[GF_PATH * 3], attributes_path[GF_PATH], + probe_src[GF_PATH]; + bool prepared = gf_path(binary, fx.home, #ifdef _WIN32 - "ancestor-diff-probe.exe" + "ancestor-diff-probe.exe" #else - "ancestor-diff-probe" + "ancestor-diff-probe" #endif - ) && gf_path(marker,fx.home,"ancestor-driver-invoked") && gf_runner_binary; - if(prepared){cbm_normalize_path_sep(binary);cbm_normalize_path_sep(marker);prepared=cbm_copy_file(gf_runner_binary,binary)==0;} + ) && + gf_path(marker, fx.home, "ancestor-driver-invoked") && + th_image_probe_path(probe_src, sizeof(probe_src)); + if (prepared) { + cbm_normalize_path_sep(binary); + cbm_normalize_path_sep(marker); + prepared = cbm_clone_or_copy_file(probe_src, binary) == 0; + } if(prepared)th_make_executable(binary); const char attributes[]="p.txt diff=fixturetrap\n"; prepared=prepared && gf_path(attributes_path,fx.repo,".gitattributes") && gf_write(attributes_path,attributes,sizeof(attributes)-1) && gf_driver_command(command,sizeof(command),binary,marker); @@ -2452,6 +2547,11 @@ SUITE(test_impact_git) { RUN_TEST(test_git_facts_rejects_local_shallow_state); RUN_TEST(test_git_facts_rejects_history_override_added_after_open); RUN_TEST(test_git_facts_cancellation_after_open_is_latched); +} + +/* Second half of test_impact_git (ancestor_changes and blob_batch cases), + * split so both halves run concurrently across workers and shards. */ +SUITE(test_impact_git_b) { RUN_TEST(test_git_ancestor_changes_requires_ancestor_of_actual_merge_base); RUN_TEST(test_git_ancestor_changes_preserves_earlier_paths_reversion_and_pinned_head); RUN_TEST(test_git_ancestor_changes_equalities_and_empty_reversion_are_distinct); @@ -2462,6 +2562,12 @@ SUITE(test_impact_git) { RUN_TEST(test_git_ancestor_changes_output_and_cumulative_limits_publish_no_prefix); RUN_TEST(test_git_ancestor_changes_repeated_calls_share_existing_command_budget); RUN_TEST(test_git_ancestor_changes_history_and_external_driver_guards_apply); +} + +/* Third slice of test_impact_git (blob_batch cases), split at the ~50%-runtime + * boundary from ancestor_changes so both run concurrently across workers and + * macOS/LSan/Windows CI shards. */ +SUITE(test_impact_git_c) { RUN_TEST(test_git_blob_batch_native_bytes_and_both_object_formats); RUN_TEST(test_git_blob_batch_keeps_request_order_duplicates_and_raw_paths); RUN_TEST(test_git_blob_batch_pinned_revisions_and_cache_history_guards);