X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2Ftest-reconnect.c;h=35d5f4175e88a322c599a480bed0393b953e9ffc;hb=003ce655b7116d18c86a74c50391e54990346931;hp=fae0f17800ef22db8f1050590e3082a0f8f58cb4;hpb=5eda645e36a9b5dd72c275b7e400dfefcba281d3;p=sliver-openvswitch.git diff --git a/tests/test-reconnect.c b/tests/test-reconnect.c index fae0f1780..35d5f4175 100644 --- a/tests/test-reconnect.c +++ b/tests/test-reconnect.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010 Nicira Networks. + * Copyright (c) 2009, 2010, 2011, 2012, 2014 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,18 +28,18 @@ #include "svec.h" #include "util.h" #include "vlog.h" +#include "ovstest.h" static struct reconnect *reconnect; static int now; -static const struct command commands[]; - static void diff_stats(const struct reconnect_stats *old, const struct reconnect_stats *new, int delta); +static const struct command *get_all_commands(void); -int -main(void) +static void +test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) { extern struct vlog_module VLM_reconnect; struct reconnect_stats prev; @@ -47,7 +47,7 @@ main(void) int old_time; char line[128]; - vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_EMER); + vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_OFF); now = 1000; reconnect = reconnect_create(now); @@ -69,7 +69,7 @@ main(void) svec_parse_words(&args, line); svec_terminate(&args); if (!svec_is_empty(&args)) { - run_command(args.n, args.names, commands); + run_command(args.n, args.names, get_all_commands()); } svec_destroy(&args); @@ -87,8 +87,6 @@ main(void) old_time = now; } - - return 0; } static void @@ -148,9 +146,9 @@ do_connected(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) } static void -do_received(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) +do_activity(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) { - reconnect_received(reconnect, now); + reconnect_activity(reconnect, now); } static void @@ -166,7 +164,7 @@ do_run(int argc, char *argv[]) switch (action) { default: if (action != 0) { - NOT_REACHED(); + OVS_NOT_REACHED(); } break; @@ -220,10 +218,10 @@ diff_stats(const struct reconnect_stats *old, new->state, new->state_elapsed, new->backoff); } if (old->creation_time != new->creation_time - || old->last_received != new->last_received + || old->last_activity != new->last_activity || old->last_connected != new->last_connected) { - printf(" created %lld, last received %lld, last connected %lld\n", - new->creation_time, new->last_received, new->last_connected); + printf(" created %lld, last activity %lld, last connected %lld\n", + new->creation_time, new->last_activity, new->last_connected); } if (old->n_successful_connections != new->n_successful_connections || old->n_attempted_connections != new->n_attempted_connections @@ -272,7 +270,7 @@ do_listen_error(int argc OVS_UNUSED, char *argv[]) reconnect_listen_error(reconnect, now, atoi(argv[1])); } -static const struct command commands[] = { +static const struct command all_commands[] = { { "enable", 0, 0, do_enable }, { "disable", 0, 0, do_disable }, { "force-reconnect", 0, 0, do_force_reconnect }, @@ -280,7 +278,7 @@ static const struct command commands[] = { { "connecting", 0, 0, do_connecting }, { "connect-failed", 0, 1, do_connect_failed }, { "connected", 0, 0, do_connected }, - { "received", 0, 0, do_received }, + { "activity", 0, 0, do_activity }, { "run", 0, 1, do_run }, { "advance", 1, 1, do_advance }, { "timeout", 0, 0, do_timeout }, @@ -290,3 +288,11 @@ static const struct command commands[] = { { "listen-error", 1, 1, do_listen_error }, { NULL, 0, 0, NULL }, }; + +static const struct command * +get_all_commands(void) +{ + return all_commands; +} + +OVSTEST_REGISTER("test-reconnect", test_reconnect_main);