2 * Copyright (c) 2014 Nicira, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 * OVS tests directory contains many small test programs. One down side
24 * of building them as individual programs is that they all have to be
25 * linked whenever a library function is modified.
27 * ovstest is an attempt to improve the overall build time by linking
28 * all test programs into a single program, ovs-test. Regardless of
29 * the number of test programs, linking will be done only once to produce
32 * With ovs-test, each test programs now becomes a sub program of ovstest.
33 * For example, 'mytest' program, can now be invoked as 'ovs mytest'.
35 * 'ovstest --help' will list all test programs can be invoked.
37 * The Usage comment section below documents how a new test program can
38 * be added to ovs-test.
41 typedef void (*ovstest_func)(int argc, char *argv[]);
44 ovstest_register(const char *test_name, ovstest_func f,
45 const struct command * sub_commands);
50 * For each test sub program, its 'main' program should be named as
51 * '<test_name>_main()'.
53 * OVSTEST_REGISTER register the sub program with ovs-test top level
54 * command line parser. <test_name> is expected as argv[1] when invoking
57 * In case the test program has sub commands, its command array can be
58 * passed in as <sub_command>. Otherwise, NULL can be used instead.
63 * Suppose the test program is called my-test.c
67 * my_test_main(int argc, char *argv[])
72 * // The last parameter is NULL in case my-test.c does
73 * // not have sub commands. Otherwise, its command
74 * // array can replace the NULL here.
76 * OVSTEST_REGISTER("my-test", my_test_main, NULL);
79 #define OVSTEST_REGISTER(name, function, sub_commands) \
80 OVS_CONSTRUCTOR(register_##function) { \
81 ovstest_register(name, function, sub_commands); \