#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[])
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
{ NULL, 0, 0, NULL },
};
+static struct command *
+get_all_commands(void)
+{
+ return all_commands;
+}
+
OVSTEST_REGISTER("test-jsonrpc", test_jsonrpc_main);
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
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),
#undef TEST
};
+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[])
{
#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;
}
{ "help", 0, INT_MAX, do_help },
{ NULL, 0, 0, NULL },
};
+
+static struct command *
+get_all_commands(void)
+{
+ return all_commands;
+}
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)
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);
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 },
{ NULL, 0, 0, NULL },
};
+static struct command *
+get_all_commands(void)
+{
+ return all_commands;
+}
+
OVSTEST_REGISTER("test-reconnect", test_reconnect_main);
/* Format for table output. */
static struct table_style table_style = TABLE_STYLE_DEFAULT;
-/* All supported commands. */
-static const struct vtep_ctl_command_syntax all_commands[];
-
/* The IDL we're using and the current transaction, if any.
* This is for use by vtep_ctl_exit() only, to allow it to clean up.
* Other code should use its context arguments. */
static struct vtep_ctl_lswitch *find_lswitch(struct vtep_ctl_context *,
const char *name,
bool must_exist);
+static const struct vtep_ctl_command_syntax *get_all_commands(void);
int
main(int argc, char *argv[])
options = xmemdup(global_long_options, sizeof global_long_options);
allocated_options = ARRAY_SIZE(global_long_options);
n_options = n_global_long_options;
- for (p = all_commands; p->name; p++) {
+ for (p = get_all_commands(); p->name; p++) {
if (p->options[0]) {
char *save_ptr = NULL;
char *name;
if (shash_is_empty(&commands)) {
const struct vtep_ctl_command_syntax *p;
- for (p = all_commands; p->name; p++) {
+ for (p = get_all_commands(); p->name; p++) {
shash_add_assert(&commands, p->name, p);
}
}
{NULL, 0, 0, NULL, NULL, NULL, NULL, RO},
};
+static const struct vtep_ctl_command_syntax *
+get_all_commands(void)
+{
+ return all_commands;
+}