]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: add uninstall_element in testcli
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 25 Jan 2017 03:14:07 +0000 (04:14 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Fri, 10 Feb 2017 14:40:38 +0000 (15:40 +0100)
Test uninstall_element().  The commandline-specified counter allows
isolating memleaks more closely, differentiating one-off vs. repeated
leaks.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
tests/lib/cli/common_cli.c
tests/lib/cli/common_cli.h
tests/lib/cli/test_cli.c

index 83196e04aab6b1a7d10456868646c38c15334303..104352f5169fd054158a3d916ad0edd6e1e5c4bb 100644 (file)
@@ -83,7 +83,7 @@ main (int argc, char **argv)
   vty_init (master);
   memory_init ();
 
-  test_init ();
+  test_init (argc, argv);
 
   vty_stdio (vty_do_exit);
 
index 9c72b08e44a448f115083b0eb939483c0cb41069..9e7fe99830b2db01b4a034f2c3b9526d72a002a9 100644 (file)
@@ -28,7 +28,7 @@
 #include "command.h"
 
 /* function to be implemented by test */
-extern void test_init (void);
+extern void test_init (int argc, char **argv);
 
 /* functions provided by common cli
  * (includes main())
index 1a316022e2ae038fccda1869d2422fc1f16df439..54b34bc79983b869012c6f31de087e39b8b278bc 100644 (file)
@@ -38,8 +38,10 @@ DUMMY_DEFUN(cmd11, "alt a WORD");
 DUMMY_DEFUN(cmd12, "alt a A.B.C.D");
 DUMMY_DEFUN(cmd13, "alt a X:X::X:X");
 
-void test_init(void)
+void test_init(int argc, char **argv)
 {
+  size_t repeat = argc > 1 ? strtoul(argv[1], NULL, 0) : 223;
+
   install_element (ENABLE_NODE, &cmd0_cmd);
   install_element (ENABLE_NODE, &cmd1_cmd);
   install_element (ENABLE_NODE, &cmd2_cmd);
@@ -53,4 +55,12 @@ void test_init(void)
   install_element (ENABLE_NODE, &cmd11_cmd);
   install_element (ENABLE_NODE, &cmd12_cmd);
   install_element (ENABLE_NODE, &cmd13_cmd);
+  for (size_t i = 0; i < repeat; i++) {
+    uninstall_element (ENABLE_NODE, &cmd5_cmd);
+    install_element (ENABLE_NODE, &cmd5_cmd);
+  }
+  for (size_t i = 0; i < repeat; i++) {
+    uninstall_element (ENABLE_NODE, &cmd13_cmd);
+    install_element (ENABLE_NODE, &cmd13_cmd);
+  }
 }