From 4f04acfb53ff274a276f387f18c48d467d807015 Mon Sep 17 00:00:00 2001 From: Jan Venekamp <1422460+jan2000@users.noreply.github.com> Date: Wed, 21 Aug 2024 01:20:13 +0200 Subject: [PATCH] test --- .github/workflows/macos.yml | 204 +++++++++++++++++++----------------- tests/http/testenv/env.py | 24 ++--- tests/http/testenv/httpd.py | 17 +++ 3 files changed, 137 insertions(+), 108 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 30f1144e406c29..58a70aea13136a 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -9,6 +9,7 @@ on: branches: - master - '*/ci' + - '*/ci-pytest' paths-ignore: - '**/*.md' - '.azure-pipelines.yml' @@ -68,83 +69,84 @@ jobs: fail-fast: false matrix: include: - - name: '!ssl !debug' - compiler: clang - configure: --without-ssl --enable-websockets - macos-version-min: '10.9' - - name: '!ssl !debug' - compiler: gcc-12 - configure: --without-ssl --enable-websockets - macos-version-min: '10.9' - - name: '!ssl' - compiler: clang - configure: --enable-debug --without-ssl --enable-websockets - macos-version-min: '10.9' - - name: '!ssl libssh2 AppleIDN' - compiler: clang - configure: --enable-debug --with-libssh2=$(brew --prefix libssh2) --without-ssl --with-apple-idn --enable-websockets - macos-version-min: '10.9' - - name: 'OpenSSL libssh c-ares' - compiler: clang - install: libssh - configure: --enable-debug --with-libssh --with-openssl=$(brew --prefix openssl) --enable-ares --enable-websockets - macos-version-min: '10.9' - - name: 'OpenSSL libssh' - compiler: llvm@15 - install: libssh - configure: --enable-debug --with-libssh --with-openssl=$(brew --prefix openssl) --enable-websockets - macos-version-min: '10.9' - - name: '!ssl c-ares' - compiler: clang - configure: --enable-debug --enable-ares --without-ssl --enable-websockets - macos-version-min: '10.9' - - name: '!ssl HTTP-only' - compiler: clang - configure: | - --enable-debug \ - --disable-alt-svc --disable-dict --disable-file --disable-ftp --disable-gopher --disable-imap \ - --disable-ldap --disable-pop3 --disable-rtmp --disable-rtsp --disable-scp --disable-sftp \ - --disable-shared --disable-smb --disable-smtp --disable-telnet --disable-tftp --disable-unix-sockets \ - --without-brotli --without-gssapi --without-libidn2 --without-libpsl --without-librtmp --without-libssh2 \ - --without-nghttp2 --without-ntlm-auth --without-ssl --without-zlib --without-zstd - - macos-version-min: '10.15' # Catalina (2019) +# - name: '!ssl !debug' +# compiler: clang +# configure: --without-ssl --enable-websockets +# macos-version-min: '10.9' +# - name: '!ssl !debug' +# compiler: gcc-12 +# configure: --without-ssl --enable-websockets +# macos-version-min: '10.9' +# - name: '!ssl' +# compiler: clang +# configure: --enable-debug --without-ssl --enable-websockets +# macos-version-min: '10.9' +# - name: '!ssl libssh2 AppleIDN' +# compiler: clang +# configure: --enable-debug --with-libssh2=$(brew --prefix libssh2) --without-ssl --with-apple-idn --enable-websockets +# macos-version-min: '10.9' +# - name: 'OpenSSL libssh c-ares' +# compiler: clang +# install: libssh +# configure: --enable-debug --with-libssh --with-openssl=$(brew --prefix openssl) --enable-ares --enable-websockets +# macos-version-min: '10.9' +# - name: 'OpenSSL libssh' +# compiler: llvm@15 +# install: libssh +# configure: --enable-debug --with-libssh --with-openssl=$(brew --prefix openssl) --enable-websockets +# macos-version-min: '10.9' +# - name: '!ssl c-ares' +# compiler: clang +# configure: --enable-debug --enable-ares --without-ssl --enable-websockets +# macos-version-min: '10.9' +# - name: '!ssl HTTP-only' +# compiler: clang +# configure: | +# --enable-debug \ +# --disable-alt-svc --disable-dict --disable-file --disable-ftp --disable-gopher --disable-imap \ +# --disable-ldap --disable-pop3 --disable-rtmp --disable-rtsp --disable-scp --disable-sftp \ +# --disable-shared --disable-smb --disable-smtp --disable-telnet --disable-tftp --disable-unix-sockets \ +# --without-brotli --without-gssapi --without-libidn2 --without-libpsl --without-librtmp --without-libssh2 \ +# --without-nghttp2 --without-ntlm-auth --without-ssl --without-zlib --without-zstd +# +# macos-version-min: '10.15' # Catalina (2019) - name: 'SecureTransport libssh2' compiler: clang + install: httpd configure: --enable-debug --with-secure-transport --enable-websockets --with-libssh2=$(brew --prefix libssh2) macos-version-min: '10.8' - - name: 'SecureTransport libssh2 10.12' - compiler: clang - configure: --enable-debug --with-secure-transport --enable-websockets --with-libssh2=$(brew --prefix libssh2) - macos-version-min: '10.12' # for monotonic timers - cflags: '-Wno-deprecated-declarations' - - name: 'SecureTransport libssh2' - compiler: gcc-12 - configure: --enable-debug --with-secure-transport --enable-websockets --with-libssh2=$(brew --prefix libssh2) - macos-version-min: '10.8' - - name: 'LibreSSL' - compiler: clang - install: libressl - configure: --enable-debug --with-openssl=$(brew --prefix libressl) --enable-websockets - macos-version-min: '10.9' - - name: 'OpenSSL' - compiler: clang - configure: --enable-debug --with-openssl=$(brew --prefix openssl) --enable-websockets - macos-version-min: '10.9' - - name: 'OpenSSL torture !FTP' - compiler: clang - configure: --enable-debug --disable-shared --disable-threaded-resolver --with-openssl=$(brew --prefix openssl) --enable-websockets - tflags: -n -t --shallow=25 !FTP - macos-version-min: '10.9' - - name: 'OpenSSL torture FTP' - compiler: clang - configure: --enable-debug --disable-shared --disable-threaded-resolver --with-openssl=$(brew --prefix openssl) --enable-websockets - tflags: -n -t --shallow=20 FTP - macos-version-min: '10.9' - - name: 'OpenSSL libssh2 !ldap 10.15' - compiler: clang - configure: --enable-debug --disable-ldap --with-openssl=$(brew --prefix openssl) --enable-websockets - macos-version-min: '10.15' +# - name: 'SecureTransport libssh2 10.12' +# compiler: clang +# configure: --enable-debug --with-secure-transport --enable-websockets --with-libssh2=$(brew --prefix libssh2) +# macos-version-min: '10.12' # for monotonic timers +# cflags: '-Wno-deprecated-declarations' +# - name: 'SecureTransport libssh2' +# compiler: gcc-12 +# configure: --enable-debug --with-secure-transport --enable-websockets --with-libssh2=$(brew --prefix libssh2) +# macos-version-min: '10.8' +# - name: 'LibreSSL' +# compiler: clang +# install: libressl +# configure: --enable-debug --with-openssl=$(brew --prefix libressl) --enable-websockets +# macos-version-min: '10.9' +# - name: 'OpenSSL' +# compiler: clang +# configure: --enable-debug --with-openssl=$(brew --prefix openssl) --enable-websockets +# macos-version-min: '10.9' +# - name: 'OpenSSL torture !FTP' +# compiler: clang +# configure: --enable-debug --disable-shared --disable-threaded-resolver --with-openssl=$(brew --prefix openssl) --enable-websockets +# tflags: -n -t --shallow=25 !FTP +# macos-version-min: '10.9' +# - name: 'OpenSSL torture FTP' +# compiler: clang +# configure: --enable-debug --disable-shared --disable-threaded-resolver --with-openssl=$(brew --prefix openssl) --enable-websockets +# tflags: -n -t --shallow=20 FTP +# macos-version-min: '10.9' +# - name: 'OpenSSL libssh2 !ldap 10.15' +# compiler: clang +# configure: --enable-debug --disable-ldap --with-openssl=$(brew --prefix openssl) --enable-websockets +# macos-version-min: '10.15' steps: - name: 'brew install' # Run this command with retries because of spurious failures seen @@ -178,7 +180,7 @@ jobs: run: | python3 -m venv $HOME/venv source $HOME/venv/bin/activate - python3 -m pip install impacket + python3 -m pip install impacket pytest psutil - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 @@ -213,6 +215,7 @@ jobs: fi if [[ '${{ matrix.compiler }}' = 'llvm'* ]]; then options+=" --target=$(uname -m)-apple-darwin" + options+=" --with-test-httpd=$(brew --prefix httpd)" CC+=" --target=$(uname -m)-apple-darwin" fi if [ '${{ matrix.compiler }}' != 'clang' ]; then @@ -239,29 +242,40 @@ jobs: - name: 'curl version' run: bld/src/curl --disable --version - - name: 'make examples' - run: make -C bld V=1 examples - - - name: 'make tests' - run: make -C bld V=1 -C tests - - - name: 'run tests' +# - name: 'make examples' +# run: make -C bld V=1 examples +# +# - name: 'make tests' +# run: make -C bld V=1 -C tests +# +# - name: 'run tests' +# run: | +# export TFLAGS='${{ matrix.tflags }} -j10' +# if [[ '${{ matrix.compiler }}' = 'gcc'* ]]; then +# TFLAGS+=' ~RTSP' # 567 568 569 570 571 572 577 689 3100 +# TFLAGS+=' ~1156 ~1539' # HTTP Content-Range, Content-Length +# if [[ '${{ matrix.configure }}' = *'--with-secure-transport'* ]]; then +# TFLAGS+=' ~2100' # 2100:'HTTP GET using DoH' https://github.com/curl/curl/actions/runs/9942146678/job/27462937524#step:15:5059 +# TFLAGS+=' ~HTTP/2' # 2400 2401 2402 2403 2404 2406, SecureTransport + nghttp2 +# else +# TFLAGS+=' ~2402 ~2404' # non-SecureTransport + nghttp2 +# fi +# fi +# rm -f $HOME/.curlrc +# make -C bld V=1 test-ci + + - name: 'run pytest' run: | - export TFLAGS='${{ matrix.tflags }} -j10' - if [[ '${{ matrix.compiler }}' = 'gcc'* ]]; then - TFLAGS+=' ~RTSP' # 567 568 569 570 571 572 577 689 3100 - TFLAGS+=' ~1156 ~1539' # HTTP Content-Range, Content-Length - if [[ '${{ matrix.configure }}' = *'--with-secure-transport'* ]]; then - TFLAGS+=' ~2100' # 2100:'HTTP GET using DoH' https://github.com/curl/curl/actions/runs/9942146678/job/27462937524#step:15:5059 - TFLAGS+=' ~HTTP/2' # 2400 2401 2402 2403 2404 2406, SecureTransport + nghttp2 - else - TFLAGS+=' ~2402 ~2404' # non-SecureTransport + nghttp2 - fi - fi - rm -f $HOME/.curlrc - make -C bld V=1 test-ci + python3 -m venv $HOME/venv + source $HOME/venv/bin/activate + python3 -m pytest -v tests -k 17_ -v -s + env: + BUILD_DIR: bld + TFLAGS: "${{ matrix.build.tflags }}" + CURL_CI: github cmake: + if: false name: 'CM ${{ matrix.compiler }} ${{ matrix.build.name }}' runs-on: 'macos-latest' timeout-minutes: 10 @@ -382,7 +396,7 @@ jobs: make -C bld test-ci combinations: # Test buildability with host OS, Xcode / SDK, compiler, target-OS, SecureTransport/not, built tool, combinations - if: true # Set to `true` to enable this test matrix. It runs quickly. + if: false # Set to `true` to enable this test matrix. It runs quickly. name: "${{ matrix.build == 'cmake' && 'CM' || 'AM' }} ${{ matrix.compiler }} ${{ matrix.image }} ${{ matrix.xcode }} ${{ matrix.config }}" runs-on: ${{ matrix.image }} timeout-minutes: 30 diff --git a/tests/http/testenv/env.py b/tests/http/testenv/env.py index 2cd6432364b304..fec1476b564274 100644 --- a/tests/http/testenv/env.py +++ b/tests/http/testenv/env.py @@ -52,24 +52,22 @@ def init_config_from(conf_path): return None -TESTS_HTTPD_PATH = os.path.dirname(os.path.dirname(__file__)) -DEF_CONFIG = init_config_from(os.path.join(TESTS_HTTPD_PATH, 'config.ini')) - -TOP_PATH = os.path.dirname(os.path.dirname(TESTS_HTTPD_PATH)) -CURL = os.path.join(TOP_PATH, 'src/curl') - - class EnvConfig: def __init__(self): - self.tests_dir = TESTS_HTTPD_PATH - self.gen_dir = os.path.join(self.tests_dir, 'gen') - self.project_dir = os.path.dirname(os.path.dirname(self.tests_dir)) - self.config = DEF_CONFIG - # check cur and its features - self.curl = CURL + if 'BUILD_DIR' in os.environ: + BUILD_DIR = os.path.realpath(os.environ['BUILD_DIR']) + else: + BUILD_DIR = f'{os.path.dirname(__file__)}/../../../' + self.tests_dir = os.path.normpath(f'{BUILD_DIR}/tests/http/') + self.gen_dir = os.path.normpath(f'{BUILD_DIR}/tests/http/gen') + self.project_dir = os.path.normpath(f'{BUILD_DIR}/') + self.config = init_config_from(os.path.normpath(f'{BUILD_DIR}/tests/http/config.ini')) + # check curl and its features if 'CURL' in os.environ: self.curl = os.environ['CURL'] + else: + self.curl = os.path.normpath(f'{BUILD_DIR}/src/curl') self.curl_props = { 'version': None, 'os': None, diff --git a/tests/http/testenv/httpd.py b/tests/http/testenv/httpd.py index 8cc2c34a5f1f08..fcf956fed5efb9 100644 --- a/tests/http/testenv/httpd.py +++ b/tests/http/testenv/httpd.py @@ -70,6 +70,7 @@ def __init__(self, env: Env, proxy_auth: bool = False): self._docs_dir = os.path.join(self._apache_dir, 'docs') self._conf_dir = os.path.join(self._apache_dir, 'conf') self._conf_file = os.path.join(self._conf_dir, 'test.conf') + print(f'CONF_DIR: {self._conf_dir}') self._logs_dir = os.path.join(self._apache_dir, 'logs') self._error_log = os.path.join(self._logs_dir, 'error_log') self._tmp_dir = os.path.join(self._apache_dir, 'tmp') @@ -150,8 +151,19 @@ def start(self): with open(os.path.join(self._apache_dir, 'xxx'), 'a') as fd: fd.write('start of server\n') r = self._apachectl('start') + print('******************************************************************************************************') + print('APACHECTL') + print('******************************************************************************************************') + printf(r.stdout) + print('******************************************************************************************************') if r.exit_code != 0: log.error(f'failed to start httpd: {r}') + with open(self._digest_passwords, 'w') as fd: + print('******************************************************************************************************') + print('APACHE LOG') + print('******************************************************************************************************') + fd.read() + print('******************************************************************************************************') return False self._loaded_extra_configs = copy.deepcopy(self._extra_configs) return self.wait_live(timeout=timedelta(seconds=5)) @@ -377,6 +389,11 @@ def _write_config(self): f'', ]) + print('******************************************************************************************************') + print('CONF') + print('******************************************************************************************************') + print("\n".join(conf)) + print('******************************************************************************************************') fd.write("\n".join(conf)) with open(os.path.join(self._conf_dir, 'mime.types'), 'w') as fd: fd.write("\n".join([