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. */
| 4129 | * an absolute byte ceiling, and require a semantic-floor marker so trimming |
| 4130 | * can never hollow the response out either. */ |
| 4131 | static const char *check_tool_output(cbm_mcp_server_t *srv, const char *req, int ceiling, |
| 4132 | const char *floor_marker) { |
| 4133 | char *resp = cbm_mcp_server_handle(srv, req); |
| 4134 | if (!resp) { |
| 4135 | return "no response"; |
| 4136 | } |
| 4137 | char *inner = extract_text_content(resp); |
| 4138 | free(resp); |
| 4139 | if (!inner) { |
| 4140 | return "no text content"; |
| 4141 | } |
| 4142 | static char why[256]; |
| 4143 | const char *smell = output_explosion_smell(inner); |
| 4144 | if (smell) { |
| 4145 | snprintf(why, sizeof(why), "%s", smell); |
| 4146 | free(inner); |
| 4147 | return why; |
| 4148 | } |
| 4149 | if ((int)strlen(inner) >= ceiling) { |
| 4150 | snprintf(why, sizeof(why), "output %d B >= ceiling %d B", (int)strlen(inner), ceiling); |
| 4151 | free(inner); |
| 4152 | return why; |
| 4153 | } |
| 4154 | if (floor_marker && !strstr(inner, floor_marker)) { |
| 4155 | snprintf(why, sizeof(why), "semantic floor missing: %s", floor_marker); |
| 4156 | free(inner); |
| 4157 | return why; |
| 4158 | } |
| 4159 | free(inner); |
| 4160 | return NULL; |
| 4161 | } |
| 4162 | |
| 4163 | TEST(tool_output_regression_gate) { |
| 4164 | char tmp[256]; |
no test coverage detected