]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
pytest: make test_07_22 more lenient to exit codes
authorStefan Eissing <stefan@eissing.org>
Thu, 17 Apr 2025 09:05:28 +0000 (11:05 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 17 Apr 2025 15:30:03 +0000 (17:30 +0200)
Depending on timing when the server aborting the connection is detected,
the reported curl exit code may vary. Check for the possible set of
expected codes instead of a single one.

Closes #17083

tests/http/test_07_upload.py
tests/http/testenv/curl.py

index 8b33325d34c7674a4eec2efeff9e26771f25f603..d99c0d867984c375e4a4333a5a415d784b34168c 100644 (file)
@@ -274,8 +274,9 @@ class TestUpload:
             f'/curltest/tweak?status=400&delay=5ms&chunks=1&body_error=reset&id=[0-{count-1}]'
         r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto,
                              extra_args=['--parallel'])
-        exp_exit = 92 if proto == 'h2' else 95
-        r.check_stats(count=count, exitcode=exp_exit)
+        # depending on timing and protocol, we might get CURLE_PARTIAL_FILE or
+        # CURLE_HTTP3 or CURLE_HTTP2_STREAM
+        r.check_stats(count=count, exitcode=[18, 92, 95])
 
     # PUT 100k
     @pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
index ee224d9a67d308b33d637d33de17a2c6d0912216..cb253c077deda7408d3a20357c29a5dcd9b8ca80 100644 (file)
@@ -386,11 +386,13 @@ class ExecResult:
                 f'were made\n{self.dump_logs()}'
 
     def check_stats(self, count: int, http_status: Optional[int] = None,
-                    exitcode: Optional[int] = None,
+                    exitcode: Optional[Union[int, List[int]]] = None,
                     remote_port: Optional[int] = None,
                     remote_ip: Optional[str] = None):
         if exitcode is None:
             self.check_exit_code(0)
+        elif isinstance(exitcode, int):
+            exitcode = [exitcode]
         assert len(self.stats) == count, \
             f'stats count: expected {count}, got {len(self.stats)}\n{self.dump_logs()}'
         if http_status is not None:
@@ -403,7 +405,7 @@ class ExecResult:
         if exitcode is not None:
             for idx, x in enumerate(self.stats):
                 if 'exitcode' in x:
-                    assert x['exitcode'] == exitcode, \
+                    assert x['exitcode'] in exitcode, \
                         f'status #{idx} exitcode: expected {exitcode}, '\
                         f'got {x["exitcode"]}\n{self.dump_stat(x)}'
         if remote_port is not None: