MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / sh_struct_battery

Function sh_struct_battery

tests/repro/repro_grammar_shells.c:184–245  ·  view source on GitHub ↗

── Shared single-file battery: structural with defs (dims 1-5) ──────────── * * Adds defs-present for the structural-with-defs languages (SMALI, KCONFIG). * Pass NULL for expect_label2/expect_label3 when fewer labels are needed. * Returns 0 on PASS. */

Source from the content-addressed store, hash-verified

182 * Returns 0 on PASS.
183 */
184static int sh_struct_battery(const char *lang_tag, const char *src, CBMLanguage lang,
185 const char *file, const char *expect_label,
186 const char *expect_label2, const char *expect_label3) {
187 const char *RED = tf_red();
188 const char *RST = tf_reset();
189
190 if (inv_extract_clean(src, lang, file) != 1) {
191 printf(" %sFAIL%s [%s] extract-clean: NULL result or has_error set\n",
192 RED, RST, lang_tag);
193 return 1;
194 }
195
196 CBMFileResult *r = inv_rx(src, lang, file);
197 if (!r) {
198 printf(" %sFAIL%s [%s] inv_rx returned NULL after clean extract\n",
199 RED, RST, lang_tag);
200 return 1;
201 }
202
203 int fails = 0;
204
205 int bad_labels = inv_count_bad_labels(r);
206 if (bad_labels != 0) {
207 printf(" %sFAIL%s [%s] labels-valid: %d def(s) with invalid label\n",
208 RED, RST, lang_tag, bad_labels);
209 fails++;
210 }
211
212 int bad_fqns = inv_count_bad_fqns(r);
213 if (bad_fqns != 0) {
214 printf(" %sFAIL%s [%s] fqn-wellformed: %d def(s) with malformed QN\n",
215 RED, RST, lang_tag, bad_fqns);
216 fails++;
217 }
218
219 int bad_ranges = inv_count_bad_ranges(r);
220 if (bad_ranges != 0) {
221 printf(" %sFAIL%s [%s] ranges-valid: %d def(s) with invalid range\n",
222 RED, RST, lang_tag, bad_ranges);
223 fails++;
224 }
225
226 /* 5. defs-present (up to three expected labels) */
227 if (expect_label && inv_count_label(r, expect_label) < 1) {
228 printf(" %sFAIL%s [%s] defs-present: no def labelled \"%s\"\n",
229 RED, RST, lang_tag, expect_label);
230 fails++;
231 }
232 if (expect_label2 && inv_count_label(r, expect_label2) < 1) {
233 printf(" %sFAIL%s [%s] defs-present: no def labelled \"%s\"\n",
234 RED, RST, lang_tag, expect_label2);
235 fails++;
236 }
237 if (expect_label3 && inv_count_label(r, expect_label3) < 1) {
238 printf(" %sFAIL%s [%s] defs-present: no def labelled \"%s\"\n",
239 RED, RST, lang_tag, expect_label3);
240 fails++;
241 }

Callers 1

Calls 9

tf_redFunction · 0.85
tf_resetFunction · 0.85
inv_extract_cleanFunction · 0.85
inv_rxFunction · 0.85
inv_count_bad_labelsFunction · 0.85
inv_count_bad_fqnsFunction · 0.85
inv_count_bad_rangesFunction · 0.85
inv_count_labelFunction · 0.85
cbm_free_resultFunction · 0.85

Tested by

no test coverage detected