diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/common-cli.c | 1 | ||||
| -rw-r--r-- | tests/heavy-wq.c | 14 | ||||
| -rw-r--r-- | tests/main.c | 1 | ||||
| -rw-r--r-- | tests/test-buffer.c | 1 | ||||
| -rw-r--r-- | tests/test-memory.c | 49 | ||||
| -rw-r--r-- | tests/test-privs.c | 1 |
6 files changed, 39 insertions, 28 deletions
diff --git a/tests/common-cli.c b/tests/common-cli.c index 7c34e6a559..aed20b2d53 100644 --- a/tests/common-cli.c +++ b/tests/common-cli.c @@ -26,6 +26,7 @@ #include "vty.h" #include "command.h" #include "memory.h" +#include "memory_vty.h" #include "log.h" #include "common-cli.h" diff --git a/tests/heavy-wq.c b/tests/heavy-wq.c index 2f133cc5d4..2d15dc37bd 100644 --- a/tests/heavy-wq.c +++ b/tests/heavy-wq.c @@ -38,6 +38,10 @@ #include "tests.h" +DEFINE_MGROUP(TEST_HEAVYWQ, "heavy-wq test") +DEFINE_MTYPE_STATIC(TEST_HEAVYWQ, WQ_NODE, "heavy_wq_node") +DEFINE_MTYPE_STATIC(TEST_HEAVYWQ, WQ_NODE_STR, "heavy_wq_node->str") + extern struct thread_master *master; static struct work_queue *heavy_wq; @@ -61,17 +65,17 @@ heavy_wq_add (struct vty *vty, const char *str, int i) { struct heavy_wq_node *hn; - if ((hn = XCALLOC (MTYPE_PREFIX_LIST, sizeof(struct heavy_wq_node))) == NULL) + if ((hn = XCALLOC (MTYPE_WQ_NODE, sizeof(struct heavy_wq_node))) == NULL) { zlog_err ("%s: unable to allocate hn", __func__); return; } hn->i = i; - if (!(hn->str = XSTRDUP (MTYPE_PREFIX_LIST_STR, str))) + if (!(hn->str = XSTRDUP (MTYPE_WQ_NODE_STR, str))) { zlog_err ("%s: unable to xstrdup", __func__); - XFREE (MTYPE_PREFIX_LIST, hn); + XFREE (MTYPE_WQ_NODE, hn); return; } @@ -92,9 +96,9 @@ slow_func_del (struct work_queue *wq, void *data) struct heavy_wq_node *hn = data; assert (hn && hn->str); printf ("%s: %s\n", __func__, hn->str); - XFREE (MTYPE_PREFIX_LIST_STR, hn->str); + XFREE (MTYPE_WQ_NODE_STR, hn->str); hn->str = NULL; - XFREE(MTYPE_PREFIX_LIST, hn); + XFREE(MTYPE_WQ_NODE, hn); } static wq_item_status diff --git a/tests/main.c b/tests/main.c index 5396c7d50f..885b8a2923 100644 --- a/tests/main.c +++ b/tests/main.c @@ -27,6 +27,7 @@ #include "vty.h" #include "command.h" #include "memory.h" +#include "memory_vty.h" extern void test_init(); diff --git a/tests/test-buffer.c b/tests/test-buffer.c index e95d6fb829..67e4035806 100644 --- a/tests/test-buffer.c +++ b/tests/test-buffer.c @@ -21,6 +21,7 @@ #include <zebra.h> #include <memory.h> +#include <memory_vty.h> #include <buffer.h> struct thread_master *master; diff --git a/tests/test-memory.c b/tests/test-memory.c index 807249ea6d..6849b9dceb 100644 --- a/tests/test-memory.c +++ b/tests/test-memory.c @@ -20,6 +20,9 @@ #include <zebra.h> #include <memory.h> +DEFINE_MGROUP(TEST_MEMORY, "memory test") +DEFINE_MTYPE_STATIC(TEST_MEMORY, TEST, "generic test mtype") + /* Memory torture tests * * Tests below are generic but comments are focused on interaction with @@ -52,28 +55,28 @@ main(int argc, char **argv) /* simple case, test cache */ for (i = 0; i < TIMES; i++) { - a[0] = XMALLOC (MTYPE_VTY, 1024); + a[0] = XMALLOC (MTYPE_TEST, 1024); memset (a[0], 1, 1024); - a[1] = XMALLOC (MTYPE_VTY, 1024); + a[1] = XMALLOC (MTYPE_TEST, 1024); memset (a[1], 1, 1024); - XFREE(MTYPE_VTY, a[0]); /* should go to cache */ - a[0] = XMALLOC (MTYPE_VTY, 1024); /* should be satisfied from cache */ - XFREE(MTYPE_VTY, a[0]); - XFREE(MTYPE_VTY, a[1]); + XFREE(MTYPE_TEST, a[0]); /* should go to cache */ + a[0] = XMALLOC (MTYPE_TEST, 1024); /* should be satisfied from cache */ + XFREE(MTYPE_TEST, a[0]); + XFREE(MTYPE_TEST, a[1]); } printf ("malloc x, malloc y, free x, malloc y, free free\n\n"); /* cache should go invalid, valid, invalid, etc.. */ for (i = 0; i < TIMES; i++) { - a[0] = XMALLOC (MTYPE_VTY, 512); + a[0] = XMALLOC (MTYPE_TEST, 512); memset (a[0], 1, 512); - a[1] = XMALLOC (MTYPE_VTY, 1024); /* invalidate cache */ + a[1] = XMALLOC (MTYPE_TEST, 1024); /* invalidate cache */ memset (a[1], 1, 1024); - XFREE(MTYPE_VTY, a[0]); - a[0] = XMALLOC (MTYPE_VTY, 1024); - XFREE(MTYPE_VTY, a[0]); - XFREE(MTYPE_VTY, a[1]); + XFREE(MTYPE_TEST, a[0]); + a[0] = XMALLOC (MTYPE_TEST, 1024); + XFREE(MTYPE_TEST, a[0]); + XFREE(MTYPE_TEST, a[1]); /* cache should become valid again on next request */ } @@ -81,12 +84,12 @@ main(int argc, char **argv) /* test calloc */ for (i = 0; i < TIMES; i++) { - a[0] = XCALLOC (MTYPE_VTY, 1024); + a[0] = XCALLOC (MTYPE_TEST, 1024); memset (a[0], 1, 1024); - a[1] = XCALLOC (MTYPE_VTY, 512); /* invalidate cache */ + a[1] = XCALLOC (MTYPE_TEST, 512); /* invalidate cache */ memset (a[1], 1, 512); - XFREE(MTYPE_VTY, a[1]); - XFREE(MTYPE_VTY, a[0]); + XFREE(MTYPE_TEST, a[1]); + XFREE(MTYPE_TEST, a[0]); /* alloc == 0, cache can become valid again on next request */ } @@ -95,27 +98,27 @@ main(int argc, char **argv) for (i = 0; i < TIMES; i++) { printf ("calloc a0 1024\n"); - a[0] = XCALLOC (MTYPE_VTY, 1024); + a[0] = XCALLOC (MTYPE_TEST, 1024); memset (a[0], 1, 1024/2); printf ("calloc 1 1024\n"); - a[1] = XCALLOC (MTYPE_VTY, 1024); + a[1] = XCALLOC (MTYPE_TEST, 1024); memset (a[1], 1, 1024/2); printf ("realloc 0 1024\n"); - a[3] = XREALLOC (MTYPE_VTY, a[0], 2048); /* invalidate cache */ + a[3] = XREALLOC (MTYPE_TEST, a[0], 2048); /* invalidate cache */ if (a[3] != NULL) a[0] = a[3]; memset (a[0], 1, 1024); printf ("calloc 2 512\n"); - a[2] = XCALLOC (MTYPE_VTY, 512); + a[2] = XCALLOC (MTYPE_TEST, 512); memset (a[2], 1, 512); printf ("free 1 0 2\n"); - XFREE(MTYPE_VTY, a[1]); - XFREE(MTYPE_VTY, a[0]); - XFREE(MTYPE_VTY, a[2]); + XFREE(MTYPE_TEST, a[1]); + XFREE(MTYPE_TEST, a[0]); + XFREE(MTYPE_TEST, a[2]); /* alloc == 0, cache valid next request */ } return 0; diff --git a/tests/test-privs.c b/tests/test-privs.c index beae81f693..e0118a881c 100644 --- a/tests/test-privs.c +++ b/tests/test-privs.c @@ -25,6 +25,7 @@ #include "getopt.h" #include "privs.h" #include "memory.h" +#include "memory_vty.h" zebra_capabilities_t _caps_p [] = { |
