]> git.proxmox.com Git - mirror_frr.git/blob - tests/lib/test_zlog.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / lib / test_zlog.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Zlog tests.
4 * Copyright (C) 2018 Cumulus Networks, Inc.
5 * Quentin Young
6 */
7 #include <zebra.h>
8 #include <memory.h>
9 #include "log.h"
10 #include "network.h"
11
12 /* maximum amount of data to hexdump */
13 #define MAXDATA 16384
14
15 /*
16 * Test hexdump functionality.
17 *
18 * At the moment, not crashing is considered success.
19 */
20 static bool test_zlog_hexdump(void)
21 {
22 unsigned int nl = 1;
23
24 do {
25 uint8_t d[nl];
26
27 for (unsigned int i = 0; i < nl; i++)
28 d[i] = frr_weak_random();
29 zlog_hexdump(d, nl - 1);
30
31 nl += 1 + (nl / 2);
32 } while (nl <= MAXDATA);
33
34 return true;
35 }
36
37 bool (*tests[])(void) = {
38 test_zlog_hexdump,
39 };
40
41 int main(int argc, char **argv)
42 {
43 zlog_aux_init("NONE: ", ZLOG_DISABLED);
44
45 for (unsigned int i = 0; i < array_size(tests); i++)
46 if (!tests[i]())
47 return 1;
48 return 0;
49 }