2005-10-27 22:13:40 +08:00
|
|
|
/* Unit testing.
|
2020-01-10 19:56:08 +08:00
|
|
|
Copyright (C) 2005-2011, 2015, 2018-2020 Free Software Foundation,
|
2019-02-10 18:29:48 +08:00
|
|
|
Inc.
|
2005-10-27 22:13:40 +08:00
|
|
|
|
|
|
|
This file is part of GNU Wget.
|
|
|
|
|
|
|
|
GNU Wget is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-07-10 13:53:22 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2005-10-27 22:13:40 +08:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
GNU Wget is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-07-10 13:53:22 +08:00
|
|
|
along with Wget. If not, see <http://www.gnu.org/licenses/>.
|
2005-10-27 22:13:40 +08:00
|
|
|
|
2007-11-28 16:05:33 +08:00
|
|
|
Additional permission under GNU GPL version 3 section 7
|
|
|
|
|
|
|
|
If you modify this program, or any covered work, by linking or
|
|
|
|
combining it with the OpenSSL project's OpenSSL library (or a
|
|
|
|
modified version of that library), containing parts covered by the
|
|
|
|
terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
|
|
|
|
grants you additional permission to convey the resulting work.
|
|
|
|
Corresponding Source for a non-source form of such a combination
|
|
|
|
shall include the source code for the parts of OpenSSL used as well
|
|
|
|
as that of the covered work. */
|
2005-10-27 22:13:40 +08:00
|
|
|
|
2012-12-09 22:41:18 +08:00
|
|
|
#include "wget.h"
|
|
|
|
|
2005-10-27 22:13:40 +08:00
|
|
|
#include <stdio.h>
|
2014-06-16 23:20:30 +08:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
# include <locale.h>
|
|
|
|
#endif
|
2005-10-27 22:13:40 +08:00
|
|
|
|
2018-02-09 19:42:19 +08:00
|
|
|
#include "unit-tests.h"
|
2005-10-27 22:13:40 +08:00
|
|
|
|
2020-02-22 20:40:50 +08:00
|
|
|
extern const char *program_argstring;
|
2011-11-05 05:25:00 +08:00
|
|
|
|
2015-06-14 04:34:36 +08:00
|
|
|
static int tests_run;
|
2005-10-27 22:13:40 +08:00
|
|
|
|
2006-03-15 22:55:29 +08:00
|
|
|
static const char *
|
2014-11-17 18:28:20 +08:00
|
|
|
all_tests(void)
|
2005-10-27 22:13:40 +08:00
|
|
|
{
|
2015-06-23 22:36:21 +08:00
|
|
|
#ifdef HAVE_METALINK
|
|
|
|
mu_run_test (test_find_key_value);
|
2015-06-23 23:51:32 +08:00
|
|
|
mu_run_test (test_find_key_values);
|
2015-06-23 22:46:39 +08:00
|
|
|
mu_run_test (test_has_key);
|
2015-06-23 22:36:21 +08:00
|
|
|
#endif
|
2006-02-03 17:33:57 +08:00
|
|
|
mu_run_test (test_parse_content_disposition);
|
2015-08-30 01:38:39 +08:00
|
|
|
mu_run_test (test_parse_range_header);
|
2006-03-15 22:55:29 +08:00
|
|
|
mu_run_test (test_subdir_p);
|
|
|
|
mu_run_test (test_dir_matches_p);
|
2008-04-23 13:59:22 +08:00
|
|
|
mu_run_test (test_commands_sorted);
|
2006-06-13 21:58:33 +08:00
|
|
|
mu_run_test (test_cmd_spec_restrict_file_names);
|
2008-04-27 18:23:54 +08:00
|
|
|
mu_run_test (test_path_simplify);
|
2006-06-13 21:58:33 +08:00
|
|
|
mu_run_test (test_append_uri_pathel);
|
2006-06-28 19:09:30 +08:00
|
|
|
mu_run_test (test_are_urls_equal);
|
|
|
|
mu_run_test (test_is_robots_txt_url);
|
2015-07-01 06:21:05 +08:00
|
|
|
#ifdef HAVE_HSTS
|
|
|
|
mu_run_test (test_hsts_new_entry);
|
|
|
|
mu_run_test (test_hsts_url_rewrite_superdomain);
|
|
|
|
mu_run_test (test_hsts_url_rewrite_congruent);
|
|
|
|
mu_run_test (test_hsts_read_database);
|
|
|
|
#endif
|
2009-09-22 11:39:44 +08:00
|
|
|
|
2005-10-27 22:13:40 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-02-22 20:40:50 +08:00
|
|
|
extern const char *program_name; /* Needed by lib/error.c. */
|
2005-10-27 22:13:40 +08:00
|
|
|
|
|
|
|
int
|
2014-11-24 17:20:51 +08:00
|
|
|
main (int argc _GL_UNUSED, const char *argv[])
|
2005-10-27 22:13:40 +08:00
|
|
|
{
|
2009-09-03 11:14:19 +08:00
|
|
|
const char *result;
|
|
|
|
|
2015-07-01 06:21:05 +08:00
|
|
|
printf ("[DEBUG] Testing...\n\n");
|
2014-06-11 21:38:14 +08:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
/* Set the current locale. */
|
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
/* Set the text message domain. */
|
|
|
|
bindtextdomain ("wget", LOCALEDIR);
|
|
|
|
textdomain ("wget");
|
|
|
|
#endif /* ENABLE_NLS */
|
|
|
|
|
2009-09-03 11:14:19 +08:00
|
|
|
program_name = argv[0];
|
|
|
|
|
|
|
|
result = all_tests();
|
2009-09-22 11:39:44 +08:00
|
|
|
|
|
|
|
if (result != NULL)
|
2005-10-27 22:13:40 +08:00
|
|
|
{
|
|
|
|
puts (result);
|
|
|
|
}
|
2009-09-22 11:39:44 +08:00
|
|
|
else
|
2005-10-27 22:13:40 +08:00
|
|
|
{
|
|
|
|
printf ("ALL TESTS PASSED\n");
|
|
|
|
}
|
2009-09-22 11:39:44 +08:00
|
|
|
|
2005-10-27 22:13:40 +08:00
|
|
|
printf ("Tests run: %d\n", tests_run);
|
2009-09-22 11:39:44 +08:00
|
|
|
|
2005-10-27 22:13:40 +08:00
|
|
|
return result != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* vim: et ts=2 sw=2
|
|
|
|
*/
|