]> git.proxmox.com Git - mirror_ovs.git/blob - tests/ovstest.h
ovstest: Fix a typo in a comment.
[mirror_ovs.git] / tests / ovstest.h
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 #include "compiler.h"
21
22 /* Overview
23 * ========
24 *
25 * OVS tests directory contains many small test programs. One down side
26 * of building them as individual programs is that they all have to be
27 * linked whenever a library function is modified.
28 *
29 * ovstest is an attempt to improve the overall build time by linking
30 * all test programs into a single program, ovs-test. Regardless of
31 * the number of test programs, linking will be done only once to produce
32 * ovstest.
33 *
34 * With ovstest, each test programs now becomes a sub program of ovstest.
35 * For example, 'mytest' program, can now be invoked as 'ovstest mytest'.
36 *
37 * 'ovstest --help' will list all test programs can be invoked.
38 *
39 * The 'Usage' section below documents how to add a new sub program
40 * to ovstest using OVSTEST_REIGSTER macros.
41 */
42
43 typedef void (*ovstest_func)(int argc, char *argv[]);
44 void ovstest_register(const char *test_name, ovstest_func f);
45
46 /* Usage
47 * =====
48 *
49 * For each sub test program, its 'main' program should be named as
50 * '<test_name>_main()'.
51 *
52 * The 'main' programs should be registered with ovstest as a sub program.
53 * OVSTEST_REGISTER(name, function)
54 *
55 * 'name' will be name of the test program. It is expected as argv[1] when
56 * invoking with ovstest.
57 *
58 * 'function' is the 'main' program mentioned above.
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 * OVSTEST_REGISTER("my-test", my_test_main);
73 */
74 #define OVSTEST_REGISTER(name, function) \
75 OVS_CONSTRUCTOR(register_##function) { \
76 ovstest_register(name, function); \
77 }
78
79 #endif