]> git.proxmox.com Git - mirror_frr.git/blobdiff - tests/lib/test_privs.c
Merge pull request #8626 from idryzhov/fix-isis-topo1
[mirror_frr.git] / tests / lib / test_privs.c
index 421c3454365761f7ec24a66662f3c7862f236148..c06ebbeb38e86d35fdb4ff8c73f4860f1a67c282 100644 (file)
@@ -22,7 +22,7 @@
 #include "getopt.h"
 #include "privs.h"
 #include "memory.h"
-#include "memory_vty.h"
+#include "lib_vty.h"
 
 zebra_capabilities_t _caps_p[] = {
        ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN, ZCAP_DAC_OVERRIDE,
@@ -37,7 +37,7 @@ struct zebra_privs_t test_privs = {
        .vty_group = VTY_GROUP,
 #endif
        .caps_p = _caps_p,
-       .cap_num_p = sizeof(_caps_p) / sizeof(_caps_p[0]),
+       .cap_num_p = array_size(_caps_p),
        .cap_num_i = 0};
 
 struct option longopts[] = {{"help", no_argument, NULL, 'h'},
@@ -105,7 +105,7 @@ int main(int argc, char **argv)
        }
 
        /* Library inits. */
-       memory_init();
+       lib_cmd_init();
        zprivs_preinit(&test_privs);
        zprivs_init(&test_privs);
 
@@ -113,10 +113,9 @@ int main(int argc, char **argv)
        ((test_privs.current_state() == ZPRIVS_RAISED) ? "Raised" : "Lowered")
 
        printf("%s\n", PRIV_STATE());
-       test_privs.change(ZPRIVS_RAISE);
-
-       printf("%s\n", PRIV_STATE());
-       test_privs.change(ZPRIVS_LOWER);
+       frr_with_privs(&test_privs) {
+               printf("%s\n", PRIV_STATE());
+       }
 
        printf("%s\n", PRIV_STATE());
        zprivs_get_ids(&ids);
@@ -126,10 +125,9 @@ int main(int argc, char **argv)
 
        /* but these should continue to work... */
        printf("%s\n", PRIV_STATE());
-       test_privs.change(ZPRIVS_RAISE);
-
-       printf("%s\n", PRIV_STATE());
-       test_privs.change(ZPRIVS_LOWER);
+       frr_with_privs(&test_privs) {
+               printf("%s\n", PRIV_STATE());
+       }
 
        printf("%s\n", PRIV_STATE());
        zprivs_get_ids(&ids);