# BRCM_VERSION=3
[bcm963xx.git] / userapps / opensource / net-snmp / testing / T.c
1 /*
2  * T.c
3  *
4  * Expected SUCCESSes for all tests:    FIX [+ FIX ...]
5  *                                      (List number of lines containing the
6  *                                       string "SUCCESS" that are expected
7  *                                       to be printed to stdout.)
8  *
9  * Returns:
10  *      Number of FAILUREs.
11  *
12  * FIX  Short test description/table of contents.       SUCCESSes: FIX
13  */
14
15 #include <net-snmp/net-snmp-config.h>
16
17 #include <sys/types.h>
18 #include <stdio.h>
19 #ifdef HAVE_STDLIB_H
20 #include <stdlib.h>
21 #endif
22
23 /*
24  * #include ... 
25  */
26
27 extern char    *optarg;
28 extern int      optind, optopt, opterr;
29
30
31
32 /*
33  * Globals, &c...
34  */
35 char           *local_progname;
36
37 #define USAGE   "Usage: %s [-h][-aS]"
38 #define OPTIONLIST      "ahS"
39
40 int             doalltests = 0, dosomething = 0;
41
42 #define ALLOPTIONS      (doalltests + dosomething)
43
44
45
46 #define LOCAL_MAXBUF    (1024 * 8)
47 #define NL              "\n"
48
49 #define OUTPUT(o)       fprintf(stdout, "\n\n%s\n\n", o);
50
51 #define SUCCESS(s)                                      \
52 {                                                       \
53         if (!failcount)                                 \
54                 fprintf(stdout, "\nSUCCESS: %s\n", s);  \
55 }
56
57 #define FAILED(e, f)                                    \
58 {                                                       \
59         if (e != SNMPERR_SUCCESS) {                     \
60                 fprintf(stdout, "\nFAILED: %s\n", f);   \
61                 failcount += 1;                         \
62         }                                               \
63 }
64
65
66
67
68
69 /*
70  * Prototypes.
71  */
72 void            usage(FILE * ofp);
73
74 int             test_dosomething(void);
75
76
77
78
79 int
80 main(int argc, char **argv)
81 {
82     int             rval = SNMPERR_SUCCESS, failcount = 0;
83     char            ch;
84
85     local_progname = argv[0];
86
87     EM(-1);                     /* */
88
89     /*
90      * Parse.
91      */
92     while ((ch = getopt(argc, argv, OPTIONLIST)) != EOF) {
93         switch (ch) {
94         case 'a':
95             doalltests = 1;
96             break;
97         case 'S':
98             dosomething = 1;
99             break;
100         case 'h':
101             rval = 0;
102         default:
103             usage(stdout);
104             exit(rval);
105         }
106
107         argc -= 1;
108         argv += 1;
109         if (optarg) {
110             argc -= 1;
111             argv += 1;
112             optarg = NULL;
113         }
114         optind = 1;
115     }                           /* endwhile getopt */
116
117     if ((argc > 1)) {
118         usage(stdout);
119         exit(1000);
120
121     } else if (ALLOPTIONS != 1) {
122         usage(stdout);
123         exit(1000);
124     }
125
126
127     /*
128      * Test stuff.
129      */
130     if (dosomething || doalltests) {
131         failcount += test_dosomething();
132     }
133
134
135     /*
136      * Cleanup.
137      */
138     return failcount;
139
140 }                               /* end main() */
141
142
143
144
145
146 void
147 usage(FILE * ofp)
148 {
149     fprintf(ofp,
150             USAGE
151             "" NL
152             "   -a              All tests." NL
153             "   -S              Test something." NL
154             "   -h              Help." NL "" NL, local_progname);
155
156 }                               /* end usage() */
157
158
159
160
161 #ifdef EXAMPLE
162 #endif                          /* EXAMPLE */
163 /*******************************************************************-o-******
164  * test_dosomething
165  *
166  * Returns:
167  *      Number of failures.
168  *
169  *
170  * Test template.
171  */
172 int
173 test_dosomething(void)
174 {
175     int             rval = SNMPERR_SUCCESS, failcount = 0;
176
177     EM0(1, "UNIMPLEMENTED");    /* EM(1); /* */
178
179   test_dosomething_quit:
180     return failcount;
181
182 }                               /* end test_dosomething() */