Whole-file read for byte-identity assertions on a published database. */
| 20436 | |
| 20437 | /* Whole-file read for byte-identity assertions on a published database. */ |
| 20438 | static unsigned char *read_file_bytes(const char *path, size_t *len_out) { |
| 20439 | *len_out = 0; |
| 20440 | FILE *f = fopen(path, "rb"); |
| 20441 | if (!f) { |
| 20442 | return NULL; |
| 20443 | } |
| 20444 | long size = fseek(f, 0, SEEK_END) == 0 ? ftell(f) : -1; |
| 20445 | if (size < 0) { |
| 20446 | fclose(f); |
| 20447 | return NULL; |
| 20448 | } |
| 20449 | rewind(f); |
| 20450 | unsigned char *buf = malloc((size_t)size + 1); |
| 20451 | if (!buf) { |
| 20452 | fclose(f); |
| 20453 | return NULL; |
| 20454 | } |
| 20455 | size_t got = fread(buf, 1, (size_t)size, f); |
| 20456 | fclose(f); |
| 20457 | if (got != (size_t)size) { |
| 20458 | free(buf); |
| 20459 | return NULL; |
| 20460 | } |
| 20461 | *len_out = got; |
| 20462 | return buf; |
| 20463 | } |
| 20464 | |
| 20465 | TEST(pipeline_backpressure_futile_nap_disengages) { |
| 20466 | /* 64 tiny files: > MIN_FILES_FOR_PARALLEL (50) so the parallel path (and its |
no test coverage detected