testsuite: Add timeout to add_of_br() command.
[cascardo/ovs.git] / tests / test-reconnect.c
index 2d6f620..76e43ea 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, 2011, 2012, 2014 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2014, 2016 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,13 +39,12 @@ static const struct ovs_cmdl_command *get_all_commands(void);
 static void
 test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 {
-    extern struct vlog_module VLM_reconnect;
     struct reconnect_stats prev;
     unsigned int old_max_tries;
     int old_time;
     char line[128];
 
-    vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_OFF);
+    vlog_set_levels_from_string_assert("reconnect:off");
 
     now = 1000;
     reconnect = reconnect_create(now);
@@ -67,7 +66,11 @@ test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         svec_parse_words(&args, line);
         svec_terminate(&args);
         if (!svec_is_empty(&args)) {
-            ovs_cmdl_run_command(args.n, args.names, get_all_commands());
+            struct ovs_cmdl_context ctx = {
+                .argc = args.n,
+                .argv = args.names,
+            };
+            ovs_cmdl_run_command(&ctx, get_all_commands());
         }
         svec_destroy(&args);
 
@@ -88,19 +91,19 @@ test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 }
 
 static void
-do_enable(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+do_enable(struct ovs_cmdl_context *ctx OVS_UNUSED)
 {
     reconnect_enable(reconnect, now);
 }
 
 static void
-do_disable(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+do_disable(struct ovs_cmdl_context *ctx OVS_UNUSED)
 {
     reconnect_disable(reconnect, now);
 }
 
 static void
-do_force_reconnect(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+do_force_reconnect(struct ovs_cmdl_context *ctx OVS_UNUSED)
 {
     reconnect_force_reconnect(reconnect, now);
 }
@@ -120,42 +123,42 @@ error_from_string(const char *s)
 }
 
 static void
-do_disconnected(int argc OVS_UNUSED, char *argv[])
+do_disconnected(struct ovs_cmdl_context *ctx)
 {
-    reconnect_disconnected(reconnect, now, error_from_string(argv[1]));
+    reconnect_disconnected(reconnect, now, error_from_string(ctx->argv[1]));
 }
 
 static void
-do_connecting(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+do_connecting(struct ovs_cmdl_context *ctx OVS_UNUSED)
 {
     reconnect_connecting(reconnect, now);
 }
 
 static void
-do_connect_failed(int argc OVS_UNUSED, char *argv[])
+do_connect_failed(struct ovs_cmdl_context *ctx)
 {
-    reconnect_connect_failed(reconnect, now, error_from_string(argv[1]));
+    reconnect_connect_failed(reconnect, now, error_from_string(ctx->argv[1]));
 }
 
 static void
-do_connected(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+do_connected(struct ovs_cmdl_context *ctx OVS_UNUSED)
 {
     reconnect_connected(reconnect, now);
 }
 
 static void
-do_activity(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+do_activity(struct ovs_cmdl_context *ctx OVS_UNUSED)
 {
     reconnect_activity(reconnect, now);
 }
 
 static void
-do_run(int argc, char *argv[])
+do_run(struct ovs_cmdl_context *ctx)
 {
     enum reconnect_action action;
 
-    if (argc > 1) {
-        now += atoi(argv[1]);
+    if (ctx->argc > 1) {
+        now += atoi(ctx->argv[1]);
     }
 
     action = reconnect_run(reconnect, now);
@@ -181,13 +184,13 @@ do_run(int argc, char *argv[])
 }
 
 static void
-do_advance(int argc OVS_UNUSED, char *argv[])
+do_advance(struct ovs_cmdl_context *ctx)
 {
-    now += atoi(argv[1]);
+    now += atoi(ctx->argv[1]);
 }
 
 static void
-do_timeout(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+do_timeout(struct ovs_cmdl_context *ctx OVS_UNUSED)
 {
     int timeout = reconnect_timeout(reconnect, now);
     if (timeout >= 0) {
@@ -199,9 +202,9 @@ do_timeout(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 }
 
 static void
-do_set_max_tries(int argc OVS_UNUSED, char *argv[])
+do_set_max_tries(struct ovs_cmdl_context *ctx)
 {
-    reconnect_set_max_tries(reconnect, atoi(argv[1]));
+    reconnect_set_max_tries(reconnect, atoi(ctx->argv[1]));
 }
 
 static void
@@ -251,21 +254,21 @@ diff_stats(const struct reconnect_stats *old,
 }
 
 static void
-do_set_passive(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+do_set_passive(struct ovs_cmdl_context *ctx OVS_UNUSED)
 {
     reconnect_set_passive(reconnect, true, now);
 }
 
 static void
-do_listening(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+do_listening(struct ovs_cmdl_context *ctx OVS_UNUSED)
 {
     reconnect_listening(reconnect, now);
 }
 
 static void
-do_listen_error(int argc OVS_UNUSED, char *argv[])
+do_listen_error(struct ovs_cmdl_context *ctx)
 {
-    reconnect_listen_error(reconnect, now, atoi(argv[1]));
+    reconnect_listen_error(reconnect, now, atoi(ctx->argv[1]));
 }
 
 static const struct ovs_cmdl_command all_commands[] = {