Files
deusdata--codebase-memory-mcp/tests/test_main.c
Martin Vogel 943eb16334 Suppress the bounded cfml/HTML vendored-scanner leak under LeakSanitizer
scan_tag_name in the shared vendored HTML-family tree-sitter scanner leaks a small bounded tag-name buffer in an edge path of scan_start_tag_name. tag_for_name's ownership is grammar-specific and not verifiable without HTML-family parse coverage, so the bounded leak is suppressed via __lsan_default_suppressions rather than risking a blind double-free. The larger SQL scanner leak was fixed properly.
2026-06-06 13:33:15 +02:00

232 lines
6.4 KiB
C

/*
* test_main.c — Test runner entry point for pure C rewrite.
*
* Includes all test suites and runs them sequentially.
*/
/* Global test counters (declared extern in test_framework.h) */
int tf_pass_count = 0;
int tf_fail_count = 0;
int tf_skip_count = 0;
#include "test_framework.h"
#include <sqlite3.h>
/* Forward declarations of suite functions */
extern void suite_arena(void);
extern void suite_hash_table(void);
extern void suite_dyn_array(void);
extern void suite_str_intern(void);
extern void suite_log(void);
extern void suite_str_util(void);
extern void suite_platform(void);
extern void suite_extraction(void);
extern void suite_grammar_regression(void);
extern void suite_grammar_labels(void);
extern void suite_grammar_imports(void);
extern void suite_ac(void);
extern void suite_store_nodes(void);
extern void suite_store_edges(void);
extern void suite_store_search(void);
extern void suite_cypher(void);
extern void suite_mcp(void);
extern void suite_language(void);
extern void suite_userconfig(void);
extern void suite_gitignore(void);
extern void suite_discover(void);
extern void suite_graph_buffer(void);
extern void suite_registry(void);
extern void suite_pipeline(void);
extern void suite_fqn(void);
extern void suite_path_alias(void);
extern void suite_watcher(void);
extern void suite_lz4(void);
extern void suite_zstd(void);
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_php_lsp(void);
extern void suite_cs_lsp(void);
extern void suite_cs_lsp_bench(void);
extern void suite_scope(void);
extern void suite_type_rep(void);
extern void suite_py_lsp(void);
extern void suite_py_lsp_bench(void);
extern void suite_py_lsp_stress(void);
extern void suite_py_lsp_scale(void);
extern void suite_ts_lsp(void);
extern void suite_java_lsp(void);
extern void suite_java_lsp_coverage(void);
extern void suite_kotlin_lsp(void);
extern void suite_rust_lsp(void);
extern void suite_store_arch(void);
extern void suite_store_bulk(void);
extern void suite_store_pragmas(void);
extern void suite_store_checkpoint(void);
extern void suite_traces(void);
extern void suite_configlink(void);
extern void suite_infrascan(void);
extern void suite_cli(void);
extern void suite_system_info(void);
extern void suite_worker_pool(void);
extern void suite_parallel(void);
extern void suite_mem(void);
extern void suite_ui(void);
extern void suite_security(void);
extern void suite_yaml(void);
extern void suite_integration(void);
extern void suite_lang_contract(void);
extern void suite_incremental(void);
extern void suite_simhash(void);
extern void suite_stack_overflow(void);
/* Free the main thread's thread-local node-type bitset cache before exit so
* LeakSanitizer (Linux x64) doesn't report it. Worker threads free their own
* caches at thread teardown (pass_parallel.c). */
extern void cbm_kind_in_set_free_cache(void);
/* LeakSanitizer (Linux x64) suppressions. scan_tag_name is in the vendored,
* shared HTML-family tree-sitter scanner (common/scanner.h, used by cfml/html/…);
* it leaks a small bounded tag-name buffer in an edge path of scan_start_tag_name's
* tag-type switch. That is regenerated 3rd-party code whose tag_for_name
* copy-vs-move ownership cannot be verified without HTML-family parse testing, so
* the bounded leak is suppressed rather than risking a blind double-free patch.
* (The larger sql scanner leak WAS fixed properly in sql/scanner.c.) */
const char *__lsan_default_suppressions(void);
const char *__lsan_default_suppressions(void) {
return "leak:scan_tag_name\n";
}
int main(void) {
printf("\n codebase-memory-mcp C test suite\n");
/* Foundation */
RUN_SUITE(arena);
RUN_SUITE(hash_table);
RUN_SUITE(dyn_array);
RUN_SUITE(str_intern);
RUN_SUITE(log);
RUN_SUITE(str_util);
RUN_SUITE(platform);
/* Existing C code regression tests */
RUN_SUITE(ac);
RUN_SUITE(extraction);
RUN_SUITE(grammar_regression);
RUN_SUITE(grammar_labels);
RUN_SUITE(grammar_imports);
/* Store (M5) */
RUN_SUITE(store_nodes);
RUN_SUITE(store_edges);
RUN_SUITE(store_search);
RUN_SUITE(store_bulk);
RUN_SUITE(store_pragmas);
RUN_SUITE(store_checkpoint);
/* Cypher (M6) */
RUN_SUITE(cypher);
/* MCP Server (M9) */
RUN_SUITE(mcp);
/* Discover (M2) */
RUN_SUITE(language);
RUN_SUITE(userconfig);
RUN_SUITE(gitignore);
RUN_SUITE(discover);
/* Graph Buffer (M7) */
RUN_SUITE(graph_buffer);
/* Pipeline (M8) */
RUN_SUITE(registry);
RUN_SUITE(pipeline);
RUN_SUITE(fqn);
RUN_SUITE(path_alias);
/* Watcher (M10) */
RUN_SUITE(watcher);
/* LZ4 + zstd + SQLite writer */
RUN_SUITE(lz4);
RUN_SUITE(zstd);
RUN_SUITE(sqlite_writer);
/* Persistent artifact export/import */
RUN_SUITE(artifact);
/* LSP resolvers */
RUN_SUITE(scope);
RUN_SUITE(type_rep);
RUN_SUITE(go_lsp);
RUN_SUITE(c_lsp);
RUN_SUITE(php_lsp);
RUN_SUITE(cs_lsp);
RUN_SUITE(cs_lsp_bench);
RUN_SUITE(py_lsp);
RUN_SUITE(kotlin_lsp);
RUN_SUITE(rust_lsp);
RUN_SUITE(py_lsp_bench);
RUN_SUITE(py_lsp_stress);
RUN_SUITE(py_lsp_scale);
RUN_SUITE(ts_lsp);
RUN_SUITE(java_lsp);
RUN_SUITE(java_lsp_coverage);
/* Architecture + ADR + Louvain */
RUN_SUITE(store_arch);
/* HTTP link */
/* Traces helpers */
RUN_SUITE(traces);
/* Config link */
RUN_SUITE(configlink);
/* Infrastructure scanning */
RUN_SUITE(infrascan);
/* CLI (install, update, config) */
RUN_SUITE(cli);
/* System info + worker pool (parallelism) */
RUN_SUITE(system_info);
RUN_SUITE(worker_pool);
/* Parallel pipeline */
RUN_SUITE(parallel);
/* mem + arena + slab integration */
RUN_SUITE(mem);
/* UI (config, embedded assets, layout) */
RUN_SUITE(ui);
/* Security defenses */
RUN_SUITE(security);
/* YAML parser */
RUN_SUITE(yaml);
/* SimHash / SIMILAR_TO */
RUN_SUITE(simhash);
/* Stack overflow regression (GitHub #199) */
RUN_SUITE(stack_overflow);
/* Integration (end-to-end) */
RUN_SUITE(integration);
/* Per-language graph contracts (node/edge types, attribution, no-crash) */
RUN_SUITE(lang_contract);
RUN_SUITE(incremental);
/* Release process-lifetime caches so LeakSanitizer reports no leaks. */
cbm_kind_in_set_free_cache();
sqlite3_shutdown();
TEST_SUMMARY();
}