EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
testMain.h
1 /*************************************************************************\
2 * Copyright (c) 2006 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * SPDX-License-Identifier: EPICS
5 * EPICS BASE is distributed subject to a Software License Agreement found
6 * in file LICENSE that is included with this distribution.
7 \*************************************************************************/
8 
9 #ifndef INC_testMain_H
10 #define INC_testMain_H
11 
12 /* This header defines a convenience macro for use by pure test programs.
13  * A pure test program cannot take any arguments since it must be fully
14  * automatable. If your program needs to use argv/argc, it may be doing
15  * measurements not unit and/or regression testing. On Host architectures
16  * these programs needs to be named main and take dummy argc/argv args,
17  * but on vxWorks and RTEMS they must be named as the test program.
18  *
19  * Use this macro as follows:
20  *
21  * #include "testMain.h"
22  * #include "epicsUnitTest.h"
23  *
24  * MAIN(myProgTest) {
25  * testPlan(...);
26  * testOk(...)
27  * return testDone();
28  * }
29  */
30 
31 #if defined(__rtems__)
32  #ifdef __cplusplus
33  #define MAIN(prog) extern "C" int prog(void); extern "C" int main() __attribute__((weak, alias(#prog))); extern "C" int prog(void)
34  #else
35  #define MAIN(prog) int prog(); int main() __attribute__((weak, alias(#prog))); int prog()
36  #endif
37 #elif defined(vxWorks)
38  #ifdef __cplusplus
39  #define MAIN(prog) extern "C" int prog(void)
40  #else
41  #define MAIN(prog) int prog()
42  #endif
43 #else
44  #ifdef __cplusplus
45  #define MAIN(prog) int main(int /*argc*/, char * /*argv*/ [] )
46  #else
47  #define MAIN(prog) int main(int argc, char *argv[] )
48  #endif
49 #endif
50 
51 
52 #endif /* INC_testMain_H */