summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGurucharan Shetty <gshetty@nicira.com>2014-04-03 16:07:43 -0700
committerGurucharan Shetty <gshetty@nicira.com>2014-04-04 07:34:10 -0700
commitd2586fce485240801bdfdd73ad4679b9c88bc659 (patch)
tree311de835773f595dc9e1a624649adc99a0609ff8 /tests
parent79bda8258b5365438a70d08c74fab903f1dc0a29 (diff)
downloadopenvswitch-d2586fce485240801bdfdd73ad4679b9c88bc659.tar.gz
Avoid static declarations of arrays with unknown size.
Visual studio does not like it. This commit is similar to commit 3815d6c2c (Avoid designated initializers and static decls of arrays of unknown size.) but touches more files. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test-jsonrpc.c11
-rw-r--r--tests/test-lockfile.c28
-rw-r--r--tests/test-ovsdb.c11
-rw-r--r--tests/test-reconnect.c13
4 files changed, 39 insertions, 24 deletions
diff --git a/tests/test-jsonrpc.c b/tests/test-jsonrpc.c
index 4ace6dc63..7251265fe 100644
--- a/tests/test-jsonrpc.c
+++ b/tests/test-jsonrpc.c
@@ -35,10 +35,9 @@
#include "vlog.h"
#include "ovstest.h"
-static struct command all_commands[];
-
static void usage(void) NO_RETURN;
static void parse_options(int argc, char *argv[]);
+static struct command *get_all_commands(void);
static void
test_jsonrpc_main(int argc, char *argv[])
@@ -46,7 +45,7 @@ test_jsonrpc_main(int argc, char *argv[])
proctitle_init(argc, argv);
set_program_name(argv[0]);
parse_options(argc, argv);
- run_command(argc - optind, argv + optind, all_commands);
+ run_command(argc - optind, argv + optind, get_all_commands());
}
static void
@@ -337,4 +336,10 @@ static struct command all_commands[] = {
{ NULL, 0, 0, NULL },
};
+static struct command *
+get_all_commands(void)
+{
+ return all_commands;
+}
+
OVSTEST_REGISTER("test-jsonrpc", test_jsonrpc_main);
diff --git a/tests/test-lockfile.c b/tests/test-lockfile.c
index 80cc5a84a..0bf3fe6dd 100644
--- a/tests/test-lockfile.c
+++ b/tests/test-lockfile.c
@@ -35,7 +35,7 @@ struct test {
void (*function)(void);
};
-static const struct test tests[];
+static void run_help(void);
#define CHECK(A, B) check(A, B, #A, #B, __FILE__, __LINE__)
static void
@@ -237,19 +237,6 @@ run_lock_symlink_to_dir(void)
lockfile_unlock(a);
}
-static void
-run_help(void)
-{
- size_t i;
-
- printf("usage: %s TESTNAME\n"
- "where TESTNAME is one of the following:\n",
- program_name);
- for (i = 0; tests[i].name; i++) {
- fprintf(stderr, "\t%s\n", tests[i].name);
- }
-}
-
static const struct test tests[] = {
#define TEST(NAME) { #NAME, run_##NAME }
TEST(lock_and_unlock),
@@ -268,6 +255,19 @@ static const struct test tests[] = {
};
static void
+run_help(void)
+{
+ size_t i;
+
+ printf("usage: %s TESTNAME\n"
+ "where TESTNAME is one of the following:\n",
+ program_name);
+ for (i = 0; tests[i].name; i++) {
+ fprintf(stderr, "\t%s\n", tests[i].name);
+ }
+}
+
+static void
test_lockfile_main(int argc, char *argv[])
{
size_t i;
diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index aeb7a5e7f..29d75420f 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -51,17 +51,16 @@
#include "util.h"
#include "vlog.h"
-static struct command all_commands[];
-
static void usage(void) NO_RETURN;
static void parse_options(int argc, char *argv[]);
+static struct command *get_all_commands(void);
int
main(int argc, char *argv[])
{
set_program_name(argv[0]);
parse_options(argc, argv);
- run_command(argc - optind, argv + optind, all_commands);
+ run_command(argc - optind, argv + optind, get_all_commands());
return 0;
}
@@ -1993,3 +1992,9 @@ static struct command all_commands[] = {
{ "help", 0, INT_MAX, do_help },
{ NULL, 0, 0, NULL },
};
+
+static struct command *
+get_all_commands(void)
+{
+ return all_commands;
+}
diff --git a/tests/test-reconnect.c b/tests/test-reconnect.c
index d3ff6e82c..286405187 100644
--- a/tests/test-reconnect.c
+++ b/tests/test-reconnect.c
@@ -33,11 +33,10 @@
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 struct command *get_all_commands(void);
static void
test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
@@ -70,7 +69,7 @@ test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
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);
@@ -271,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 },
@@ -290,4 +289,10 @@ static const struct command commands[] = {
{ NULL, 0, 0, NULL },
};
+static struct command *
+get_all_commands(void)
+{
+ return all_commands;
+}
+
OVSTEST_REGISTER("test-reconnect", test_reconnect_main);