]>
git.proxmox.com Git - ceph.git/blob - ceph/src/civetweb/test/main.c
1 /* Copyright (c) 2015 the Civetweb developers
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 #include "civetweb_check.h"
24 #include "public_func.h"
25 #include "public_server.h"
27 #include "private_exe.h"
33 /* This unit test file uses the excellent Check unit testing library.
34 * The API documentation is available here:
35 * http://check.sourceforge.net/doc/check_html/index.html
39 main(const int argc
, char *argv
[])
41 // Determine what tests to run
42 const char *suite
= NULL
;
43 const char *const suite_arg
= "--suite=";
44 const size_t suite_arg_size
= strlen(suite_arg
);
45 const char *test_case
= NULL
;
46 const char *const test_case_arg
= "--test-case=";
47 const size_t test_case_arg_size
= strlen(test_case_arg
);
48 const char *const test_dir_arg
= "--test-dir=";
49 const size_t test_dir_arg_size
= strlen(test_dir_arg
);
50 for (int i
= 1; i
< argc
; ++i
) {
51 if (0 == strncmp(suite_arg
, argv
[i
], suite_arg_size
)
52 && (strlen(argv
[i
]) > suite_arg_size
)) {
53 suite
= &argv
[i
][suite_arg_size
];
54 } else if (0 == strncmp(test_case_arg
, argv
[i
], test_case_arg_size
)
55 && (strlen(argv
[i
]) > test_case_arg_size
)) {
56 test_case
= &argv
[i
][test_case_arg_size
];
57 } else if (0 == strncmp(test_dir_arg
, argv
[i
], test_dir_arg_size
)
58 && (strlen(argv
[i
]) > test_dir_arg_size
)) {
59 set_test_directory(&argv
[i
][test_dir_arg_size
]);
60 } else if (0 == strcmp("--help", argv
[i
])) {
62 "Usage: %s [options]\n"
63 " --suite=Suite Determines the suite to run\n"
64 " --test-case='Test Case' Determines the test case to run\n"
65 " --test-dir='folder/path' The location of the test directory "
67 " 'fixtures' and 'expected\n",
71 fprintf(stderr
, "Invalid argument: %s\n", argv
[i
]);
76 /* Run up the tests */
77 SRunner
*const srunner
= srunner_create(make_public_func_suite());
78 srunner_add_suite(srunner
, make_public_server_suite());
79 srunner_add_suite(srunner
, make_private_suite());
80 srunner_add_suite(srunner
, make_private_exe_suite());
82 /* Write test logs to a file */
83 srunner_set_log(srunner
, "test.log");
84 srunner_set_xml(srunner
, "test.xml");
86 /* CK_NORMAL offers not enough diagnosis during setup phase*/
87 srunner_run(srunner
, suite
, test_case
, CK_VERBOSE
);
89 const int number_run
= srunner_ntests_run(srunner
);
90 const int number_failed
= srunner_ntests_failed(srunner
);
91 srunner_free(srunner
);
92 return (number_failed
== 0) && (number_run
!= 0) ? EXIT_SUCCESS