model_test_context.h

tests/model/model_test_context.h

@file model_test_context.h @brief Shared infrastructure for model tests (subsystem + engine).

Owners: @tvanfossen

testCaseStarting

void VramMonitorListener::testCaseStarting(Catch::TestCaseInfo const &) override

Snapshot VRAM before test.

tests/model/model_test_context.h:899

Show on the map →

Called by none

Calls query_vram_bytes

Result: absent

Verifies

requirementlinkedpath to the implementer
REQ-INFER-020inferred
Source · 3 lines
    void testCaseStarting(Catch::TestCaseInfo const& /*tc*/) override {
        vram_before_ = query_vram_bytes();
    }
Activity · 1 steps
lines 900–900vram_before_ = query_vram_bytes();

testRunEnded

void VramMonitorListener::testRunEnded(Catch::TestRunStats const &) override

Note where the logs went.

tests/model/model_test_context.h:931

Show on the map →

Called by none

Tested by

1 teststestRunEnded

Calls none

Result: absent

Verifies

requirementlinkedpath to the implementer
REQ-INFER-002inferred
REQ-INFER-020inferred
Source · 3 lines
    void testRunEnded(Catch::TestRunStats const& /*stats*/) override {
        spdlog::info("Model tests complete — logs in {}", LOG_DIR.string());
    }
Activity · 1 steps
lines 932–932spdlog::info("Model tests complete — logs in {}", LOG_DIR.string());
void ModelTestListener::testRunEnded(Catch::TestRunStats const &stats) override

Unload model after run.

tests/model/model_test_context.h:980

Result: absent

Verifies

requirementlinkedpath to the implementer
REQ-INFER-002inferredtestRunEnded → shutdown
REQ-INFER-020inferredtestRunEnded → shutdown
Source · 10 lines
    void testRunEnded(Catch::TestRunStats const& stats) override {
        // v2.14.6: release the production iface context before the
        // orchestrator it points at shuts down.
        destroy_orchestrator_interface(g_ctx.iface_ctx);
        g_ctx.iface_ctx = nullptr;
        if (g_ctx.orchestrator) {
            g_ctx.orchestrator->shutdown();
        }
        VramMonitorListener::testRunEnded(stats);
    }
Activity · 5 steps
lines 983–983destroy_orchestrator_interface(g_ctx.iface_ctx);lines 984–984g_ctx.iface_ctx = nullptr;lines 985–985◇ if (g_ctx.orchestrator)lines 986–986g_ctx.orchestrator->shutdown();lines 988–988VramMonitorListener::testRunEnded(stats);

testRunStarting

void VramMonitorListener::testRunStarting(Catch::TestRunInfo const &) override

Ensure the log directory exists before any case writes to it.

tests/model/model_test_context.h:889

Show on the map →

Called by none

Tested by

1 teststestRunStarting

Calls none

Result: absent

Verifies

requirementlinkedpath to the implementer
REQ-API-004inferred
REQ-API-013inferred
REQ-CFG-001inferred
REQ-CFG-002inferred
REQ-CFG-003inferred
REQ-CFG-005inferred
REQ-CFG-006inferred
REQ-CFG-007inferred
REQ-CFG-008inferred
REQ-DELEG-005inferred
REQ-INFER-002inferred
REQ-INFER-007inferred
REQ-INFER-012inferred
REQ-INFER-019inferred
REQ-INFER-020inferred
REQ-INFER-023inferred
REQ-INFER-027inferred
REQ-MCP-021inferred
REQ-MCP-023inferred
REQ-TYPE-005inferred
Source · 3 lines
    void testRunStarting(Catch::TestRunInfo const& /*info*/) override {
        fs::create_directories(LOG_DIR);
    }
Activity · 1 steps
lines 890–890fs::create_directories(LOG_DIR);
void ModelTestListener::testRunStarting(Catch::TestRunInfo const &info) override

Load model before test run.

tests/model/model_test_context.h:957

Show on the map →

Called by none

Calls adjust_config, info, init_orchestrator, load_harness_inputs, testRunStarting, use_small_default_model

Result: absent

