1 /*
2  * Copyright (c) 2015-2021 Free Software Foundation, Inc.
3  *
4  * This file is part of Wget
5  *
6  * Wget is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Wget is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Wget  If not, see <https://www.gnu.org/licenses/>.
18  *
19  *
20  * Testing 'base' html tag
21  *
22  */
23 
24 #include <config.h>
25 
26 #include <stdlib.h> // exit()
27 #include "libtest.h"
28 
main(void)29 int main(void)
30 {
31 	wget_test_url_t urls[]={
32 		{	.name = "/1.bad.txt",
33 			.code = "200 Dontcare",
34 			.body = "FFFFFFF4\nGarbage",
35 			.headers = {
36 				"Content-Type: text/plain",
37 				"Transfer-Encoding: chunked",
38 			}
39 		},
40 		{	.name = "/2.bad.txt",
41 			.code = "200 Dontcare",
42 			.body = "FFFFFFFE\r\nGarbage",
43 			.headers = {
44 				"Content-Type: text/plain",
45 				"Transfer-Encoding: chunked",
46 			}
47 		},
48 		{	.name = "/3.bad.txt",
49 			.code = "200 Dontcare",
50 			.body = "FFFFFFFFFFFFFFF4\r\nGarbage",
51 			.headers = {
52 				"Content-Type: text/plain",
53 				"Transfer-Encoding: chunked",
54 			}
55 		},
56 	};
57 
58 	// functions won't come back if an error occurs
59 	wget_test_start_server(
60 		WGET_TEST_RESPONSE_URLS, &urls, countof(urls),
61 		WGET_TEST_FEATURE_MHD,
62 		WGET_TEST_SKIP_H2,
63 		0);
64 
65 	// test negative chunk size (32bit system only)
66 	wget_test(
67 		WGET_TEST_OPTIONS, "",
68 		WGET_TEST_REQUEST_URLS, "1.bad.txt", "2.bad.txt", "3.bad.txt", NULL,
69 		WGET_TEST_EXPECTED_ERROR_CODE, 0,
70 		WGET_TEST_EXPECTED_FILES, &(wget_test_file_t []) {
71 			{ urls[0].name + 1, NULL }, // do not check content
72 			{ urls[1].name + 1, NULL }, // do not check content
73 			{ urls[2].name + 1, NULL }, // do not check content
74 			{	NULL } },
75 		0);
76 
77 	exit(EXIT_SUCCESS);
78 }
79