From ba3e6e2bca97df14920375b0a1ebf4eab95b78b5 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 23 Apr 2024 15:27:40 -0400 Subject: Post review fixes for test_json_parser test module . Add missing copytight notices . improve code coverage . put work files in a temp directory in the standard location . improve error checking in C code . indent perl files with perltidy . add some comments per comments from Michael Paquier Discussion: https://postgr.es/m/ZiC3-cdFys4-6xSk@paquier.xyz --- src/test/modules/test_json_parser/test_json_parser_perf.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/test/modules/test_json_parser/test_json_parser_perf.c') diff --git a/src/test/modules/test_json_parser/test_json_parser_perf.c b/src/test/modules/test_json_parser/test_json_parser_perf.c index c463046848c..f5c0e8dd9ae 100644 --- a/src/test/modules/test_json_parser/test_json_parser_perf.c +++ b/src/test/modules/test_json_parser/test_json_parser_perf.c @@ -23,6 +23,7 @@ #include "postgres_fe.h" #include "common/jsonapi.h" +#include "common/logging.h" #include "lib/stringinfo.h" #include "mb/pg_wchar.h" #include @@ -52,7 +53,9 @@ main(int argc, char **argv) sscanf(argv[1], "%d", &iter); - json_file = fopen(argv[2], "r"); + if ((json_file = fopen(argv[2], "r")) == NULL) + pg_fatal("Could not open input file '%s': %m", argv[2]); + while ((n_read = fread(buff, 1, 6000, json_file)) > 0) { appendBinaryStringInfo(&json, buff, n_read); @@ -76,12 +79,8 @@ main(int argc, char **argv) freeJsonLexContext(lex); } if (result != JSON_SUCCESS) - { - fprintf(stderr, - "unexpected result %d (expecting %d) on parse\n", - result, JSON_SUCCESS); - exit(1); - } + pg_fatal("unexpected result %d (expecting %d) on parse", + result, JSON_SUCCESS); } exit(0); } -- cgit v1.2.3