• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

certs/H03-May-2022-960766

conf/H07-Sep-2021-384280

exc/H07-Sep-2021-2918

misc/H07-Sep-2021-371194

server/H07-Sep-2021-659551

test/H07-Sep-2021-343250

Makefile.amH A D06-Jun-20215.6 KiB13197

Makefile.inH A D03-May-202283.8 KiB2,2142,086

READMEH A D07-Sep-202014 KiB307249

Test--convert-links--content-on-error.pyH A D04-May-20201.7 KiB7864

Test--https-crl.pyH A D28-Dec-20201.3 KiB5238

Test--https.pyH A D28-Dec-20201.4 KiB5743

Test--rejected-log.pyH A D04-May-20202.8 KiB10183

Test--spider-r.pyH A D04-May-20202.3 KiB10587

Test-416.pyH A D04-May-20201.4 KiB5440

Test-504.pyH A D04-May-20202 KiB7155

Test-Content-disposition-2.pyH A D04-May-20201.4 KiB5340

Test-Content-disposition.pyH A D04-May-20201.5 KiB5543

Test-Head.pyH A D04-May-20201,009 4331

Test-O.pyH A D04-May-20201 KiB4432

Test-Post.pyH A D04-May-20201.2 KiB4734

Test-auth-basic-fail.pyH A D04-May-20201.2 KiB5038

Test-auth-basic-netrc-pass-given.pyH A D04-May-20201.8 KiB6954

Test-auth-basic-netrc-user-given.pyH A D04-May-20201.8 KiB6954

Test-auth-basic-netrc.pyH A D04-May-20201.8 KiB6752

Test-auth-basic-no-netrc-fail.pyH A D04-May-20201.4 KiB6045

Test-auth-basic.pyH A D04-May-20201.5 KiB5846

Test-auth-both.pyH A D04-May-20202.2 KiB8672

Test-auth-digest.pyH A D04-May-20201.5 KiB6552

Test-auth-no-challenge-url.pyH A D04-May-20201.3 KiB5341

Test-auth-no-challenge.pyH A D04-May-20201.3 KiB5341

Test-auth-retcode.pyH A D04-May-20201 KiB4934

Test-auth-with-content-disposition.pyH A D04-May-20201.3 KiB5341

Test-c-full.pyH A D04-May-20201.4 KiB5238

Test-condget.pyH A D04-May-20204 KiB139103

Test-cookie-401.pyH A D04-May-20201.4 KiB5845

Test-cookie-domain-mismatch.pyH A D04-May-20201.4 KiB5743

Test-cookie-expires.pyH A D04-May-20202.1 KiB8067

Test-cookie.pyH A D04-May-20201.3 KiB5643

Test-hsts.pyH A D28-Dec-20201.9 KiB8158

Test-metalink-http-baddigest.pyH A D04-May-20202.5 KiB9466

Test-metalink-http-quoted.pyH A D04-May-20204.6 KiB12792

Test-metalink-http-xml-trust-name.pyH A D04-May-20209 KiB273227

Test-metalink-http-xml-trust.pyH A D04-May-20208.9 KiB273227

Test-metalink-http-xml-type-content.pyH A D04-May-20207.2 KiB222184

Test-metalink-http-xml-type-trust-content.pyH A D04-May-20207.1 KiB222184

Test-metalink-http-xml-type-trust.pyH A D04-May-20207.1 KiB222184

Test-metalink-http-xml-type.pyH A D04-May-20207.1 KiB222184

Test-metalink-http-xml.pyH A D04-May-20209 KiB273227

Test-metalink-http.pyH A D04-May-20204.5 KiB12792

Test-metalink-xml-abspath-trust.pyH A D04-May-20203 KiB10257

Test-metalink-xml-abspath.pyH A D04-May-20203 KiB10156

Test-metalink-xml-absprefix-trust.pyH A D04-May-20203.1 KiB10358

Test-metalink-xml-absprefix.pyH A D04-May-20203.1 KiB10257

Test-metalink-xml-continue.pyH A D04-May-20203.3 KiB10860

Test-metalink-xml-emptyprefix-trust.pyH A D04-May-20203.1 KiB10358

Test-metalink-xml-homepath-trust.pyH A D04-May-20203.1 KiB10358

Test-metalink-xml-homepath.pyH A D04-May-20203.1 KiB10257

Test-metalink-xml-homeprefix-trust.pyH A D04-May-20203.1 KiB10358

Test-metalink-xml-homeprefix.pyH A D04-May-20203.1 KiB10257

Test-metalink-xml-nohash.pyH A D04-May-20203 KiB10156

Test-metalink-xml-nourls.pyH A D04-May-20203.1 KiB10156

Test-metalink-xml-prefix-trust.pyH A D04-May-20203.1 KiB10358

