static int formatted_output = JSON_C_TO_STRING_SPACED;
static int show_output = 1;
+static int show_diag = 1;
static int strict_mode = 0;
static int validate_utf8 = 0;
static int tokener_flags = 0;
static void showmem(void)
{
+ if (!show_diag)
+ return;
#ifdef HAVE_GETRUSAGE
struct rusage rusage;
memset(&rusage, 0, sizeof(rusage));
fp = stderr;
if (errmsg != NULL)
fprintf(fp, "ERROR: %s\n\n", errmsg);
- fprintf(fp, "Usage: %s [-f|-F <arg>] [-n] [-s] [-u] [filename]\n", argv0);
+ fprintf(fp, "Usage: %s [-f|-F <arg>] [-n] [-s] [-u] [-N] [filename]\n", argv0);
fprintf(fp, " -f - Format the output to stdout with JSON_C_TO_STRING_PRETTY (default is JSON_C_TO_STRING_SPACED)\n");
fprintf(fp, " -F - Format the output to stdout with <arg>, e.g. 0 for JSON_C_TO_STRING_PLAIN\n");
fprintf(fp, " -n - No output\n");
+ fprintf(fp, " -N - Omit diagnostic information, such as memory usage\n");
fprintf(fp, " -c - Set JSON_C_TO_STRING_COLOR to colorize the output\n");
fprintf(fp, " -P - Initialize tokener flags to the given value\n");
fprintf(fp, " -s - Parse in strict mode, add flags:\n");
{
int opt;
- while ((opt = getopt(argc, argv, "cfF:hnP:su")) != -1)
+ while ((opt = getopt(argc, argv, "cfF:hnNP:su")) != -1)
{
switch (opt)
{
case 'f': formatted_output = JSON_C_TO_STRING_PRETTY; break;
case 'F': formatted_output = atoi(optarg); break;
case 'n': show_output = 0; break;
+ case 'N': show_diag = 0; break;
case 'P': tokener_flags = atoi(optarg); break;
case 's': strict_mode = 1; break;
case 'u': validate_utf8 = 1; break;
test_visit
test_object_iterator)
+set(NOBUILD_TEST_NAMES
+ test_json_parse_cli
+)
+
if (NOT DISABLE_JSON_POINTER)
set(ALL_TEST_NAMES ${ALL_TEST_NAMES} test_json_pointer)
set(ALL_TEST_NAMES ${ALL_TEST_NAMES} test_safe_json_pointer_set)
endif()
endif()
+foreach(TESTNAME ${NOBUILD_TEST_NAMES})
+add_test(NAME ${TESTNAME} COMMAND ${PROJECT_SOURCE_DIR}/tests/${TESTNAME}.test)
+endforeach(TESTNAME)
+
foreach(TESTNAME ${ALL_TEST_NAMES})
add_executable(${TESTNAME} ${TESTNAME}.c)
--- /dev/null
+#!/bin/sh
+
+# Common definitions
+if test -z "$srcdir"; then
+ srcdir="${0%/*}"
+ test "$srcdir" = "$0" && srcdir=.
+ test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+set -x -v
+
+echo -n '"tenant=blue;note=CANARY_STACK_WINDOW_2026;status=ok"' > file1.dat
+(printf '"' ; printf 'A%.0s' $(seq 1 16) ; echo 'e2' | xxd -r -p) > file2.dat
+
+TESTNAME="${0##*/}"
+TESTNAME="${TESTNAME%.test}"
+( cat file1.dat ; cat file2.dat ) | run_output_test -o "${TESTNAME}" --exit 1 ../apps/json_parse -u -N -n -
+_err=$?
+
+exit $_err