1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

testenv: add test to stress wget 1.16 crash

This commit is contained in:
Giuseppe Scrivano 2014-11-26 20:39:59 +01:00
parent e4583ab364
commit d9ab65abd2
3 changed files with 82 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2014-11-26 Giuseppe Scrivano <gscrivan@redhat.com>
* Makefile.am (TESTS): Add Test-redirect-crash.py.
* Test-redirect-crash.py: New File.
2014-11-26 Tim Ruehsen <tim.ruehsen@gmx.de> 2014-11-26 Tim Ruehsen <tim.ruehsen@gmx.de>
* Makefile.am: Removed Test-auth-both.py from XFAIL_TESTS * Makefile.am: Removed Test-auth-both.py from XFAIL_TESTS

View File

@ -51,7 +51,8 @@ if HAVE_PYTHON3
Test-O.py \ Test-O.py \
Test-Post.py \ Test-Post.py \
Test-504.py \ Test-504.py \
Test--spider-r.py Test--spider-r.py \
Test-redirect-crash.py
# added test cases expected to fail here and under TESTS # added test cases expected to fail here and under TESTS
XFAIL_TESTS = XFAIL_TESTS =

74
testenv/Test-redirect-crash.py Executable file
View File

@ -0,0 +1,74 @@
#!/usr/bin/env python3
from sys import exit
from test.http_test import HTTPTest
from misc.wget_file import WgetFile
import os
# This test caused wget up to 1.16 to crash
os.environ["LC_ALL"] = "en_US.UTF-8"
urls = [
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory",
"File formats/Images/SVG, Scalable Vector Graphics/html, W3C v1.2 rec (tiny)/directory/",
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory/somefile.rng",
"File%20formats/Images/SVG%2C%20Scalable%20Vector%20Graphics/html%2c%20W3C%20v1.2%20rec%20%28tiny%29/directory/somefile.rng",
"File%20formats/Images/SVG%2C%20Scalable%20Vector%20Graphics/html%2c%20W3C%20v1.2%20rec%20%28tiny%29/directory/",
"File%20formats/Images/SVG%2C%20Scalable%20Vector%20Graphics/html%2C%20W3C%20v1.2%20rec%20%28tiny%29/directory"]
redirected = [
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory/"
]
TEST_NAME = "Redirection crash"
############# File Definitions ###############################################
Index = ""
for i in urls:
Index = Index + "<a href='/%s'></a>" % i
File1 = ""
def get_redirect(url):
data = {
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory" :
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory/",
"File%20formats/Images/SVG%2C%20Scalable%20Vector%20Graphics/html%2C%20W3C%20v1.2%20rec%20%28tiny%29/directory" :
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory/"
}
dest = data.get(url)
if dest:
return {"Response" : 301,
"SendHeader" : {"Location" : "/%s" % dest}}
return None
index_url = "File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/index.html"
Index_File = WgetFile (index_url, Index)
Files = ([Index_File] + [WgetFile(i, File1, rules=get_redirect(i)) for i in (redirected + urls)])
WGET_OPTIONS = "--recursive -e robots=off"
WGET_URLS = [[index_url]]
ExpectedReturnCode = 0
################ Pre and Post Test Hooks #####################################
pre_test = {
"ServerFiles" : [Files]
}
test_options = {
"WgetCommands" : WGET_OPTIONS,
"Urls" : WGET_URLS
}
post_test = {
"ExpectedRetcode" : ExpectedReturnCode,
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test
).begin ()
exit (err)