Test-metalink-xml-prefix.pyH A D04-May-20203.1 KiB10257

Test-metalink-xml-relpath-trust.pyH A D04-May-20203 KiB10257

Test-metalink-xml-relpath.pyH A D04-May-20203 KiB10156

Test-metalink-xml-relprefix-trust.pyH A D04-May-20203.1 KiB10358

Test-metalink-xml-relprefix.pyH A D04-May-20203.1 KiB10257

Test-metalink-xml-size.pyH A D04-May-20203 KiB10156

Test-metalink-xml-trust.pyH A D04-May-20203.1 KiB10257

Test-metalink-xml-urlbreak.pyH A D04-May-20207 KiB237206

Test-metalink-xml.pyH A D04-May-20203.1 KiB10156

Test-missing-scheme-retval.pyH A D04-May-20201 KiB4331

Test-no_proxy-env.pyH A D28-Dec-20204.9 KiB162108

Test-pinnedpubkey-der-https.pyH A D28-Dec-20201.6 KiB5844

Test-pinnedpubkey-der-no-check-https.pyH A D28-Dec-20201.5 KiB5743

Test-pinnedpubkey-hash-https.pyH A D28-Dec-20201.6 KiB6147

Test-pinnedpubkey-hash-no-check-fail-https.pyH A D28-Dec-20201.2 KiB5238

Test-pinnedpubkey-pem-fail-https.pyH A D28-Dec-20201.4 KiB5440

Test-pinnedpubkey-pem-https.pyH A D28-Dec-20201.6 KiB5844

Test-recursive-basic.pyH A D04-May-20201.6 KiB6047

Test-recursive-include.pyH A D04-May-20201.5 KiB5744

Test-recursive-redirect.pyH A D04-May-20201.8 KiB6551

Test-redirect-crash.pyH A D04-May-20202.6 KiB7352

Test-redirect.pyH A D04-May-20201.5 KiB5842

Test-reserved-chars.pyH A D04-May-20201.3 KiB5844

valgrind-suppressions-sslH A D06-Jun-2021831 5044

README

