]> git.proxmox.com Git - mirror_frr.git/blob - tests/lib/test_buffer.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / lib / test_buffer.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2004 Paul Jakma
4 */
5
6 #include <zebra.h>
7 #include <memory.h>
8 #include <lib_vty.h>
9 #include <buffer.h>
10
11 struct thread_master *master;
12
13 int main(int argc, char **argv)
14 {
15 struct buffer *b1, *b2;
16 int n;
17 char junk[3];
18 char c = 'a';
19
20 lib_cmd_init();
21
22 if ((argc != 2) || (sscanf(argv[1], "%d%1s", &n, junk) != 1)) {
23 fprintf(stderr, "Usage: %s <number of chars to simulate>\n",
24 *argv);
25 return 1;
26 }
27
28 b1 = buffer_new(0);
29 b2 = buffer_new(1024);
30
31 while (n-- > 0) {
32 buffer_put(b1, &c, 1);
33 buffer_put(b2, &c, 1);
34 if (c++ == 'z')
35 c = 'a';
36 buffer_reset(b1);
37 buffer_reset(b2);
38 }
39 buffer_free(b1);
40 buffer_free(b2);
41 return 0;
42 }