projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
datapath: Get rid of compat.h, compat26.h in favor of modern approach.
[openvswitch]
/
tests
/
test-reconnect.c
diff --git
a/tests/test-reconnect.c
b/tests/test-reconnect.c
index a8784fc884dcbbafec50f9e3dd047e7f75a27e24..0f49d7f5847c0bc590a7ca279b35b17d24e76b67 100644
(file)
--- a/
tests/test-reconnect.c
+++ b/
tests/test-reconnect.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2009 Nicira Networks.
+ * Copyright (c) 2009
, 2010
Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-27,6
+27,7
@@
#include "compiler.h"
#include "svec.h"
#include "util.h"
#include "compiler.h"
#include "svec.h"
#include "util.h"
+#include "vlog.h"
static struct reconnect *reconnect;
static int now;
static struct reconnect *reconnect;
static int now;
@@
-39,16
+40,21
@@
static void diff_stats(const struct reconnect_stats *old,
int
main(void)
{
int
main(void)
{
+ extern struct vlog_module VLM_reconnect;
struct reconnect_stats prev;
struct reconnect_stats prev;
+ unsigned int old_max_tries;
int old_time;
char line[128];
int old_time;
char line[128];
+ vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_EMER);
+
now = 1000;
reconnect = reconnect_create(now);
reconnect_set_name(reconnect, "remote");
reconnect_get_stats(reconnect, now, &prev);
printf("### t=%d ###\n", now);
old_time = now;
now = 1000;
reconnect = reconnect_create(now);
reconnect_set_name(reconnect, "remote");
reconnect_get_stats(reconnect, now, &prev);
printf("### t=%d ###\n", now);
old_time = now;
+ old_max_tries = reconnect_get_max_tries(reconnect);
while (fgets(line, sizeof line, stdin)) {
struct reconnect_stats cur;
struct svec args;
while (fgets(line, sizeof line, stdin)) {
struct reconnect_stats cur;
struct svec args;
@@
-74,25
+80,29
@@
main(void)
reconnect_get_stats(reconnect, now, &cur);
diff_stats(&prev, &cur);
prev = cur;
reconnect_get_stats(reconnect, now, &cur);
diff_stats(&prev, &cur);
prev = cur;
+ if (reconnect_get_max_tries(reconnect) != old_max_tries) {
+ old_max_tries = reconnect_get_max_tries(reconnect);
+ printf(" %u tries left\n", old_max_tries);
+ }
}
return 0;
}
static void
}
return 0;
}
static void
-do_enable(int argc
UNUSED, char *argv[]
UNUSED)
+do_enable(int argc
OVS_UNUSED, char *argv[] OVS_
UNUSED)
{
reconnect_enable(reconnect, now);
}
static void
{
reconnect_enable(reconnect, now);
}
static void
-do_disable(int argc
UNUSED, char *argv[]
UNUSED)
+do_disable(int argc
OVS_UNUSED, char *argv[] OVS_
UNUSED)
{
reconnect_disable(reconnect, now);
}
static void
{
reconnect_disable(reconnect, now);
}
static void
-do_force_reconnect(int argc
UNUSED, char *argv[]
UNUSED)
+do_force_reconnect(int argc
OVS_UNUSED, char *argv[] OVS_
UNUSED)
{
reconnect_force_reconnect(reconnect, now);
}
{
reconnect_force_reconnect(reconnect, now);
}
@@
-112,31
+122,31
@@
error_from_string(const char *s)
}
static void
}
static void
-do_disconnected(int argc UNUSED, char *argv[])
+do_disconnected(int argc
OVS_
UNUSED, char *argv[])
{
reconnect_disconnected(reconnect, now, error_from_string(argv[1]));
}
static void
{
reconnect_disconnected(reconnect, now, error_from_string(argv[1]));
}
static void
-do_connecting(int argc
UNUSED, char *argv[]
UNUSED)
+do_connecting(int argc
OVS_UNUSED, char *argv[] OVS_
UNUSED)
{
reconnect_connecting(reconnect, now);
}
static void
{
reconnect_connecting(reconnect, now);
}
static void
-do_connect_failed(int argc UNUSED, char *argv[])
+do_connect_failed(int argc
OVS_
UNUSED, char *argv[])
{
reconnect_connect_failed(reconnect, now, error_from_string(argv[1]));
}
static void
{
reconnect_connect_failed(reconnect, now, error_from_string(argv[1]));
}
static void
-do_connected(int argc
UNUSED, char *argv[]
UNUSED)
+do_connected(int argc
OVS_UNUSED, char *argv[] OVS_
UNUSED)
{
reconnect_connected(reconnect, now);
}
static void
{
reconnect_connected(reconnect, now);
}
static void
-do_received(int argc
UNUSED, char *argv[]
UNUSED)
+do_received(int argc
OVS_UNUSED, char *argv[] OVS_
UNUSED)
{
reconnect_received(reconnect, now);
}
{
reconnect_received(reconnect, now);
}
@@
-173,13
+183,13
@@
do_run(int argc, char *argv[])
}
static void
}
static void
-do_advance(int argc UNUSED, char *argv[])
+do_advance(int argc
OVS_
UNUSED, char *argv[])
{
now += atoi(argv[1]);
}
static void
{
now += atoi(argv[1]);
}
static void
-do_timeout(int argc
UNUSED, char *argv[]
UNUSED)
+do_timeout(int argc
OVS_UNUSED, char *argv[] OVS_
UNUSED)
{
int timeout = reconnect_timeout(reconnect, now);
if (timeout >= 0) {
{
int timeout = reconnect_timeout(reconnect, now);
if (timeout >= 0) {
@@
-190,6
+200,12
@@
do_timeout(int argc UNUSED, char *argv[] UNUSED)
}
}
}
}
+static void
+do_set_max_tries(int argc OVS_UNUSED, char *argv[])
+{
+ reconnect_set_max_tries(reconnect, atoi(argv[1]));
+}
+
static void
diff_stats(const struct reconnect_stats *old,
const struct reconnect_stats *new)
static void
diff_stats(const struct reconnect_stats *old,
const struct reconnect_stats *new)
@@
-223,6
+239,24
@@
diff_stats(const struct reconnect_stats *old,
}
}
}
}
+static void
+do_set_passive(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+{
+ reconnect_set_passive(reconnect, true, now);
+}
+
+static void
+do_listening(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+{
+ reconnect_listening(reconnect, now);
+}
+
+static void
+do_listen_error(int argc OVS_UNUSED, char *argv[])
+{
+ reconnect_listen_error(reconnect, now, atoi(argv[1]));
+}
+
static const struct command commands[] = {
{ "enable", 0, 0, do_enable },
{ "disable", 0, 0, do_disable },
static const struct command commands[] = {
{ "enable", 0, 0, do_enable },
{ "disable", 0, 0, do_disable },
@@
-235,6
+269,10
@@
static const struct command commands[] = {
{ "run", 0, 1, do_run },
{ "advance", 1, 1, do_advance },
{ "timeout", 0, 0, do_timeout },
{ "run", 0, 1, do_run },
{ "advance", 1, 1, do_advance },
{ "timeout", 0, 0, do_timeout },
+ { "set-max-tries", 1, 1, do_set_max_tries },
+ { "passive", 0, 0, do_set_passive },
+ { "listening", 0, 0, do_listening },
+ { "listen-error", 1, 1, do_listen_error },
{ NULL, 0, 0, NULL },
};
{ NULL, 0, 0, NULL },
};