Run one tool call on the fixture server, apply the explosion detector and * an absolute byte ceiling, and require a semantic-floor marker so trimming * can never hollow the response out either. */
| 2384 | * an absolute byte ceiling, and require a semantic-floor marker so trimming |
| 2385 | * can never hollow the response out either. */ |
| 2386 | static const char *check_tool_output(cbm_mcp_server_t *srv, const char *req, int ceiling, |
| 2387 | const char *floor_marker) { |
| 2388 | char *resp = cbm_mcp_server_handle(srv, req); |
| 2389 | if (!resp) { |
| 2390 | return "no response"; |
| 2391 | } |
| 2392 | char *inner = extract_text_content(resp); |
| 2393 | free(resp); |
| 2394 | if (!inner) { |
| 2395 | return "no text content"; |
| 2396 | } |
| 2397 | static char why[256]; |
| 2398 | const char *smell = output_explosion_smell(inner); |
| 2399 | if (smell) { |
| 2400 | snprintf(why, sizeof(why), "%s", smell); |
| 2401 | free(inner); |
| 2402 | return why; |
| 2403 | } |
| 2404 | if ((int)strlen(inner) >= ceiling) { |
| 2405 | snprintf(why, sizeof(why), "output %d B >= ceiling %d B", (int)strlen(inner), ceiling); |
| 2406 | free(inner); |
| 2407 | return why; |
| 2408 | } |
| 2409 | if (floor_marker && !strstr(inner, floor_marker)) { |
| 2410 | snprintf(why, sizeof(why), "semantic floor missing: %s", floor_marker); |
| 2411 | free(inner); |
| 2412 | return why; |
| 2413 | } |
| 2414 | free(inner); |
| 2415 | return NULL; |
| 2416 | } |
| 2417 | |
| 2418 | TEST(tool_output_regression_gate) { |
| 2419 | char tmp[256]; |
no test coverage detected