]> git.proxmox.com Git - mirror_frr.git/blob - tests/lib/test_buffer.c
Merge pull request #164 from opensourcerouting/pytest2
[mirror_frr.git] / tests / lib / test_buffer.c
1 /*
2 * Copyright (C) 2004 Paul Jakma
3 *
4 * This file is part of Quagga.
5 *
6 * Quagga is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * Quagga is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Quagga; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22 #include <zebra.h>
23 #include <memory.h>
24 #include <memory_vty.h>
25 #include <buffer.h>
26
27 struct thread_master *master;
28
29 int
30 main(int argc, char **argv)
31 {
32 struct buffer *b1, *b2;
33 int n;
34 char junk[3];
35 char c = 'a';
36
37 memory_init();
38
39 if ((argc != 2) || (sscanf(argv[1], "%d%1s", &n, junk) != 1))
40 {
41 fprintf(stderr, "Usage: %s <number of chars to simulate>\n", *argv);
42 return 1;
43 }
44
45 b1 = buffer_new(0);
46 b2 = buffer_new(1024);
47
48 while (n-- > 0)
49 {
50 buffer_put(b1, &c, 1);
51 buffer_put(b2, &c, 1);
52 if (c++ == 'z')
53 c = 'a';
54 buffer_reset(b1);
55 buffer_reset(b2);
56 }
57 buffer_free(b1);
58 buffer_free(b2);
59 return 0;
60 }