Skip to content

Commit 58bc061

Browse files
committed
error on failure to read test file
1 parent a932f54 commit 58bc061

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/libmongoc/tests/json-test.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -663,27 +663,24 @@ get_bson_from_json_file (char *filename)
663663

664664
file = fopen (filename, "rb");
665665
if (!file) {
666-
return NULL;
666+
test_error ("Failed to open JSON file: %s", filename);
667667
}
668668

669669
/* get file length */
670670
fseek (file, 0, SEEK_END);
671671
length = ftell (file);
672672
fseek (file, 0, SEEK_SET);
673673
if (length < 1) {
674-
return NULL;
674+
test_error ("Failed to read length of JSON file: %s", filename);
675675
}
676676

677677
/* read entire file into buffer */
678678
buffer = (const char *) bson_malloc0 (length);
679679
if (fread ((void *) buffer, 1, length, file) != length) {
680-
test_error ("Failed to read JSON file into buffer");
680+
test_error ("Failed to read JSON file into buffer: %s", filename);
681681
}
682682

683683
fclose (file);
684-
if (!buffer) {
685-
return NULL;
686-
}
687684

688685
/* convert to bson */
689686
data = bson_new_from_json ((const uint8_t *) buffer, length, &error);

0 commit comments

Comments
 (0)