]> git.proxmox.com Git - mirror_frr.git/blame - tests/lib/test_zlog.c
*: auto-convert to SPDX License IDs
[mirror_frr.git] / tests / lib / test_zlog.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
abccc775
QY
2/*
3 * Zlog tests.
4 * Copyright (C) 2018 Cumulus Networks, Inc.
5 * Quentin Young
abccc775
QY
6 */
7#include <zebra.h>
8#include <memory.h>
9#include "log.h"
5920b3eb 10#include "network.h"
abccc775
QY
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 */
20static bool test_zlog_hexdump(void)
21{
22 unsigned int nl = 1;
23
24 do {
46171e25 25 uint8_t d[nl];
abccc775
QY
26
27 for (unsigned int i = 0; i < nl; i++)
5920b3eb 28 d[i] = frr_weak_random();
46171e25
DL
29 zlog_hexdump(d, nl - 1);
30
31 nl += 1 + (nl / 2);
32 } while (nl <= MAXDATA);
abccc775
QY
33
34 return true;
35}
36
37bool (*tests[])(void) = {
38 test_zlog_hexdump,
39};
40
41int main(int argc, char **argv)
42{
0bdeb5e5 43 zlog_aux_init("NONE: ", ZLOG_DISABLED);
abccc775
QY
44
45 for (unsigned int i = 0; i < array_size(tests); i++)
46 if (!tests[i]())
47 return 1;
48 return 0;
49}