Check that paths[] contains exactly the expected file suffixes, once each. * Returns 1 if all expected suffixes appear exactly once, 0 otherwise. * Prints a diagnostic on mismatch. */
| 283 | * Returns 1 if all expected suffixes appear exactly once, 0 otherwise. |
| 284 | * Prints a diagnostic on mismatch. */ |
| 285 | static int check_sources_exact(char **paths, int count, |
| 286 | const char **expected, int nexpected) { |
| 287 | if (count != nexpected) { |
| 288 | printf(" source count %d != expected %d\n", count, nexpected); |
| 289 | for (int i = 0; i < count; i++) { |
| 290 | printf(" got: %s\n", paths[i] ? paths[i] : "(null)"); |
| 291 | } |
| 292 | return 0; |
| 293 | } |
| 294 | for (int e = 0; e < nexpected; e++) { |
| 295 | int seen = 0; |
| 296 | for (int i = 0; i < count; i++) { |
| 297 | if (paths[i] && strstr(paths[i], expected[e])) { |
| 298 | seen++; |
| 299 | } |
| 300 | } |
| 301 | if (seen != 1) { |
| 302 | printf(" expected suffix '%s' appears %d time(s) (want 1)\n", |
| 303 | expected[e], seen); |
| 304 | for (int i = 0; i < count; i++) { |
| 305 | printf(" got: %s\n", paths[i] ? paths[i] : "(null)"); |
| 306 | } |
| 307 | return 0; |
| 308 | } |
| 309 | } |
| 310 | return 1; |
| 311 | } |
| 312 | |
| 313 | /* Expected distinct USAGE source files (shared by all three tests). */ |
| 314 | static const char *k_expected[] = { |