From: Viktor Szakats Date: Wed, 1 Oct 2025 21:27:45 +0000 (+0200) Subject: pytest: skip specific tests for no-verbose builds X-Git-Tag: rc-8_17_0-3~386 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34dc762ceff13250a2338242dfea6f9ce7f061fd;p=thirdparty%2Fcurl.git pytest: skip specific tests for no-verbose builds Detect via curlinfo if curl has verbose strings disabled, and skip tests that require it. Also: - cmake: make pytests depend on curlinfo. Cherry-picked from #18797 Closes #18801 --- diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8bfca21ca6..2b12cef83b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -31,7 +31,7 @@ configure_file("config.in" "${CMAKE_CURRENT_BINARY_DIR}/config" @ONLY) add_custom_target(testdeps) if(BUILD_CURL_EXE) - add_dependencies(testdeps curlinfo) + add_dependencies(testdeps "curlinfo") endif() if(CURL_CLANG_TIDY) @@ -57,7 +57,7 @@ function(curl_add_runtests _targetname _test_flags) # skipping them, MSBuild doing a re-evaluation, and actually rebuilding them. if(NOT _targetname STREQUAL "test-ci") if(BUILD_CURL_EXE) - list(APPEND _depends ${EXE_NAME}) + list(APPEND _depends "${EXE_NAME}") endif() list(APPEND _depends "testdeps") endif() @@ -86,7 +86,7 @@ function(curl_add_pytests _targetname _test_flags) set(_depends "") if(NOT _targetname STREQUAL "pytest-ci") if(BUILD_CURL_EXE) - list(APPEND _depends ${EXE_NAME}) + list(APPEND _depends "${EXE_NAME}" "curlinfo") endif() list(APPEND _depends "libtests") endif() diff --git a/tests/http/test_02_download.py b/tests/http/test_02_download.py index 4ec781148c..89bf7e1ab1 100644 --- a/tests/http/test_02_download.py +++ b/tests/http/test_02_download.py @@ -600,6 +600,7 @@ class TestDownload: # nghttpx is the only server we have that supports TLS early data @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") @pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3']) def test_02_32_earlydata(self, env: Env, httpd, nghttpx, proto): if not env.curl_can_early_data(): @@ -654,6 +655,8 @@ class TestDownload: def test_02_33_max_host_conns(self, env: Env, httpd, nghttpx, proto, max_host_conns): if not env.curl_is_debug(): pytest.skip('only works for curl debug builds') + if not env.curl_is_verbose(): + pytest.skip('only works for curl with verbose strings') if proto == 'h3' and not env.have_h3(): pytest.skip("h3 not supported") count = 50 @@ -692,6 +695,8 @@ class TestDownload: def test_02_34_max_total_conns(self, env: Env, httpd, nghttpx, proto, max_total_conns): if not env.curl_is_debug(): pytest.skip('only works for curl debug builds') + if not env.curl_is_verbose(): + pytest.skip('only works for curl with verbose strings') if proto == 'h3' and not env.have_h3(): pytest.skip("h3 not supported") count = 50 diff --git a/tests/http/test_06_eyeballs.py b/tests/http/test_06_eyeballs.py index d05eb3c7da..7d26774476 100644 --- a/tests/http/test_06_eyeballs.py +++ b/tests/http/test_06_eyeballs.py @@ -105,6 +105,7 @@ class TestEyeballs: # check timers when trying 3 unresponsive addresses @pytest.mark.skipif(condition=not Env.curl_has_feature('IPv6'), reason='curl lacks ipv6 support') + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_06_13_timers(self, env: Env): curl = CurlClient(env=env) # ipv6 0100::/64 is supposed to go into the void (rfc6666) diff --git a/tests/http/test_10_proxy.py b/tests/http/test_10_proxy.py index e61284a4ca..592acbd60c 100644 --- a/tests/http/test_10_proxy.py +++ b/tests/http/test_10_proxy.py @@ -151,6 +151,7 @@ class TestProxy: @pytest.mark.parametrize("tunnel", ['http/1.1', 'h2']) @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_10_06_proxytunnel_https(self, env: Env, httpd, nghttpx_fwd, proto, tunnel): if tunnel == 'h2' and not env.curl_uses_lib('nghttp2'): pytest.skip('only supported with nghttp2') @@ -169,6 +170,7 @@ class TestProxy: # download many https: with proto via https: proxytunnel @pytest.mark.skipif(condition=not Env.have_ssl_curl(), reason="curl without SSL") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") @pytest.mark.parametrize("proto", ['http/1.1', 'h2']) @pytest.mark.parametrize("tunnel", ['http/1.1', 'h2']) @pytest.mark.parametrize("fname, fcount", [ @@ -209,6 +211,7 @@ class TestProxy: ['data-1m', 5] ]) @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available") def test_10_08_upload_seq_large(self, env: Env, httpd, nghttpx, proto, tunnel, fname, fcount): @@ -236,6 +239,7 @@ class TestProxy: @pytest.mark.parametrize("tunnel", ['http/1.1', 'h2']) @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_10_09_reuse_server(self, env: Env, httpd, nghttpx_fwd, tunnel): if tunnel == 'h2' and not env.curl_uses_lib('nghttp2'): pytest.skip('only supported with nghttp2') @@ -259,6 +263,7 @@ class TestProxy: @pytest.mark.parametrize("tunnel", ['http/1.1', 'h2']) @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_10_10_reuse_proxy(self, env: Env, httpd, nghttpx_fwd, tunnel): # url twice via https: proxy separated with '--next', will reuse if tunnel == 'h2' and not env.curl_uses_lib('nghttp2'): @@ -287,6 +292,7 @@ class TestProxy: @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available") @pytest.mark.skipif(condition=not Env.curl_uses_lib('openssl'), reason="tls13-ciphers not supported") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_10_11_noreuse_proxy_https(self, env: Env, httpd, nghttpx_fwd, tunnel): # different --proxy-tls13-ciphers, no reuse of connection for https: curl = CurlClient(env=env) @@ -313,6 +319,7 @@ class TestProxy: @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available") @pytest.mark.skipif(condition=not Env.curl_uses_lib('openssl'), reason="tls13-ciphers not supported") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_10_12_noreuse_proxy_http(self, env: Env, httpd, nghttpx_fwd, tunnel): # different --proxy-tls13-ciphers, no reuse of connection for http: if tunnel == 'h2' and not env.curl_uses_lib('nghttp2'): @@ -339,6 +346,7 @@ class TestProxy: @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available") @pytest.mark.skipif(condition=not Env.curl_uses_lib('openssl'), reason="tls13-ciphers not supported") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_10_13_noreuse_https(self, env: Env, httpd, nghttpx_fwd, tunnel): # different --tls13-ciphers on https: same proxy config if tunnel == 'h2' and not env.curl_uses_lib('nghttp2'): diff --git a/tests/http/test_13_proxy_auth.py b/tests/http/test_13_proxy_auth.py index fe45ae40ec..1f7c41e2dd 100644 --- a/tests/http/test_13_proxy_auth.py +++ b/tests/http/test_13_proxy_auth.py @@ -120,6 +120,7 @@ class TestProxyAuth: @pytest.mark.skipif(condition=not Env.curl_has_feature('HTTPS-proxy'), reason='curl lacks HTTPS-proxy support') @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") @pytest.mark.parametrize("proto", ['http/1.1', 'h2']) @pytest.mark.parametrize("tunnel", ['http/1.1', 'h2']) def test_13_07_tunnels_no_auth(self, env: Env, httpd, configures_httpd, nghttpx_fwd, proto, tunnel): @@ -139,6 +140,7 @@ class TestProxyAuth: @pytest.mark.skipif(condition=not Env.curl_has_feature('HTTPS-proxy'), reason='curl lacks HTTPS-proxy support') @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") @pytest.mark.parametrize("proto", ['http/1.1', 'h2']) @pytest.mark.parametrize("tunnel", ['http/1.1', 'h2']) def test_13_08_tunnels_auth(self, env: Env, httpd, configures_httpd, nghttpx_fwd, proto, tunnel): diff --git a/tests/http/test_15_tracing.py b/tests/http/test_15_tracing.py index 7e7d55de71..c94827aa4f 100644 --- a/tests/http/test_15_tracing.py +++ b/tests/http/test_15_tracing.py @@ -77,6 +77,8 @@ class TestTracing: # trace all def test_15_04_trace_all(self, env: Env, httpd): + if not env.curl_is_verbose(): + pytest.skip('only works for curl with verbose strings') curl = CurlClient(env=env) url = f'http://{env.domain1}:{env.http_port}/data.json' r = curl.http_get(url=url, def_tracing=False, extra_args=[ diff --git a/tests/http/test_17_ssl_use.py b/tests/http/test_17_ssl_use.py index 33dd50e939..b346281dfc 100644 --- a/tests/http/test_17_ssl_use.py +++ b/tests/http/test_17_ssl_use.py @@ -367,6 +367,7 @@ class TestSSLUse: assert r.exit_code != 0, f'should fail, server={server_ver:04x}, curl=[{curl_min_ver:04x}, {curl_max_ver:04x}]\n{r.dump_logs()}' @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_17_10_h3_session_reuse(self, env: Env, httpd, nghttpx): if not env.have_h3(): pytest.skip("h3 not supported") diff --git a/tests/http/test_19_shutdown.py b/tests/http/test_19_shutdown.py index 9b3a6c90e9..a0167549fd 100644 --- a/tests/http/test_19_shutdown.py +++ b/tests/http/test_19_shutdown.py @@ -90,6 +90,8 @@ class TestShutdown: def test_19_03_shutdown_by_server(self, env: Env, httpd, proto): if not env.curl_is_debug(): pytest.skip('only works for curl debug builds') + if not env.curl_is_verbose(): + pytest.skip('only works for curl with verbose strings') count = 10 curl = CurlClient(env=env, run_env={ 'CURL_GRACEFUL_SHUTDOWN': '2000', @@ -109,6 +111,8 @@ class TestShutdown: def test_19_04_shutdown_by_curl(self, env: Env, httpd, proto): if not env.curl_is_debug(): pytest.skip('only works for curl debug builds') + if not env.curl_is_verbose(): + pytest.skip('only works for curl with verbose strings') count = 10 docname = 'data.json' url = f'https://localhost:{env.https_port}/{docname}' @@ -132,6 +136,8 @@ class TestShutdown: def test_19_05_event_shutdown_by_server(self, env: Env, httpd, proto): if not env.curl_is_debug(): pytest.skip('only works for curl debug builds') + if not env.curl_is_verbose(): + pytest.skip('only works for curl with verbose strings') count = 10 run_env = os.environ.copy() # forbid connection reuse to trigger shutdowns after transfer @@ -162,6 +168,8 @@ class TestShutdown: pytest.skip("h3 not supported") if not env.curl_is_debug(): pytest.skip('only works for curl debug builds') + if not env.curl_is_verbose(): + pytest.skip('only works for curl with verbose strings') curl = CurlClient(env=env, run_env={ 'CURL_GRACEFUL_SHUTDOWN': '2000', 'CURL_DEBUG': 'all' diff --git a/tests/http/test_30_vsftpd.py b/tests/http/test_30_vsftpd.py index 5f294fdfc8..bffeae35cf 100644 --- a/tests/http/test_30_vsftpd.py +++ b/tests/http/test_30_vsftpd.py @@ -141,6 +141,7 @@ class TestVsFTPD: # check with `tcpdump` if curl causes any TCP RST packets @pytest.mark.skipif(condition=not Env.tcpdump(), reason="tcpdump not available") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_30_06_shutdownh_download(self, env: Env, vsftpd: VsFTPD): docname = 'data-1k' curl = CurlClient(env=env) @@ -158,6 +159,7 @@ class TestVsFTPD: # check with `tcpdump` if curl causes any TCP RST packets @pytest.mark.skipif(condition=not Env.tcpdump(), reason="tcpdump not available") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_30_07_shutdownh_upload(self, env: Env, vsftpd: VsFTPD): docname = 'upload-1k' curl = CurlClient(env=env) diff --git a/tests/http/test_31_vsftpds.py b/tests/http/test_31_vsftpds.py index a3a9e66ca5..f7e32cb77b 100644 --- a/tests/http/test_31_vsftpds.py +++ b/tests/http/test_31_vsftpds.py @@ -148,6 +148,7 @@ class TestVsFTPD: # check with `tcpdump` if curl causes any TCP RST packets @pytest.mark.skipif(condition=not Env.tcpdump(), reason="tcpdump not available") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_31_06_shutdownh_download(self, env: Env, vsftpds: VsFTPD): docname = 'data-1k' curl = CurlClient(env=env) @@ -164,6 +165,7 @@ class TestVsFTPD: # check with `tcpdump` if curl causes any TCP RST packets @pytest.mark.skipif(condition=not Env.tcpdump(), reason="tcpdump not available") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_31_07_shutdownh_upload(self, env: Env, vsftpds: VsFTPD): docname = 'upload-1k' curl = CurlClient(env=env) diff --git a/tests/http/test_32_ftps_vsftpd.py b/tests/http/test_32_ftps_vsftpd.py index 4a28612242..46690a8435 100644 --- a/tests/http/test_32_ftps_vsftpd.py +++ b/tests/http/test_32_ftps_vsftpd.py @@ -160,6 +160,7 @@ class TestFtpsVsFTPD: # check with `tcpdump` if curl causes any TCP RST packets @pytest.mark.skipif(condition=not Env.tcpdump(), reason="tcpdump not available") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_32_06_shutdownh_download(self, env: Env, vsftpds: VsFTPD): docname = 'data-1k' curl = CurlClient(env=env) @@ -176,6 +177,7 @@ class TestFtpsVsFTPD: # check with `tcpdump` if curl causes any TCP RST packets @pytest.mark.skipif(condition=not Env.tcpdump(), reason="tcpdump not available") @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug") + @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings") def test_32_07_shutdownh_upload(self, env: Env, vsftpds: VsFTPD): docname = 'upload-1k' curl = CurlClient(env=env) diff --git a/tests/http/testenv/env.py b/tests/http/testenv/env.py index ad1173a984..0cd9101342 100644 --- a/tests/http/testenv/env.py +++ b/tests/http/testenv/env.py @@ -64,6 +64,7 @@ if not os.path.exists(CONFIG_PATH): CONFIG_PATH = ALT_CONFIG_PATH DEF_CONFIG = init_config_from(CONFIG_PATH) CURL = os.path.join(TOP_PATH, 'src', 'curl') +CURLINFO = os.path.join(TOP_PATH, 'src', 'curlinfo') class NghttpxUtil: @@ -110,6 +111,7 @@ class EnvConfig: self.config = DEF_CONFIG # check cur and its features self.curl = CURL + self.curlinfo = CURLINFO if 'CURL' in os.environ: self.curl = os.environ['CURL'] self.curl_props = { @@ -157,6 +159,12 @@ class EnvConfig: prot.lower() for prot in line[11:].split(' ') } + p = subprocess.run(args=[self.curlinfo], + capture_output=True, text=True) + if p.returncode != 0: + raise RuntimeError(f'{self.curlinfo} failed with exit code: {p.returncode}') + self.curl_is_verbose = 'verbose-strings: ON' in p.stdout + self.ports = {} self.httpd = self.config['httpd']['httpd'] @@ -462,6 +470,10 @@ class Env: def curl_is_debug() -> bool: return Env.CONFIG.curl_is_debug + @staticmethod + def curl_is_verbose() -> bool: + return Env.CONFIG.curl_is_verbose + @staticmethod def curl_can_early_data() -> bool: if Env.curl_uses_lib('gnutls'):