1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. 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.
22 /* Top-level pool which can be used by tests. */
25 void apr_assert_success(CuTest* tc, const char* context, apr_status_t rv)
27 if (rv == APR_ENOTIMPL) {
28 CuNotImpl(tc, context);
31 if (rv != APR_SUCCESS) {
32 char buf[STRING_MAX], ebuf[128];
33 sprintf(buf, "%s (%d): %s\n", context, rv,
34 apr_strerror(rv, ebuf, sizeof ebuf));
39 static const struct testlist {
41 CuSuite *(*func)(void);
44 {"testtime", testtime},
46 {"testipsub", testipsub},
47 {"testmmap", testmmap},
49 {"testtable", testtable},
50 {"testhash", testhash},
51 {"testsleep", testsleep},
52 {"testpool", testpool},
54 {"testfile", testfile},
55 {"testfileinfo", testfileinfo},
56 {"testpipe", testpipe},
59 {"testrand", testrand},
62 {"testsockets", testsockets},
63 {"testsockopt", testsockopt},
64 {"testproc", testproc},
65 {"testprocmutex", testprocmutex},
66 {"testpoll", testpoll},
67 {"testlock", testlock},
68 {"testthread", testthread},
69 {"testargs", testgetopt},
70 {"testnames", testnames},
71 {"testuser", testuser},
72 {"testpath", testpath},
77 int main(int argc, char *argv[])
79 CuSuiteList *alltests = NULL;
80 CuString *output = CuStringNew();
83 int list_provided = 0;
86 atexit(apr_terminate);
90 apr_pool_create(&p, NULL);
92 /* see if we're in exclude mode, see if list of testcases provided */
93 for (i = 1; i < argc; i++) {
94 if (!strcmp(argv[i], "-v")) {
97 if (!strcmp(argv[i], "-x")) {
101 if (!strcmp(argv[i], "-l")) {
102 for (i = 0; tests[i].func != NULL; i++) {
103 printf("%s\n", tests[i].testname);
107 if (argv[i][0] == '-') {
108 fprintf(stderr, "invalid option: `%s'\n", argv[i]);
114 if (!list_provided) {
116 alltests = CuSuiteListNew("All APR Tests");
117 for (i = 0; tests[i].func != NULL; i++) {
118 CuSuiteListAdd(alltests, tests[i].func());
122 /* add everything but the tests listed */
123 alltests = CuSuiteListNew("Partial APR Tests");
124 for (i = 0; tests[i].func != NULL; i++) {
125 int this_test_excluded = 0;
128 for (j = 1; j < argc && !this_test_excluded; j++) {
129 if (!strcmp(argv[j], tests[i].testname)) {
130 this_test_excluded = 1;
133 if (!this_test_excluded) {
134 CuSuiteListAdd(alltests, tests[i].func());
139 /* add only the tests listed */
140 alltests = CuSuiteListNew("Partial APR Tests");
141 for (i = 1; i < argc; i++) {
145 if (argv[i][0] == '-') {
148 for (j = 0; tests[j].func != NULL; j++) {
149 if (!strcmp(argv[i], tests[j].testname)) {
150 CuSuiteListAdd(alltests, tests[j].func());
155 fprintf(stderr, "invalid test name: `%s'\n", argv[i]);
161 CuSuiteListRunWithSummary(alltests);
162 i = CuSuiteListDetails(alltests, output);
163 printf("%s\n", output->buffer);
165 return i > 0 ? 1 : 0;