Verifies

requirementlinkedpath to the implementer
REQ-API-004inferred
REQ-API-013inferred
REQ-CFG-001inferredtestRunStarting → load_harness_inputs → load_test_config → load_config
REQ-CFG-002inferredtestRunStarting → load_harness_inputs → load_test_config → load_config → load_config_layers → parse_config_file → parse_top_sections → parse_models_config
REQ-CFG-003inferredtestRunStarting → use_small_default_model → resolve
REQ-CFG-005inferredtestRunStarting → load_harness_inputs → load_test_config → load_config → load_config_layers → parse_config_file → parse_top_sections → parse_models_config → parse_model_config
REQ-CFG-006inferredtestRunStarting → load_harness_inputs → load_test_config → load_config
REQ-CFG-007inferredtestRunStarting → load_harness_inputs → load_test_config → load_config
REQ-CFG-008inferredtestRunStarting → load_harness_inputs → load_test_config → load_config → load_config_layers → load_bundled_default → resolve_data_dir
REQ-DELEG-005inferredtestRunStarting → load_harness_inputs → load_test_config → load_config → load_config_layers → parse_config_file → parse_top_sections → parse_optional_sections → parse_delegation_config
REQ-INFER-002inferredtestRunStarting → init_orchestrator → initialize → activate_router → ensure_loaded → load_and_activate
REQ-INFER-007inferredtestRunStarting → init_orchestrator → load_grammars_from → load_bundled
REQ-INFER-012inferredtestRunStarting → init_orchestrator → initialize → create_tier_backends → create_adapter
REQ-INFER-019inferredtestRunStarting → init_orchestrator → initialize → ensure_vram_budget
REQ-INFER-020inferredtestRunStarting → init_orchestrator → initialize → build_routing_tables
REQ-INFER-023inferredtestRunStarting → init_orchestrator → initialize → activate_default_tier → get_model → activate_and_track → preload_adapters_for_model
REQ-INFER-027inferredtestRunStarting → load_harness_inputs → load_test_config → load_config → validate_config → validate
REQ-MCP-021inferredtestRunStarting → load_harness_inputs → load_test_config → load_config → load_config_layers → parse_config_file → parse_top_sections → parse_optional_sections → parse_optional_subsections → parse_mcp_config → parse_absolute_path_list
REQ-MCP-023inferredtestRunStarting → load_harness_inputs → load_test_config → load_config → load_config_layers → parse_config_file → parse_top_sections → parse_optional_sections → parse_optional_subsections → parse_mcp_config → parse_mcp_sections → parse_bash_config
REQ-TYPE-005inferredtestRunStarting → load_harness_inputs → load_test_config → load_config → load_config_layers → parse_config_file
Source · 16 lines
    void testRunStarting(Catch::TestRunInfo const& info) override {
        VramMonitorListener::testRunStarting(info);
        spdlog::info("Loading model for model tests...");
        // gh#149: load_harness_inputs records WHICH setup step failed
        // instead of collapsing both into one bool.
        bool ok = load_harness_inputs(g_ctx, "the generic test model");
        // gh#87: generic engine-logic tests use a small model (footprint /
        // OOM safety). Family tests use init_orchestrator_for_v219_* and keep
        // their large models — they do NOT go through this listener.
        if (ok) { use_small_default_model(g_ctx); adjust_config(g_ctx); }
        ok = ok && init_orchestrator(g_ctx);
        if (!ok) {
            spdlog::error("Model test init failed — tests will skip: {}",
                          g_ctx.skip_reason);
        }
    }
Activity · 9 steps
lines 958–958VramMonitorListener::testRunStarting(info);lines 959–959spdlog::info("Loading model for model tests...");lines 962–962bool ok = load_harness_inputs(g_ctx, "the generic test model");lines 966–966◇ if (ok)lines 966–966use_small_default_model(g_ctx);lines 966–966adjust_config(g_ctx);lines 967–967ok = ok && init_orchestrator(g_ctx);lines 968–968◇ if (!ok)lines 969–970spdlog::error("Model test init failed — tests will skip: {}", g_ctx.skip_reason);