1This document describes the working of the GNU Wget Test Suite.
2
3Install Instructions:
4================================================================================
5
6This Test Suite exploits the Parallel Test Harness available in GNU Autotools.
7Since it uses features from a relatively recent version of Autotools, the minimum
8required version as been bumped up to 1.11.
9Run the './configure' command to generate the Makefile and then run 'make check'
10to execute the Test Suite. Use the '-j n' option with 'make check' to execute
11n tests simultaneously.
12
13Structure:
14================================================================================
15
16    * server: This package contains custom programmatically configurable servers
17    (both HTTP and FTP) for testing Wget. The HTTP server runs an instance of
18    Python's http.server module. The FTP server is to be implemented.
19
20    * test: This package contains the test case classes for HTTP and FTP. The
21    test case classes includes methods for initializing and cleaning up of the
22    test environment.
23
24    * Test-Proto.py: This is a prototype Test Case file. The file defines all
25    the acceptable elements and their uses. Typically, one must copy this file
26    and edit it for writing Test Cases.
27
28    * exc: This package contains custom exception classes used in this test
29    suite.
30
31    * conf: This package contains the configuration classes for servers to be
32    configured with.
33
34    * misc: This package contains several helper modules used in this test
35    suite.
36        - colour_terminal.py: A custom module for printing coloured output to
37        the terminal. Currently it only supports 4 colours in a *nix
38        environment.
39        - wget_file.py: Module which contains WgetFile, which is a file data
40        container object.
41
42Working:
43================================================================================
44
45The Test Files are valid Python scripts and the default mask for them is 755.
46A singular Test must be invoked in the following manner, with the current
47directory being the testenv directory:
48$ ./python3 <Name of Test File>      OR
49$ ./<Name of Test File>
50The script will then initialize the various elements and pass them to an object
51of the respective Test Class. A directory with the name <Test name>-test will be
52created and the PWD will be changed to this directory. The server is then
53spawned with the required configuration elements. A blocking call to Wget is
54made with the command line arguments specified in the Test Case along with the
55list of URLs that it must download. The server is killed once Wget returns and
56the following checks are used to determine the pass/fail status of the test:
57    * Return Code: The Exit code of Wget is matched against the expected Exit
58    Code as mentioned in the Test Case File.
59    * Downloaded Files: Check whether the expected downloaded files exist on
60    disk.
61    * File Content: Test whether the file contents were correctly downloaded by
62    Wget and not corrupted mid-way.
63    * Excess Files: Check to see whether any unexpected files were downloaded
64    by Wget.
65
66Exit Codes:
67===============================================================================
68
69Following is a list of Exit Status Codes for the tests:
70*   0  Test Successful
71*  66  Errors/Warnings Reported by Thread Sanitizer (If built with -fsanitize)
72*  77  Test Skipped
73*  99  Hard Error
74* 100  Test Failed
75
76Tests are skipped when they are either not supported by the platform, or Wget
77is not compiled with support for that feature. This feature has not yet been
78implemented.
79
80Hard Errors occur when there are problems with the Environment code. Hard
81Error reporting is currently not enabled and all errors are reported as
82failures.
83
84All exceptions should ideally be handled gracefully. If you see any unhandled
85exceptions, please file a bug report at <bug-wget@gnu.org>
86
87Environment Variables:
88================================================================================
89
90* SERVER_WAIT: Set this environment variable with a value for the number of
91  seconds the test should sleep between invoking the server and calling the Wget
92  executable. This is used when one would like to test a different version of
93  the executable or for running the test through external utilities like gdb and
94  valgrind.
95* NO_CLEANUP: Do not remove the temporary files created by the test.
96  This will prevent the ${testname}-test directory from being deleted
97* VALGRIND_TESTS: If this variable is set and contains the valgrind command line,
98  the test suite will execute all the tests via this command.
99  If it is set to "1", valgrind memcheck is enabled with hard coded options.
100  This variable is set by ./configure --enable-valgrind-tests.
101* SSL_TESTS: This must be set to run any https tests.
102* WGET_PATH: Set this environment variable to a path to wget binary on which you
103  want to run tests. This is useful for OS distributions, which want to reuse
104  upstream tests for testing wget build that they distribute. If the variable is
105  not set, the "../src/wget" binary is used by tests.
106
107
108File Structure:
109================================================================================
110
111The test case files are Python scripts. It is believed that Python is a simple
112yet elegant language and should be easy for everyone to comprehend. This test
113suite is written with the objective of making it easy to write new tests. The
114structure has been kept as intuitive as possible and should not require much
115effort to get accustomed to.
116
117All Test Files MUST begin with the following Three Lines:
118#!/usr/bin/python3
119from sys import exit
120from WgetTest import {HTTPTest|FTPTest}
121from misc.wget_file import WgetFile
122
123It is recommended that a small description of the Test Case is provided next.
124This would be very helpful to future contributors.
125
126Each File in the Test must be represented as a WgetFile object. The WgetFile
127Class has the following prototype:
128WgetFile (str name, str contents, str timestamp, dict rules)
129None except name is a mandatory parameter, one may pass only those parameters
130that are required by the File object.
131
132The timestamp string should be in a format: "YYYY-MM-DD HH:MM:SS" in UTC zone.
133The rules object is a dictionary element, with the key as the Rule Name and
134value as the Rule Data. In most cases, the Rule Data is another dictionary.
135
136Various variables used consistently across all tests are:
137    * WGET_OPTIONS: The command line string passed to Wget upon invocation. This
138    string may contain URLs, like in the case where in-URL authentication is
139    used. Variable names passed like {{var_name}} will be replaced by the
140    contents of the variable self.var_name before being passed to Wget
141    * WGET_URLS: This is a list of filenames which will be appended as the URLs
142    to Wget during invocation. This is a list of lists, where WGET_URLS[0]
143    represents the list of Filenames called from Server[0], WGET_URLS[1] is a
144    list of files downloaded from Server[2], etc.  They must be relative URLs,
145    i.e., not start with "/".
146    * Files: This variable defines the files that exist in the Server's
147    filesystem. The Files variable is a list of lists of WgetFile objects.
148    This means that File[0] is a list of WgetFile objects that lie on Server[0],
149    File[1] a list of files on Server[1] and so on.
150    * Existing_Files: This is a list of files that already exist in the
151    directory from which Wget is invoked.
152    * ExpectedReturnCode: The Exit Code expected to be returned by Wget after
153    the test.
154    * ExpectedDownloadedFiles: A list of files that are expected in the local
155    directory after Wget has finished executing. This does not include the files
156    already existing before Wget was launched and must be mentioned again.
157    * Request_List: An unordered list of Requests that each server must receive.
158    This too is a list of lists and follows the same convention as others above.
159
160Both, the HTTPTest and FTPTest modules have the same prototype:
161{
162    pre_hook,
163    test_options,
164    post_hook,
165    protocols
166}
167the three hooks should be Python dict objects and protocols should be a list of
168protocols, like [HTTP, HTTPS].
169
170Valid File Rules:
171================================================================================
172
173This section lists the currently supported File Rules and their structure.
174
175    * Authentication: Used when a File must require Authorization for access.
176    The value for this key is the following dictionary:
177    |-->Type        :   Basic|Digest|Both|Both_inline
178    |-->User        :   <Username>
179    --->Pass        :   <Password>
180
181    * ExpectHeader  : The following Headers MUST exist in every Request for the
182    File. The value for this key is a dictionary object where each header is
183    represented as:
184    |-->Header Name :   <Header Data>
185
186    * RejectHeader  : This list of Headers must NEVER occur in a request. It
187    uses the same value format as ExpectHeader.
188
189    * SendHeader    : This list of Headers will be sent in EVERY response to a
190    request for the respective file. It follows the same value format as
191    ExpectHeader. Additionally you can specify a list of strings as <Header Data>
192    if you want the header repeated with multiple values.
193
194    * Response      : The HTTP Response Code to send to a request for this File.
195    The value is an Integer that represents a valid HTTP Response Code.
196
197Pre Test Hooks:
198================================================================================
199
200The Pre-Test Hooks are executed just after starting the server and just before
201spawning an instance of the server. These are usually used for setting up the
202Test Environment and Server Rules. The currently supported Pre-Test Hooks are:
203
204    * ServerFiles   : A list of WgetFile objects that must exist on the Server
205    * LocalFiles    : A list of WgetFile objects that exist locally on disk
206    before Wget is executed.
207
208Since pre_test is a dictionary, one may not assume that the hooks will be
209executed in the same order as they are defined.
210
211Test Options:
212================================================================================
213
214The test_options dictionary defines the commands to be used when the Test is
215executed. The currently supported options are:
216
217    * Urls          : A list of the filenames that Wget must attempt to
218    download. The complete URL will be created and passed to Wget
219    automatically. (alias URLs)
220    * WgetCommands  : A string consisting of the various commandline switches
221    sent to Wget upon invocation. Any data placed between {{ }} in this string
222    will be replaced with the contents of self.<data> before being passed to
223    Wget. This is particularly useful for getting the hostname and port for a
224    file. While all Download URL's are passed to Urls, a notable exception is
225    when in-url authentication is used. In such a case, the URL is specified in
226    the WgetCommands string.
227    * EnvironmentVariables: A dictionary with key-value items, which will be
228    defined as environment variables during the execution of wget command in
229    test.
230
231Post-Test Hooks:
232================================================================================
233
234These hooks are executed as soon as the call to Wget returns. The post-test
235hooks are usually used to run checks on the data, files downloaded, return code,
236etc. The following hooks are currently supported:
237
238    * ExpectedRetcode : This is an integer value of the ReturnCode with which
239    Wget is expected to exit. (alias ExpectedRetCode)
240    * ExpectedFiles   : This is a list of WgetFile objects of the files that
241    must exist locally on disk in the Test directory.
242    * FilesCrawled    : This requires a list of the Requests that the server is
243    expected to receive. The order is un-important since it will vary on the
244    parallel-wget branch. This hook is used in tests for Recursive mode to
245    ensure that the website is traversed correctly.
246
247Writing New Tests:
248================================================================================
249
250See Test-Proto.py for an example of how to write Test Case files. The
251recommended method for writing new Test Case files is to copy Test-Proto.py and
252modify it to ones needs.
253
254In case you require any functionality that is not currently defined in List of
255Rules defined above, you should implement a new class in the conf package. The
256file name doesn't matter (though it's better to give it an appropriate name).
257The new rule or hook class should be like this:
258============================================
259from conf import rule
260
261
262@rule()
263class MyNewRule:
264    def __init__(self, rule_arg):
265        self.rule_arg = rule_arg
266        # your rule initialization code goes here
267============================================
268from conf import hook
269
270
271@hook()
272class MyNewHook:
273    def __init__(self, hook_arg):
274        self.hook_arg = hook_arg
275        # your hook initialization code goes here
276
277    def __call__(self, test_obj):
278        # your hook code goes here
279============================================
280
281Once a new Test File is created, it must be added to the TESTS variable in
282Makefile.am. This way the Test will be executed on running a 'make check'.
283If a Test is expected to fail on the current master branch, then the Test should
284also be added to the XFAIL_TESTS variable. This will allow expected failures to
285pass through. If a test mentioned in the XFAIL_TESTS variable passes, it gets
286red-flagged as a XPASS. Currently, tests expected to fail under valgrind are not
287explicitly marked as XFAIL. Tests failing under valgrind must always be
288considered a blocking error.
289
290Work Remaining:
291================================================================================
292
293Some amount of work still remains to be done.
294    * Errors in server-side checks need to be handled more explicitly
295    * Support parallel-wget branch
296        * Support to spawn multiple servers is already in place. Need to handle
297        multiple requests to a server simultaneously. Use THreading MixIn.
298    * SSL Tests. Use xyne's HTTPS server implementation
299    * Complete support for FTP Tests
300    * IRI Support. This shouldn't require much effort
301
302Requirements:
303================================================================================
304
3051. Python   >= 3.0
3062. Automake >= 1.11
307