]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/test-json.c
2 * JSON parser - test program
3 * Copyright (c) 2019, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
10 #include "utils/common.h"
12 #include "utils/json.h"
13 #include "utils/wpa_debug.h"
16 void run_test(const char *buf
, size_t len
)
18 struct json_token
*root
;
20 size_t buflen
= 10000;
22 root
= json_parse(buf
, len
);
24 wpa_printf(MSG_DEBUG
, "JSON parsing failed");
28 txt
= os_zalloc(buflen
);
30 json_print_tree(root
, txt
, buflen
);
31 wpa_printf(MSG_DEBUG
, "%s", txt
);
39 int LLVMFuzzerTestOneInput(const uint8_t *data
, size_t size
)
41 run_test((const char *) data
, size
);
44 #else /* TEST_LIBFUZZER */
45 int main(int argc
, char *argv
[])
55 buf
= os_readfile(argv
[1], &len
);
64 #endif /* TEST_LIBFUZZER */