]>
Commit | Line | Data |
---|---|---|
3932d8db AZ |
1 | /* |
2 | * Copyright (c) 2014 Nicira, Inc. | |
3 | * | |
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: | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
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. | |
15 | */ | |
16 | ||
17 | #ifndef OVSTEST_H | |
18 | #define OVSTEST_H | |
19 | ||
20 | /* Overview | |
21 | * ======== | |
22 | * | |
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. | |
26 | * | |
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 | |
30 | * ovstest. | |
31 | * | |
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'. | |
34 | * | |
35 | * 'ovstest --help' will list all test programs can be invoked. | |
36 | * | |
37 | * The Usage comment section below documents how a new test program can | |
38 | * be added to ovs-test. | |
39 | */ | |
40 | ||
41 | typedef void (*ovstest_func)(int argc, char *argv[]); | |
42 | ||
43 | void | |
44 | ovstest_register(const char *test_name, ovstest_func f, | |
45 | const struct command * sub_commands); | |
46 | ||
47 | /* Usage | |
48 | * ===== | |
49 | * | |
50 | * For each test sub program, its 'main' program should be named as | |
51 | * '<test_name>_main()'. | |
52 | * | |
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 | |
55 | * ovs-test. | |
56 | * | |
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. | |
59 | * | |
60 | * Example: | |
61 | * ---------- | |
62 | * | |
63 | * Suppose the test program is called my-test.c | |
64 | * ... | |
65 | * | |
66 | * static void | |
67 | * my_test_main(int argc, char *argv[]) | |
68 | * { | |
69 | * .... | |
70 | * } | |
71 | * | |
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. | |
75 | * | |
76 | * OVSTEST_REGISTER("my-test", my_test_main, NULL); | |
77 | */ | |
78 | ||
79 | #define OVSTEST_REGISTER(name, function, sub_commands) \ | |
80 | OVS_CONSTRUCTOR(register_##function) { \ | |
81 | ovstest_register(name, function, sub_commands); \ | |
82 | } | |
83 | ||
84 | #endif |