]> git.proxmox.com Git - ceph.git/blame - ceph/src/civetweb/test/main.c
buildsys: switch source download to quincy
[ceph.git] / ceph / src / civetweb / test / main.c
CommitLineData
11fdf7f2 1/* Copyright (c) 2015-2017 the Civetweb developers
7c673cae
FG
2 *
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:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
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
19 * THE SOFTWARE.
20 */
21
22#include "civetweb_check.h"
23#include "shared.h"
24#include "public_func.h"
25#include "public_server.h"
26#include "private.h"
11fdf7f2 27#include "timertest.h"
7c673cae
FG
28#include "private_exe.h"
29
30#include <stdlib.h>
31#include <stdio.h>
32#include <string.h>
33
34/* This unit test file uses the excellent Check unit testing library.
35 * The API documentation is available here:
36 * http://check.sourceforge.net/doc/check_html/index.html
37 */
38
39int
40main(const int argc, char *argv[])
41{
42 // Determine what tests to run
43 const char *suite = NULL;
44 const char *const suite_arg = "--suite=";
45 const size_t suite_arg_size = strlen(suite_arg);
46 const char *test_case = NULL;
47 const char *const test_case_arg = "--test-case=";
48 const size_t test_case_arg_size = strlen(test_case_arg);
49 const char *const test_dir_arg = "--test-dir=";
50 const size_t test_dir_arg_size = strlen(test_dir_arg);
11fdf7f2
TL
51
52 SRunner *srunner;
53 int number_run = 0;
54 int number_failed = 0;
55
56 int i;
57
58 for (i = 1; i < argc; ++i) {
7c673cae
FG
59 if (0 == strncmp(suite_arg, argv[i], suite_arg_size)
60 && (strlen(argv[i]) > suite_arg_size)) {
61 suite = &argv[i][suite_arg_size];
62 } else if (0 == strncmp(test_case_arg, argv[i], test_case_arg_size)
63 && (strlen(argv[i]) > test_case_arg_size)) {
64 test_case = &argv[i][test_case_arg_size];
65 } else if (0 == strncmp(test_dir_arg, argv[i], test_dir_arg_size)
66 && (strlen(argv[i]) > test_dir_arg_size)) {
67 set_test_directory(&argv[i][test_dir_arg_size]);
68 } else if (0 == strcmp("--help", argv[i])) {
69 printf(
70 "Usage: %s [options]\n"
71 " --suite=Suite Determines the suite to run\n"
72 " --test-case='Test Case' Determines the test case to run\n"
73 " --test-dir='folder/path' The location of the test directory "
74 "with the \n"
75 " 'fixtures' and 'expected\n",
76 argv[0]);
77 exit(EXIT_SUCCESS);
78 } else {
79 fprintf(stderr, "Invalid argument: %s\n", argv[i]);
80 exit(EXIT_FAILURE);
81 }
82 }
83
84 /* Run up the tests */
11fdf7f2 85 srunner = srunner_create(make_public_func_suite());
7c673cae
FG
86 srunner_add_suite(srunner, make_public_server_suite());
87 srunner_add_suite(srunner, make_private_suite());
88 srunner_add_suite(srunner, make_private_exe_suite());
11fdf7f2 89 srunner_add_suite(srunner, make_timertest_suite());
7c673cae
FG
90
91 /* Write test logs to a file */
92 srunner_set_log(srunner, "test.log");
93 srunner_set_xml(srunner, "test.xml");
94
95 /* CK_NORMAL offers not enough diagnosis during setup phase*/
96 srunner_run(srunner, suite, test_case, CK_VERBOSE);
97
11fdf7f2
TL
98 number_run = srunner_ntests_run(srunner);
99 number_failed = srunner_ntests_failed(srunner);
7c673cae
FG
100 srunner_free(srunner);
101 return (number_failed == 0) && (number_run != 0) ? EXIT_SUCCESS
102 : EXIT_FAILURE;
103}