| 417 | } |
| 418 | |
| 419 | static char *read_test_file_alloc(const char *path) { |
| 420 | FILE *f = fopen(path, "rb"); |
| 421 | if (!f) |
| 422 | return NULL; |
| 423 | if (fseek(f, 0, SEEK_END) != 0) { |
| 424 | fclose(f); |
| 425 | return NULL; |
| 426 | } |
| 427 | long len = ftell(f); |
| 428 | if (len < 0 || fseek(f, 0, SEEK_SET) != 0) { |
| 429 | fclose(f); |
| 430 | return NULL; |
| 431 | } |
| 432 | char *buf = malloc((size_t)len + 1); |
| 433 | if (!buf) { |
| 434 | fclose(f); |
| 435 | return NULL; |
| 436 | } |
| 437 | size_t read_len = fread(buf, 1, (size_t)len, f); |
| 438 | fclose(f); |
| 439 | if (read_len != (size_t)len) { |
| 440 | free(buf); |
| 441 | return NULL; |
| 442 | } |
| 443 | buf[read_len] = '\0'; |
| 444 | return buf; |
| 445 | } |
| 446 | |
| 447 | static bool test_file_contains_all(const char *path, const char *const *tokens, |
| 448 | size_t token_count) { |
no test coverage detected