1 /*
2 * Copyright (c) 2013 Tim Ruehsen
3 * Copyright (c) 2015-2021 Free Software Foundation, Inc.
4 *
5 * This file is part of Wget
6 *
7 * 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 * 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 <https://www.gnu.org/licenses/>.
19 *
20 *
21 * Testing Wget
22 *
23 * Changelog
24 * 15.07.2013 Tim Ruehsen created
25 *
26 */
27
28 #include <config.h>
29
30 #include <stdlib.h> // exit()
31 #include "libtest.h"
32
main(void)33 int main(void)
34 {
35 wget_test_url_t urls[]={
36 { .name = "/index.php",
37 .code = "200 Dontcare",
38 .body =
39 "<html><head><title>Main Page</title></head><body><p>A link to a" \
40 " <a href=\"//localhost:{{port}}/subpage.php\">second page</a>." \
41 "</p></body></html>",
42 .headers = {
43 "Content-Type: text/html",
44 }
45 },
46 { .name = "/subpage.php",
47 .code = "200 Dontcare",
48 .body = "<html><head><title>Sub Page</title></head><body>Some Text</body></html>",
49 .headers = {
50 "Content-Type: text/html",
51 }
52 },
53 };
54
55 const char *mainpagemangled =
56 "<html><head><title>Main Page</title></head><body><p>A link to a" \
57 " <a href=\"subpage.php.html\">second page</a>." \
58 "</p></body></html>";
59
60 // functions won't come back if an error occurs
61 wget_test_start_server(
62 WGET_TEST_RESPONSE_URLS, &urls, countof(urls),
63 WGET_TEST_FEATURE_MHD,
64 0);
65
66 // test-E-k
67 wget_test(
68 WGET_TEST_OPTIONS, "-r -nd -E -k",
69 WGET_TEST_REQUEST_URL, "index.php",
70 WGET_TEST_EXPECTED_ERROR_CODE, 0,
71 WGET_TEST_EXPECTED_FILES, &(wget_test_file_t []) {
72 { "index.php.html", mainpagemangled },
73 { "subpage.php.html", urls[1].body },
74 { NULL } },
75 0);
76
77 /*
78 // test-E-k-K
79 wget_test(
80 WGET_TEST_OPTIONS, "-r -nd -E -k -K",
81 WGET_TEST_REQUEST_URL, "index.php",
82 WGET_TEST_EXPECTED_ERROR_CODE, 0,
83 WGET_TEST_EXPECTED_FILES, &(wget_test_file_t []) {
84 { "index.php.html", mainpagemangled },
85 { "index.php.orig", urls[0].body },
86 { "subpage.php.html", urls[1].body },
87 { NULL } },
88 0);
89 */
90
91 exit(EXIT_SUCCESS);
92 }
93