Browse code

run-tests.py: allow returncodes to be one of a list of items

wget on RHEL5 (wget 1.11.4, python 2.4) returns 1 when hitting a HTTP 403 Forbidden
error, but returns an 8 on newer versions of wget (wget 1.14).
Therefore, we have to be able to accept either, while still checking
we got a 403 error.

Matt Domsch authored on 2014/03/14 12:21:47
Showing 1 changed files
... ...
@@ -137,8 +137,9 @@ def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [],
137 137
 
138 138
     p = Popen(cmd_args, stdout = PIPE, stderr = STDOUT, universal_newlines = True)
139 139
     stdout, stderr = p.communicate()
140
-    if retcode != p.returncode:
141
-        return failure("retcode: %d, expected: %d" % (p.returncode, retcode))
140
+    if type(retcode) not in [list, tuple]: retcode = [retcode]
141
+    if p.returncode not in retcode:
142
+        return failure("retcode: %d, expected one of: %s" % (p.returncode, retcode))
142 143
 
143 144
     if type(must_find) not in [ list, tuple ]: must_find = [must_find]
144 145
     if type(must_find_re) not in [ list, tuple ]: must_find_re = [must_find_re]
... ...
@@ -378,8 +379,8 @@ test_s3cmd("Change ACL to Private", ['setacl', '--acl-private', '%s/xyz/etc/l*.p
378 378
 ## ====== Verify Private ACL
379 379
 if have_wget:
380 380
     test("Verify Private ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.%s/xyz/etc/logo.png' % (bucket(1), cfg.host_base)],
381
-        retcode = 8,
382
-        must_find_re = [ 'ERROR 403: Forbidden' ])
381
+         retcode = [1, 8],
382
+         must_find_re = [ 'ERROR 403: Forbidden' ])
383 383
 
384 384
 
385 385
 ## ====== Change ACL to Public