/*
- * Copyright (c) 2011, 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
static void
-test_log_2_floor(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_log_2_floor(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
int n;
}
static void
-test_ctz(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_ctz(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
int n;
}
static void
-test_clz(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_clz(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
int n;
}
static void
-test_round_up_pow2(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_round_up_pow2(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
int n;
}
static void
-test_round_down_pow2(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_round_down_pow2(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
int n;
}
static void
-test_count_1bits(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_count_1bits(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
uint64_t bits[64];
int i;
}
static void
-test_bitwise_copy(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_bitwise_copy(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
unsigned int n_loops;
int src_ofs;
}
static void
-test_bitwise_zero(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_bitwise_zero(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
unsigned int n_loops;
int dst_ofs;
}
static void
-test_bitwise_one(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_bitwise_one(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
unsigned int n_loops;
int dst_ofs;
}
static void
-test_bitwise_is_all_zeros(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_bitwise_is_all_zeros(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
int n_loops;
}
static void
-test_follow_symlinks(int argc, char *argv[])
+test_follow_symlinks(struct ovs_cmdl_context *ctx)
{
int i;
- for (i = 1; i < argc; i++) {
- char *target = follow_symlinks(argv[i]);
+ for (i = 1; i < ctx->argc; i++) {
+ char *target = follow_symlinks(ctx->argv[i]);
puts(target);
free(target);
}
}
static void
-test_assert(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_assert(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
ovs_assert(false);
}
static void
-test_ovs_scan(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_ovs_scan(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
char str[16], str2[16], str3[16];
long double ld, ld2;
long l, l2;
int i, i2;
- ovs_assert(ovs_scan("", ""));
ovs_assert(ovs_scan("", " "));
ovs_assert(ovs_scan(" ", " "));
ovs_assert(ovs_scan(" ", " "));
}
static void
-test_snprintf(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_snprintf(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
char s[16];
#ifndef _WIN32
static void
-test_file_name(int argc, char *argv[])
+test_file_name(struct ovs_cmdl_context *ctx)
{
int i;
- for (i = 1; i < argc; i++) {
+ for (i = 1; i < ctx->argc; i++) {
char *dir, *base;
- dir = dir_name(argv[i]);
+ dir = dir_name(ctx->argv[i]);
puts(dir);
free(dir);
- base = base_name(argv[i]);
+ base = base_name(ctx->argv[i]);
puts(base);
free(base);
}
static void
test_util_main(int argc, char *argv[])
{
+ struct ovs_cmdl_context ctx = { .argc = 0, };
set_program_name(argv[0]);
parse_options(argc, argv);
/* On Windows, stderr is fully buffered if connected to a pipe.
* POSIX doesn't define the circumstances in which stderr is
* fully buffered either. */
setvbuf(stderr, NULL, _IONBF, 0);
- ovs_cmdl_run_command(argc - optind, argv + optind, commands);
+ ctx.argc = argc - optind;
+ ctx.argv = argv + optind;
+ ovs_cmdl_run_command(&ctx, commands);
}
OVSTEST_REGISTER("test-util", test_util_main);