• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

proftpd / proftpd / 14552756858

19 Apr 2025 08:53PM UTC coverage: 93.03% (+0.4%) from 92.667%
14552756858

push

github

51358 of 55206 relevant lines covered (93.03%)

213.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.1
/tests/api/tests.c
1
/*
2
 * ProFTPD - FTP server API testsuite
3
 * Copyright (c) 2008-2021 The ProFTPD Project team
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18
 *
19
 * As a special exemption, The ProFTPD Project team and other respective
20
 * copyright holders give permission to link this program with OpenSSL, and
21
 * distribute the resulting executable, without including the source code for
22
 * OpenSSL in the source distribution.
23
 */
24

25
#include "tests.h"
26

27
struct testsuite_info {
28
  const char *name;
29
  Suite *(*get_suite)(void);
30
};
31

32
static struct testsuite_info suites[] = {
33
  { "pool",                 tests_get_pool_suite },
34
  { "array",                 tests_get_array_suite },
35
  { "str",                 tests_get_str_suite },
36
  { "sets",                 tests_get_sets_suite },
37
  { "timers",                 tests_get_timers_suite },
38
  { "table",                 tests_get_table_suite },
39
  { "var",                 tests_get_var_suite },
40
  { "event",                 tests_get_event_suite },
41
  { "env",                 tests_get_env_suite },
42
  { "random",                 tests_get_random_suite },
43
  { "version",                 tests_get_version_suite },
44
  { "feat",                 tests_get_feat_suite },
45
  { "netaddr",                 tests_get_netaddr_suite },
46
  { "netacl",                tests_get_netacl_suite },
47
  { "class",                tests_get_class_suite },
48
  { "regexp",                tests_get_regexp_suite },
49
  { "expr",                tests_get_expr_suite },
50
  { "scoreboard",        tests_get_scoreboard_suite },
51
  { "stash",                tests_get_stash_suite },
52
  { "modules",                tests_get_modules_suite },
53
  { "cmd",                tests_get_cmd_suite },
54
  { "response",                tests_get_response_suite },
55
  { "fsio",                tests_get_fsio_suite },
56
  { "netio",                tests_get_netio_suite },
57
  { "trace",                tests_get_trace_suite },
58
  { "parser",                tests_get_parser_suite },
59
  { "pidfile",                tests_get_pidfile_suite },
60
  { "config",                tests_get_config_suite },
61
  { "auth",                tests_get_auth_suite },
62
  { "filter",                tests_get_filter_suite },
63
  { "inet",                tests_get_inet_suite },
64
  { "data",                tests_get_data_suite },
65
  { "ascii",                tests_get_ascii_suite },
66
  { "ctrls",                tests_get_ctrls_suite },
67
  { "help",                tests_get_help_suite },
68
  { "rlimit",                tests_get_rlimit_suite },
69
  { "encode",                tests_get_encode_suite },
70
  { "privs",                tests_get_privs_suite },
71
  { "display",                tests_get_display_suite },
72
  { "misc",                tests_get_misc_suite },
73
  { "json",                tests_get_json_suite },
74
  { "jot",                tests_get_jot_suite },
75
  { "redis",                tests_get_redis_suite },
76
  { "error",                tests_get_error_suite },
77

78
  { NULL, NULL }
79
};
80

81
static Suite *tests_get_suite(const char *suite) {
×
82
  register unsigned int i;
×
83

84
  for (i = 0; suites[i].name != NULL; i++) {
×
85
    if (strcmp(suite, suites[i].name) == 0) {
×
86
      return (*suites[i].get_suite)();
×
87
    }
88
  }
89

90
  return NULL;
91
}
92

93
int main(int argc, char *argv[]) {
890✔
94
  const char *log_file = "api-tests.log";
890✔
95
  const char *xml_file = "api-tests.xml";
890✔
96
  int nfailed = 0;
890✔
97
  SRunner *runner = NULL;
890✔
98
  char *requested = NULL;
890✔
99

100
  runner = srunner_create(NULL);
890✔
101

102
  /* XXX This log name should be set outside this code, e.g. via environment
103
   * variable or command-line option.
104
   */
105
  srunner_set_log(runner, log_file);
890✔
106
  if (getenv("PR_XML_TEST_OUTPUT")) {
890✔
107
    srunner_set_xml(runner, xml_file);
×
108
  }
109

110
  requested = getenv("PR_TEST_SUITE");
890✔
111
  if (requested != NULL) {
890✔
112
    Suite *suite;
×
113

114
    suite = tests_get_suite(requested);
×
115
    if (suite != NULL) {
×
116
      srunner_add_suite(runner, suite);
×
117

118
    } else {
119
      fprintf(stderr, "No such test suite ('%s') requested via PR_TEST_SUITE\n",
×
120
        requested);
121
      srunner_free(runner);
×
122
      return EXIT_FAILURE;
×
123
    }
124

125
  } else {
126
    register unsigned int i;
127

128
    for (i = 0; suites[i].name; i++) {
40,050✔
129
      Suite *suite;
39,160✔
130

131
      suite = (suites[i].get_suite)();
39,160✔
132
      if (suite != NULL) {
39,160✔
133
        srunner_add_suite(runner, suite);
39,160✔
134
      }
135
    }
136
  }
137

138
  /* Configure the Trace API to write to stderr. */
139
  pr_trace_use_stderr(TRUE);
890✔
140

141
  requested = getenv("PR_TEST_NOFORK");
890✔
142
  if (requested != NULL) {
890✔
143
    srunner_set_fork_status(runner, CK_NOFORK);
×
144

145
  } else {
146
    requested = getenv("CK_DEFAULT_TIMEOUT");
890✔
147
    if (requested == NULL) {
890✔
148
      setenv("CK_DEFAULT_TIMEOUT", "60", 1);
890✔
149
    }
150
  }
151

152
  srunner_run_all(runner, CK_NORMAL);
890✔
153

154
  nfailed = srunner_ntests_failed(runner);
1✔
155

156
  if (runner != NULL) {
1✔
157
    srunner_free(runner);
1✔
158
  }
159

160
  if (nfailed != 0) {
1✔
161
    fprintf(stderr, "-------------------------------------------------\n");
×
162
    fprintf(stderr, " FAILED %d %s\n\n", nfailed,
×
163
      nfailed != 1 ? "tests" : "test");
164
    fprintf(stderr, " Please send email to:\n\n");
×
165
    fprintf(stderr, "   proftp-devel@lists.sourceforge.net\n\n");
×
166
    fprintf(stderr, " containing the `%s' file (in the tests/ directory)\n", log_file);
×
167
    fprintf(stderr, " and the output from running `proftpd -V'\n");
×
168
    fprintf(stderr, "-------------------------------------------------\n");
×
169

170
    return EXIT_FAILURE;
×
171
  }
172

173
  return EXIT_SUCCESS;
174
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc