| 1 |
/* Unit testing. |
| 2 |
Copyright (C) 2005-2011, 2015, 2018-2024 Free Software Foundation, |
| 3 |
Inc. |
| 4 |
|
| 5 |
This file is part of GNU Wget. |
| 6 |
|
| 7 |
GNU Wget is free software; you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU General Public License as published by |
| 9 |
the Free Software Foundation; either version 3 of the License, or |
| 10 |
(at your option) any later version. |
| 11 |
|
| 12 |
GNU Wget is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with Wget. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
Additional permission under GNU GPL version 3 section 7 |
| 21 |
|
| 22 |
If you modify this program, or any covered work, by linking or |
| 23 |
combining it with the OpenSSL project's OpenSSL library (or a |
| 24 |
modified version of that library), containing parts covered by the |
| 25 |
terms of the OpenSSL or SSLeay licenses, the Free Software Foundation |
| 26 |
grants you additional permission to convey the resulting work. |
| 27 |
Corresponding Source for a non-source form of such a combination |
| 28 |
shall include the source code for the parts of OpenSSL used as well |
| 29 |
as that of the covered work. */ |
| 30 |
|
| 31 |
#include "wget.h" |
| 32 |
|
| 33 |
#include <stdio.h> |
| 34 |
#ifdef ENABLE_NLS |
| 35 |
# include <locale.h> |
| 36 |
#endif |
| 37 |
|
| 38 |
#include "unit-tests.h" |
| 39 |
|
| 40 |
extern const char *program_argstring; |
| 41 |
|
| 42 |
static int tests_run; |
| 43 |
|
| 44 |
static const char * |
| 45 |
all_tests(void) |
| 46 |
{ |
| 47 |
#ifdef HAVE_METALINK |
| 48 |
mu_run_test (test_find_key_value); |
| 49 |
mu_run_test (test_find_key_values); |
| 50 |
mu_run_test (test_has_key); |
| 51 |
#endif |
| 52 |
mu_run_test (test_parse_content_disposition); |
| 53 |
mu_run_test (test_parse_range_header); |
| 54 |
mu_run_test (test_subdir_p); |
| 55 |
mu_run_test (test_dir_matches_p); |
| 56 |
mu_run_test (test_commands_sorted); |
| 57 |
mu_run_test (test_cmd_spec_restrict_file_names); |
| 58 |
mu_run_test (test_path_simplify); |
| 59 |
mu_run_test (test_append_uri_pathel); |
| 60 |
mu_run_test (test_are_urls_equal); |
| 61 |
mu_run_test (test_uri_merge); |
| 62 |
mu_run_test (test_is_robots_txt_url); |
| 63 |
#ifdef HAVE_HSTS |
| 64 |
mu_run_test (test_hsts_new_entry); |
| 65 |
mu_run_test (test_hsts_url_rewrite_superdomain); |
| 66 |
mu_run_test (test_hsts_url_rewrite_congruent); |
| 67 |
mu_run_test (test_hsts_read_database); |
| 68 |
#endif |
| 69 |
mu_run_test (test_parse_netrc); |
| 70 |
mu_run_test (test_retr_rate); |
| 71 |
|
| 72 |
return NULL; |
| 73 |
} |
| 74 |
|
| 75 |
extern const char *program_name; /* Needed by lib/error.c. */ |
| 76 |
|
| 77 |
int |
| 78 |
main (int argc _GL_UNUSED, const char *argv[]) |
| 79 |
{ |
| 80 |
const char *result; |
| 81 |
|
| 82 |
printf ("[DEBUG] Testing...\n\n"); |
| 83 |
#ifdef ENABLE_NLS |
| 84 |
/* Set the current locale. */ |
| 85 |
setlocale (LC_ALL, ""); |
| 86 |
/* Set the text message domain. */ |
| 87 |
bindtextdomain ("wget", LOCALEDIR); |
| 88 |
textdomain ("wget"); |
| 89 |
#endif /* ENABLE_NLS */ |
| 90 |
|
| 91 |
program_name = argv[0]; |
| 92 |
|
| 93 |
result = all_tests(); |
| 94 |
|
| 95 |
if (result != NULL) |
| 96 |
{ |
| 97 |
puts (result); |
| 98 |
} |
| 99 |
else |
| 100 |
{ |
| 101 |
printf ("ALL TESTS PASSED\n"); |
| 102 |
} |
| 103 |
|
| 104 |
printf ("Tests run: %d\n", tests_run); |
| 105 |
|
| 106 |
return result != 0; |
| 107 |
} |
| 108 |
|
| 109 |
/* |
| 110 |
* vim: et ts=2 sw=2 |
| 111 |
*/ |