]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: speed up builds with single-binary test bundles
authorViktor Szakats <commit@vsz.me>
Mon, 2 Sep 2024 12:46:00 +0000 (14:46 +0200)
committerViktor Szakats <commit@vsz.me>
Sun, 22 Sep 2024 07:51:15 +0000 (09:51 +0200)
Add support for single-block binaries that contain all libtests and
unit tests respectively.

Enable with:
- autotools: `--enable-test-bundles`
- cmake: `-DCURL_TEST_BUNDLES=ON`

(They are compatible with `--enable-unity` and `-DCMAKE_UNITY_BUILD=ON`
options, for further speed-up.)

Makes libtests and unit tests build _fast_, needing little disk space
even in static mode. Similar to CMake unity mode, but with a custom
script, also supporting autotools builds.

The price is having to deal with symbols/macros colliding between
`lib*.c` and `unit*.c` sources. Maybe with naming conventions or other
solutions this can be improved gradually and reduce the need for manual
intervention by `mk-bundle.mk`. I've included a script that does the bulk
of detecting name collisions.

Also:
- CI: enable test bundles.
- CI: build tests in more jobs.
- lib2305: fix FILE handle leak.
- unit1661: fix memleak found by torture test by releasing the `bufref`
  structure in `unit_stop()` that was allocated in `unit_setup()`.
  ```
  test 1661...[bufref unit tests]
  Leak detected: memory still allocated: 13 bytes
   allocated by /home/runner/work/curl/curl/tests/unit/unit1661.c:70
   1661: torture FAILED: function number 1 in test.
  ```
  Ref: https://github.com/curl/curl/actions/runs/10967279334/job/30456745290?pr=14772#step:8:41

Similar test suite builds with autotools default and cmake+bundle+unity:
- GHA/Linux: 33s vs 7s
  https://github.com/curl/curl/actions/runs/10705668823/job/29681617374
- GHA/macOS 34s vs 2s
  https://github.com/curl/curl/actions/runs/10705668813/job/29681632885
- GHA/FreeBSD: 15m25 vs 6m21 (full workflow time, ~qemu)
  https://github.com/curl/curl/actions/runs/10705668811/job/29681607915
- GHA/Cygwin: 9m52 vs 32s
  https://github.com/curl/curl/actions/runs/10705668809/job/29681609965
- GHA/MSYS2: 3m52 vs 14s
  https://github.com/curl/curl/actions/runs/10705668808/job/29681624295
- GHA/mingw-w64: 5m45 vs 30s
  https://github.com/curl/curl/actions/runs/10705668808/job/29681628787

Autotools test suite builds compared between master -> `--enable-test-bundles`:
- GHA/Linux: 33s -> 9s (run tests: 22m23 -> 20m44)
  https://github.com/curl/curl/actions/runs/10710030193/job/29695932185
  https://github.com/curl/curl/actions/runs/10967831456/job/30458220344
- GHA/macOS: 25s -> 4s (run tests: 2m58 -> 2m24)
  https://github.com/curl/curl/actions/runs/10710030195/job/29695938444
  https://github.com/curl/curl/actions/runs/10967831452/job/30458225762
- GHA/non-native (FreeBSD): 4m8 -> 3m12 (full workflow time, ~qemu)
  https://github.com/curl/curl/actions/runs/10710030198/job/29695928401
  https://github.com/curl/curl/actions/runs/10967831458/job/30458212692
- GHA/Cygwin: 9m25 -> 1m9 (run tests: 9m19 -> 3m28)
  https://github.com/curl/curl/actions/runs/10710030212/job/29695928213
  https://github.com/curl/curl/actions/runs/10967831453/job/30458213268
- GHA/MSYS2: 3m54 -> 32s (run tests: 6m3 -> 3m59)
  https://github.com/curl/curl/actions/runs/10710030190/job/29704850591
  https://github.com/curl/curl/actions/runs/10967831449/job/30459280005
- GHA/mingw-w64: 5m42 -> 1m5 (run tests: 7m41 -> 5m36)
  https://github.com/curl/curl/actions/runs/10710030190/job/29704852058
  https://github.com/curl/curl/actions/runs/10967831449/job/30459280862
- Azure MSYS2 mingw64 openssl: 38m55 -> 11m58
  https://dev.azure.com/daniel0244/curl/_build/results?buildId=25546&view=logs&j=b58b8c59-0f61-52e9-0f9e-fad562a1e77f&t=0f9230a7-3b10-53ca-9938-700ece377c5e
  https://dev.azure.com/daniel0244/curl/_build/results?buildId=25547&view=logs&jobId=39473db1-3945-55d5-deb5-c218fad88dce&j=b58b8c59-0f61-52e9-0f9e-fad562a1e77f&t=0f9230a7-3b10-53ca-9938-700ece377c5e
- Azure Ubuntu default: 2m15 -> 55s (all build)
  https://dev.azure.com/daniel0244/curl/_build/results?buildId=25546&view=logs&j=9d58b9ac-e1e6-53b6-f83a-1f9f1d912522&t=a6b38d83-e7cf-5a9b-c762-a178412717b7
  https://dev.azure.com/daniel0244/curl/_build/results?buildId=25547&view=logs&jobId=39473db1-3945-55d5-deb5-c218fad88dce&j=9d58b9ac-e1e6-53b6-f83a-1f9f1d912522&t=a6b38d83-e7cf-5a9b-c762-a178412717b7

Cmake test suite builds compared between master -> `-DCURL_TEST_BUNDLES=ON` + unity:
- GHA/Linux: 29s -> 7s (run tests: 4m50 -> 4m57, 20m43 -> 20m45)
  https://github.com/curl/curl/actions/runs/10710030193/job/29695941814
  https://github.com/curl/curl/actions/runs/10705668823/job/29681622201
- GHA/Linux old: 44s -> 13s (bundle+no unity) (run tests: 5m5 -> 5m6)
  https://github.com/curl/curl/actions/runs/10718264094/job/29719794727
  https://github.com/curl/curl/actions/runs/10718653175/job/29721009613
- GHA/macOS: 32s -> 2s (run tests: 2m43 -> 2m40)
  https://github.com/curl/curl/actions/runs/10710030195/job/29695931956
  https://github.com/curl/curl/actions/runs/10705668813/job/29681638937
- GHA/non-native (*BSD): inconclusive (full workflow time, ~qemu)
  https://github.com/curl/curl/actions/runs/10710030198
  https://github.com/curl/curl/actions/runs/10705668811
- GHA/Cygwin: 3m9 -> 32s
  https://github.com/curl/curl/actions/runs/10710030212/job/29695929075
  https://github.com/curl/curl/actions/runs/10705668809/job/29681609965
- GHA/MSYS2: 2m24 -> 14s
  https://github.com/curl/curl/actions/runs/10710030190/job/29704850996
  https://github.com/curl/curl/actions/runs/10705668808/job/29681624295
- GHA/mingw-w64: 3m56 -> 30s (run tests: 4m2 -> 3m52)
  https://github.com/curl/curl/actions/runs/10710030190/job/29704852219
  https://github.com/curl/curl/actions/runs/10705668808/job/29681631393
- GHA/mingw-w64-old: 7m19 -> 1m44 (run tests: 3m30 -> 2m53)
  https://github.com/curl/curl/actions/runs/10710030190/job/29704849763
  https://github.com/curl/curl/actions/runs/10705668808/job/29681622329
- GHA/MSVC: 3m22 -> 13s (run tests: 9m43 -> 4m22)
  https://github.com/curl/curl/actions/runs/10710030190/job/29704850411
  https://github.com/curl/curl/actions/runs/10705668808/job/29681623313
- AppVeyor CI MSVC 2008: 4m3 -> 45s (full build)
- AppVeyor CI MSVC 2010: 2m56 -> 1m8 (full build)
- AppVeyor CI MSVC 2022: 10m19 -> 2m23 (full build)
  https://ci.appveyor.com/project/curlorg/curl/builds/50538455
  https://ci.appveyor.com/project/curlorg/curl/builds/50536558
- AppVeyor CI total build time: 10m30 (master) -> 6m48 (unity) -> 4m5 (bundle) -> 3m24 (bundle+unity) -> 5m7 (bundle+unity+all jobs building tests)

Closes #14772

86 files changed:
.circleci/config.yml
.github/workflows/awslc.yml
.github/workflows/cygwin.yml
.github/workflows/http3-linux.yml
.github/workflows/linux-old.yml
.github/workflows/linux.yml
.github/workflows/linux32.yml
.github/workflows/macos.yml
.github/workflows/non-native.yml
.github/workflows/torture.yml
.github/workflows/windows.yml
.github/workflows/wolfssl.yml
appveyor.sh
appveyor.yml
configure.ac
tests/CMakeLists.txt
tests/Makefile.am
tests/globalconfig.pm
tests/libtest/.gitignore
tests/libtest/CMakeLists.txt
tests/libtest/Makefile.am
tests/libtest/Makefile.inc
tests/libtest/first.c
tests/libtest/first.h [new file with mode: 0644]
tests/libtest/lib1156.c
tests/libtest/lib1514.c
tests/libtest/lib1517.c
tests/libtest/lib1525.c
tests/libtest/lib1526.c
tests/libtest/lib1527.c
tests/libtest/lib1554.c
tests/libtest/lib1565.c
tests/libtest/lib1591.c
tests/libtest/lib1662.c
tests/libtest/lib1911.c
tests/libtest/lib1940.c
tests/libtest/lib2301.c
tests/libtest/lib2304.c
tests/libtest/lib2305.c
tests/libtest/lib3207.c
tests/libtest/lib500.c
tests/libtest/lib506.c
tests/libtest/lib508.c
tests/libtest/lib510.c
tests/libtest/lib518.c
tests/libtest/lib530.c
tests/libtest/lib537.c
tests/libtest/lib540.c
tests/libtest/lib552.c
tests/libtest/lib554.c
tests/libtest/lib557.c
tests/libtest/lib578.c
tests/libtest/lib579.c
tests/libtest/lib582.c
tests/libtest/lib586.c
tests/libtest/lib643.c
tests/libtest/lib650.c
tests/libtest/lib651.c
tests/libtest/lib652.c
tests/libtest/lib654.c
tests/libtest/lib666.c
tests/libtest/lib667.c
tests/libtest/lib668.c
tests/libtest/lib670.c
tests/libtest/lib677.c
tests/libtest/libntlmconnect.c
tests/libtest/mk-lib1521.pl
tests/libtest/test.h
tests/mk-bundle-hints.sh [new file with mode: 0755]
tests/mk-bundle.pl [new file with mode: 0755]
tests/runner.pm
tests/runtests.md
tests/runtests.pl
tests/unit/.gitignore
tests/unit/CMakeLists.txt
tests/unit/Makefile.am
tests/unit/Makefile.inc
tests/unit/unit1302.c
tests/unit/unit1303.c
tests/unit/unit1304.c
tests/unit/unit1305.c
tests/unit/unit1398.c
tests/unit/unit1606.c
tests/unit/unit1652.c
tests/unit/unit1661.c
tests/unit/unit1663.c

index a0e802909d22c3e90da2abe7b213e68ab010bd49..264fcb5f80d115c39685df723dd64353be910319 100644 (file)
@@ -33,7 +33,7 @@ commands:
       - run:
           command: |
             autoreconf -fi
-            ./configure --disable-dependency-tracking --enable-unity --enable-warnings --enable-werror --with-openssl \
+            ./configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror --with-openssl \
               || { tail -1000 config.log; false; }
 
   configure-openssl-no-verbose:
@@ -41,7 +41,7 @@ commands:
       - run:
           command: |
             autoreconf -fi
-            ./configure --disable-dependency-tracking --enable-unity --disable-verbose --enable-werror --with-openssl \
+            ./configure --disable-dependency-tracking --enable-unity --enable-test-bundles --disable-verbose --enable-werror --with-openssl \
               || { tail -1000 config.log; false; }
 
   configure-no-proxy:
@@ -49,7 +49,7 @@ commands:
       - run:
           command: |
             autoreconf -fi
-            ./configure --disable-dependency-tracking --enable-unity --disable-proxy --enable-werror --with-openssl \
+            ./configure --disable-dependency-tracking --enable-unity --enable-test-bundles --disable-proxy --enable-werror --with-openssl \
               || { tail -1000 config.log; false; }
 
   install-cares:
@@ -110,7 +110,7 @@ commands:
       - run:
           command: |
             autoreconf -fi
-            ./configure --disable-dependency-tracking --enable-unity --enable-warnings --enable-werror --with-openssl --enable-ares \
+            ./configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror --with-openssl --enable-ares \
               || { tail -1000 config.log; false; }
 
   configure-wolfssh:
@@ -118,7 +118,7 @@ commands:
       - run:
           command: |
             autoreconf -fi
-            LDFLAGS="-Wl,-rpath,$HOME/wssh/lib" ./configure --disable-dependency-tracking --enable-unity --enable-warnings --enable-werror --with-wolfssl=$HOME/wssl --with-wolfssh=$HOME/wssh \
+            LDFLAGS="-Wl,-rpath,$HOME/wssh/lib" ./configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror --with-wolfssl=$HOME/wssl --with-wolfssh=$HOME/wssh \
               || { tail -1000 config.log; false; }
 
   configure-cares-debug:
@@ -126,7 +126,7 @@ commands:
       - run:
           command: |
             autoreconf -fi
-            ./configure --disable-dependency-tracking --enable-unity --enable-debug --enable-werror --with-openssl --enable-ares \
+            ./configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-debug --enable-werror --with-openssl --enable-ares \
               || { tail -1000 config.log; false; }
 
   build:
index 73b3d35f2f2bc0dbc5aeceea49805fd2dd60f31d..742075561cc71bc4867f02b7318357014f5e01c9 100644 (file)
@@ -142,7 +142,9 @@ jobs:
 
       - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
 
-      - run: cmake -Bbuild -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DOPENSSL_ROOT_DIR=$HOME/awslc -DBUILD_SHARED_LIBS=ON .
+      - run: |
+          cmake -B build -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON -DCURL_WERROR=ON \
+            -DOPENSSL_ROOT_DIR=$HOME/awslc -DBUILD_SHARED_LIBS=ON
         name: 'cmake generate out-of-tree'
 
       - run: cmake --build build --parallel
@@ -150,3 +152,6 @@ jobs:
 
       - run: cmake --install build --prefix $HOME/curl --strip
         name: 'cmake install'
+
+      - run: cmake --build build --parallel --target testdeps
+        name: 'cmake build tests'
index 715931415596b1841a99c787bdcd8a684ebefbf9..a2653058bb187b90d1a06cac77d698302fa97cd6 100644 (file)
@@ -81,7 +81,7 @@ jobs:
         timeout-minutes: 5
         run: |
           PATH="/usr/bin:$(cygpath "${SYSTEMROOT}")/System32"
-          mkdir bld && cd bld && ../configure --enable-unity --enable-warnings --enable-werror \
+          mkdir bld && cd bld && ../configure --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
             --prefix="${HOME}"/install \
             --enable-websockets \
             --with-openssl \
@@ -139,7 +139,7 @@ jobs:
         run: |
           PATH="/usr/bin:$(cygpath "${SYSTEMROOT}")/System32"
           cmake -B bld -G Ninja ${options} \
-            -DCMAKE_UNITY_BUILD=ON \
+            -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
             -DCURL_WERROR=ON \
             -DENABLE_WEBSOCKETS=ON \
             -DCURL_BROTLI=ON \
index d58f64ea1e9e6d7214491fb191c734766669eedf..8bd34ab05942e09a066d72751d71f481712e7edd 100644 (file)
@@ -451,7 +451,7 @@ jobs:
       - run: autoreconf -fi
         name: 'autoreconf'
 
-      - run: ./configure --disable-dependency-tracking --enable-unity ${{ matrix.build.configure }}
+      - run: ./configure --disable-dependency-tracking --enable-unity --enable-test-bundles ${{ matrix.build.configure }}
         name: 'configure'
 
       - run: make V=1
index 6075393214a3b7d913a8dfd8083663f8d4dbe9da..fb10892ddbf6e5a7110b327d49e0d2271430cedc 100644 (file)
@@ -79,7 +79,7 @@ jobs:
         run: |
           mkdir bld-1
           cd bld-1
-          cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \
+          cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \
             -DENABLE_ARES=OFF -DCURL_ZSTD=OFF -DCURL_USE_GSSAPI=OFF -DCURL_USE_LIBSSH2=ON -DCURL_USE_LIBSSH=OFF -DUSE_LIBRTMP=ON -DENABLE_WEBSOCKETS=ON
           make install
           src/curl --disable --version
@@ -88,7 +88,7 @@ jobs:
         run: |
           mkdir bld-cares
           cd bld-cares
-          cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \
+          cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \
             -DENABLE_ARES=ON -DCURL_ZSTD=ON -DCURL_USE_GSSAPI=ON -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=ON -DUSE_LIBRTMP=ON -DENABLE_WEBSOCKETS=ON \
             -DCURL_LIBCURL_VERSIONED_SYMBOLS=ON
 
@@ -113,7 +113,7 @@ jobs:
         run: |
           mkdir bld-am
           cd bld-am
-          ../configure --disable-dependency-tracking --enable-unity --enable-warnings --enable-werror \
+          ../configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
             --with-openssl --enable-ares --with-libssh --with-zstd --with-gssapi --with-librtmp --enable-websockets \
             --prefix="$PWD"/../install-am
 
index 2ca69877e5abe64b1f8937f0c9f3696713e15647..be96dd2e1b7b32cdac2365f6b75b55deeaf76e2a 100644 (file)
@@ -498,7 +498,7 @@ jobs:
 
       - run: |
           ${{ matrix.build.configure-prefix }} \
-          ./configure --disable-dependency-tracking --enable-unity --enable-warnings --enable-werror \
+          ./configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
             ${{ matrix.build.configure }}
         if: ${{ matrix.build.configure }}
         name: 'configure (autotools)'
index 43494f289c8aadd9eda91ea84bd9b3fcf7094d75..14380450d9e2493d2c501611d1c0096bc3f3a81a 100644 (file)
@@ -70,7 +70,7 @@ jobs:
         name: 'autoreconf'
 
       - run: |
-          ./configure --disable-dependency-tracking --enable-unity --enable-warnings --enable-werror \
+          ./configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
             ${{ matrix.build.configure }}
         name: 'configure'
 
index 96ac6704a4eb56c4649add1de9f2c13018114283..61aa95d9a1d03f406b594e02517337d5b854b4a4 100644 (file)
@@ -193,7 +193,7 @@ jobs:
             options+=" --with-sysroot=$(xcrun --sdk macosx --show-sdk-path 2>/dev/null)"
             CFLAGS+=" --sysroot=$(xcrun --sdk macosx --show-sdk-path 2>/dev/null)"
           fi
-          mkdir bld && cd bld && ../configure --enable-unity --enable-warnings --enable-werror \
+          mkdir bld && cd bld && ../configure --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
             --disable-dependency-tracking \
             --with-libpsl=$(brew --prefix libpsl) \
             ${{ matrix.configure }} ${options}
@@ -343,7 +343,7 @@ jobs:
               fi
             done
           fi
-          cmake -B bld -G Ninja -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON \
+          cmake -B bld -G Ninja -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON -DCURL_WERROR=ON \
             -DCMAKE_OSX_DEPLOYMENT_TARGET=${{ matrix.build.macos-version-min }} \
             "-DCMAKE_C_COMPILER_TARGET=$(uname -m | sed 's/arm64/aarch64/')-apple-darwin$(uname -r)" \
             ${{ matrix.build.generate }}
@@ -608,7 +608,7 @@ jobs:
             [ '${{ matrix.config }}' = 'SecureTransport' ] && options+=' --with-secure-transport'
             CFLAGS+=' -mmacosx-version-min=${{ matrix.macos-version-min }}'
             # would pick up nghttp2, libidn2, but libssh2 is disabled by default
-            mkdir bld && cd bld && ../configure --enable-unity --enable-warnings --enable-werror \
+            mkdir bld && cd bld && ../configure --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
               --disable-dependency-tracking \
               --disable-docs --disable-manual \
               --without-nghttp2 --without-libidn2 \
@@ -618,7 +618,7 @@ jobs:
             [ '${{ matrix.config }}' = 'OpenSSL' ]         && options+=' -DCURL_USE_OPENSSL=ON'
             [ '${{ matrix.config }}' = 'SecureTransport' ] && options+=' -DCURL_USE_SECTRANSP=ON'
             # would pick up nghttp2, libidn2, and libssh2
-            cmake -B bld -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON \
+            cmake -B bld -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON -DCURL_WERROR=ON \
               -DCMAKE_OSX_DEPLOYMENT_TARGET=${{ matrix.macos-version-min }} \
               "-DCMAKE_IGNORE_PREFIX_PATH=$(brew --prefix)" \
               "-DCMAKE_C_COMPILER_TARGET=$(uname -m | sed 's/arm64/aarch64/')-apple-darwin$(uname -r)" \
index cfa030a33a1f4ab84d849e61f5ad22d8755cebfb..1efe5028094037749b2af50e3b8ae10692d5f980 100644 (file)
@@ -55,7 +55,7 @@ jobs:
             # https://pkgsrc.se/
             sudo pkgin -y install cmake ninja-build pkg-config perl brotli heimdal openldap-client libssh2 libidn2 libpsl nghttp2 py311-impacket
             cmake -B bld -G Ninja \
-              -DCMAKE_UNITY_BUILD=ON \
+              -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
               -DCURL_WERROR=ON \
               -DENABLE_DEBUG=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG= \
               -DENABLE_WEBSOCKETS=ON \
@@ -64,8 +64,8 @@ jobs:
               || { cat bld/CMakeFiles/CMake*.yaml; false; }
             cmake --build bld --config Debug --parallel 3
             bld/src/curl --disable --version
+            cmake --build bld --config Debug --parallel 3 --target testdeps
             if [ '${{ matrix.arch }}' = 'x86_64' ]; then  # Slow on emulated CPU
-              cmake --build bld --config Debug --parallel 3 --target testdeps
               export TFLAGS='-j0'  # flakies: ~389 ~392 ~TFTP and more
               cmake --build bld --config Debug --target test-ci
             fi
@@ -92,7 +92,7 @@ jobs:
             # https://openbsd.app/
             sudo pkg_add cmake ninja perl brotli openldap-client libssh2 libidn2 libpsl nghttp2 python3 py3-impacket
             cmake -B bld -G Ninja \
-              -DCMAKE_UNITY_BUILD=ON \
+              -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
               -DCURL_WERROR=ON \
               -DENABLE_DEBUG=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG= \
               -DENABLE_WEBSOCKETS=ON \
@@ -101,8 +101,8 @@ jobs:
               || { cat bld/CMakeFiles/CMake*.yaml; false; }
             cmake --build bld --config Debug --parallel 3
             bld/src/curl --disable --version
+            cmake --build bld --config Debug --parallel 3 --target testdeps
             if [ '${{ matrix.arch }}' = 'x86_64' ]; then  # Slow on emulated CPU
-              cmake --build bld --config Debug --parallel 3 --target testdeps
               export TFLAGS='-j8 ~3017 ~TFTP ~FTP'  # FIXME: TFTP requests executed twice? Related: `curl: (69) TFTP: Access Violation`?
               cmake --build bld --config Debug --target test-ci
             fi
@@ -136,7 +136,7 @@ jobs:
               pkgconf brotli openldap26-client libidn2 libnghttp2 nghttp2 stunnel py311-impacket
             autoreconf -fi
             export CC='${{ matrix.compiler }}'
-            mkdir bld && cd bld && ../configure --enable-unity --enable-debug --enable-warnings --enable-werror \
+            mkdir bld && cd bld && ../configure --enable-unity --enable-test-bundles --enable-debug --enable-warnings --enable-werror \
               --prefix="${HOME}"/install \
               --enable-websockets \
               --with-openssl \
@@ -144,8 +144,8 @@ jobs:
               --disable-dependency-tracking || { tail -n 1000 config.log; false; }
             make -j3 install
             src/curl --disable --version
+            make -j3 -C tests
             if [ '${{ matrix.arch }}' = 'x86_64' ]; then  # Slow on emulated CPU
-              make -j3 -C tests
               make test-ci V=1 TFLAGS='-j8 ~FTP'
             fi
             echo '::group::build examples'
@@ -165,7 +165,7 @@ jobs:
               pkgconf brotli openldap26-client libidn2 libnghttp2 nghttp2 stunnel py311-impacket
             cmake -B bld -G Ninja \
               '-DCMAKE_C_COMPILER=${{ matrix.compiler }}' \
-              -DCMAKE_UNITY_BUILD=ON \
+              -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
               -DCURL_WERROR=ON \
               -DENABLE_DEBUG=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG= \
               -DENABLE_WEBSOCKETS=ON \
@@ -174,8 +174,8 @@ jobs:
               || { cat bld/CMakeFiles/CMake*.yaml; false; }
             cmake --build bld --config Debug --parallel 3
             bld/src/curl --disable --version
+            cmake --build bld --config Debug --parallel 3 --target testdeps
             if [ '${{ matrix.arch }}' = 'x86_64' ]; then  # Slow on emulated CPU
-              cmake --build bld --config Debug --parallel 3 --target testdeps
               export TFLAGS='-j8 ~FTP'
               cmake --build bld --config Debug --target test-ci
             fi
@@ -198,7 +198,7 @@ jobs:
           run: |
             ln -s /usr/bin/gcpp /usr/bin/cpp  # Some tests expect `cpp`, which is named `gcpp` in this env.
             autoreconf -fi
-            mkdir bld && cd bld && ../configure --enable-unity --enable-debug --enable-warnings --enable-werror \
+            mkdir bld && cd bld && ../configure --enable-unity --enable-test-bundles --enable-debug --enable-warnings --enable-werror \
               --prefix="${HOME}"/install \
               --enable-websockets \
               --with-openssl \
index 450ebaa08c5ffd73fc31e31300d7e6be85a43699..ae6a318635cf4904e2275f50ee1a20b48240563e 100644 (file)
@@ -69,7 +69,7 @@ jobs:
       - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
 
       - run: |
-          cmake -G Ninja -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON \
+          cmake -G Ninja -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON -DCURL_WERROR=ON \
             -DCURL_BROTLI=ON -DCURL_ZSTD=ON \
             ${{ matrix.build.generate }}
         name: 'cmake configure'
index e6f5e2c70ee38b527b84855ad9539ef25b3afdb8..cf1bc44e7508db9b930ffa74cc739d344a253767 100644 (file)
@@ -103,7 +103,7 @@ jobs:
         if: ${{ matrix.build == 'autotools' }}
         timeout-minutes: 5
         run: |
-          mkdir bld && cd bld && ../configure --enable-unity --enable-warnings --enable-werror \
+          mkdir bld && cd bld && ../configure --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
             --prefix="${HOME}"/install \
             --enable-websockets \
             --with-openssl \
@@ -196,7 +196,7 @@ jobs:
             "-DCMAKE_C_FLAGS=${cflags}" \
             "-DCMAKE_RC_COMPILE_OBJECT=${rcopts}" \
             '-DCMAKE_BUILD_TYPE=${{ matrix.type }}' \
-            -DCMAKE_UNITY_BUILD=ON \
+            -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
             -DCURL_WERROR=ON \
             -DENABLE_WEBSOCKETS=ON \
             -DCURL_BROTLI=ON \
@@ -329,7 +329,7 @@ jobs:
             '-GMSYS Makefiles' \
             -DCMAKE_C_COMPILER=gcc \
             '-DCMAKE_BUILD_TYPE=${{ matrix.type }}' \
-            -DCMAKE_UNITY_BUILD=ON \
+            -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
             -DCURL_WERROR=ON \
             -DENABLE_WEBSOCKETS=ON \
             -DCURL_USE_LIBPSL=OFF \
@@ -415,7 +415,7 @@ jobs:
       - name: 'autotools configure'
         if: ${{ matrix.build == 'autotools' }}
         run: |
-          mkdir bld && cd bld && ../configure --enable-unity --enable-warnings --enable-werror \
+          mkdir bld && cd bld && ../configure --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
             --host=${TRIPLET} \
             --with-schannel --with-winidn \
             --without-libpsl \
@@ -429,6 +429,10 @@ jobs:
         if: ${{ matrix.build == 'autotools' }}
         run: make -C bld -j5
 
+      - name: 'autotools build tests'
+        if: ${{ matrix.build == 'autotools' }}
+        run: make -C bld -j5 -C tests
+
       - name: 'autotools build examples'
         if: ${{ matrix.build == 'autotools' }}
         run: make -C bld -j5 examples
@@ -440,7 +444,7 @@ jobs:
             -DCMAKE_SYSTEM_NAME=Windows \
             -DCMAKE_C_COMPILER_TARGET=${TRIPLET} \
             -DCMAKE_C_COMPILER=${TRIPLET}-gcc \
-            -DCMAKE_UNITY_BUILD=ON \
+            -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
             -DCURL_WERROR=ON \
             -DCURL_USE_SCHANNEL=ON -DUSE_WIN32_IDN=ON \
             -DCURL_USE_LIBPSL=OFF
@@ -453,6 +457,10 @@ jobs:
         if: ${{ matrix.build == 'cmake' }}
         run: cmake --build bld --parallel 5
 
+      - name: 'cmake build tests'
+        if: ${{ matrix.build == 'cmake' }}
+        run: cmake --build bld --parallel 5 --target testdeps
+
       - name: 'cmake build examples'
         if: ${{ matrix.build == 'cmake' }}
         run: cmake --build bld --parallel 5 --target curl-examples
@@ -565,7 +573,7 @@ jobs:
             '-DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-${{ matrix.plat }}' \
             -DCMAKE_VS_GLOBALS=TrackFileAccess=false \
             '-DCMAKE_BUILD_TYPE=${{ matrix.type }}' \
-            -DCMAKE_UNITY_BUILD=ON \
+            -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
             -DCURL_WERROR=ON \
             -DENABLE_WEBSOCKETS=ON \
             -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG= \
index 3f7a9ba4dfe4aef1762a4bffd85a03ee2bfe28ed..49b1bd91740294cbd40dc9624aa5ac0f21b9a9a3 100644 (file)
@@ -84,7 +84,7 @@ jobs:
       - run: autoreconf -fi
         name: 'autoreconf'
 
-      - run: ./configure --disable-dependency-tracking --enable-unity --enable-warnings --enable-werror ${{ matrix.build.configure }}
+      - run: ./configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror ${{ matrix.build.configure }}
         name: 'configure'
 
       - run: make V=1
index 7237137d990246652b0d412a135f00062e71f18b..05939e548545d2c7ec8608ba3a01de258f7a2301 100644 (file)
@@ -56,6 +56,7 @@ if [ "${BUILD_SYSTEM}" = 'CMake' ]; then
     "-DBUILD_SHARED_LIBS=${SHARED}" \
     "-DENABLE_WEBSOCKETS=${WEBSOCKETS:-}" \
     "-DCMAKE_UNITY_BUILD=${UNITY}" \
+    '-DCURL_TEST_BUNDLES=ON' \
     '-DCURL_WERROR=ON' \
     "-DENABLE_DEBUG=${DEBUG}" \
     "-DENABLE_UNICODE=${ENABLE_UNICODE}" \
index 63fe9c8ca5433c3111ef862fee5f10bc24aaefec..79cb58d57a1644d880f10b8633168f9093eec326 100644 (file)
@@ -35,13 +35,13 @@ environment:
   OPENSSL: 'OFF'
   DEBUG: 'ON'
   SHARED: 'OFF'
-  TFLAGS: 'skipall'
+  TFLAGS: 'skiprun'
   EXAMPLES: 'OFF'
   matrix:
 
     # generated CMake-based Visual Studio builds
 
-    - job_name: 'CMake, VS2008, Release, x86, Schannel, Build-only'
+    - job_name: 'CMake, VS2008, Release, x86, Schannel, Build-tests'
       APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2015'
       BUILD_SYSTEM: CMake
       PRJ_GEN: 'Visual Studio 9 2008'
@@ -60,9 +60,8 @@ environment:
       ENABLE_UNICODE: 'OFF'
       HTTP_ONLY: 'OFF'
       SHARED: 'ON'
-      TFLAGS: 'skiprun'
       EXAMPLES: 'ON'
-    - job_name: 'CMake, VS2022, Release, x64, OpenSSL 3.2, WebSockets, Build-only'
+    - job_name: 'CMake, VS2022, Release, x64, OpenSSL 3.2, WebSockets, Build-tests'
       APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022'
       BUILD_SYSTEM: CMake
       PRJ_GEN: 'Visual Studio 17 2022'
@@ -85,7 +84,6 @@ environment:
       HTTP_ONLY: 'OFF'
       DEBUG: 'OFF'
       CURLDEBUG: 'ON'
-      TFLAGS: 'skiprun'
     - job_name: 'CMake, VS2010, Debug, x64, Schannel, Static, Build-tests & examples'
       APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2015'
       BUILD_SYSTEM: CMake
@@ -94,9 +92,8 @@ environment:
       SCHANNEL: 'ON'
       ENABLE_UNICODE: 'OFF'
       HTTP_ONLY: 'OFF'
-      TFLAGS: 'skiprun'
       EXAMPLES: 'ON'
-    - job_name: 'CMake, VS2022, Debug, x64, Schannel, Static, Unicode, Build-only'
+    - job_name: 'CMake, VS2022, Debug, x64, Schannel, Static, Unicode, Build-tests'
       APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022'
       BUILD_SYSTEM: CMake
       PRJ_GEN: 'Visual Studio 17 2022'
@@ -105,7 +102,7 @@ environment:
       SCHANNEL: 'ON'
       ENABLE_UNICODE: 'ON'
       HTTP_ONLY: 'OFF'
-    - job_name: 'CMake, VS2022, Release, x64, Schannel, Shared, Unicode, DEBUGBULID, no-CURLDEBUG, Build-only'
+    - job_name: 'CMake, VS2022, Release, x64, Schannel, Shared, Unicode, DEBUGBULID, no-CURLDEBUG, Build-tests'
       APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022'
       BUILD_SYSTEM: CMake
       PRJ_GEN: 'Visual Studio 17 2022'
@@ -116,7 +113,7 @@ environment:
       HTTP_ONLY: 'OFF'
       SHARED: 'ON'
       CURLDEBUG: 'OFF'
-    - job_name: 'CMake, VS2022, Debug, x64, no SSL, Static, Build-only'
+    - job_name: 'CMake, VS2022, Debug, x64, no SSL, Static, Build-tests'
       APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022'
       BUILD_SYSTEM: CMake
       PRJ_GEN: 'Visual Studio 17 2022'
@@ -125,7 +122,7 @@ environment:
       SCHANNEL: 'OFF'
       ENABLE_UNICODE: 'OFF'
       HTTP_ONLY: 'OFF'
-    - job_name: 'CMake, VS2022, Debug, x64, no SSL, Static, HTTP only, Build-only'
+    - job_name: 'CMake, VS2022, Debug, x64, no SSL, Static, HTTP only, Build-tests'
       APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022'
       BUILD_SYSTEM: CMake
       PRJ_GEN: 'Visual Studio 17 2022'
index f8b0e9751d55069a43a546a409ee0eee6783beaa..bf265b62a8ed16ec01e053bbdb26a8a2f4aa499a 100644 (file)
@@ -629,6 +629,29 @@ AS_HELP_STRING([--disable-unity],[Disable unity (default)]),
 
 AM_CONDITIONAL([USE_UNITY], [test "$want_unity" = 'yes'])
 
+dnl -----------------------
+dnl whether to bundle tests
+dnl -----------------------
+
+want_test_bundles='no'
+AC_MSG_CHECKING([whether to build tests into single-binary bundles])
+AC_ARG_ENABLE(test-bundles,
+AS_HELP_STRING([--enable-test-bundles],[Enable test bundles])
+AS_HELP_STRING([--disable-test-bundles],[Disable test bundles (default)]),
+[ case "$enableval" in
+  yes)
+    want_test_bundles='yes'
+    AC_MSG_RESULT([yes])
+    ;;
+  *)
+    AC_MSG_RESULT([no])
+    ;;
+  esac ],
+    AC_MSG_RESULT([no])
+)
+
+AM_CONDITIONAL([USE_TEST_BUNDLES], [test "$want_test_bundles" = 'yes'])
+
 dnl ************************************************************
 dnl switch off particular protocols
 dnl
index 3a9e8e76ac271956299dc9dbf0e09ef9b8e2737d..22226b4a41e28de422a7e17903983d4c2cec3c50 100644 (file)
@@ -21,6 +21,8 @@
 # SPDX-License-Identifier: curl
 #
 ###########################################################################
+option(CURL_TEST_BUNDLES "Bundle libtests/unittests into single binaries" OFF)
+
 find_program(TEST_NGHTTPX "nghttpx")
 if(NOT TEST_NGHTTPX)
   set(TEST_NGHTTPX "nghttpx")
@@ -38,6 +40,9 @@ add_subdirectory(unit)
 add_subdirectory(certs EXCLUDE_FROM_ALL)
 
 function(add_runtests _targetname _test_flags)
+  if(CURL_TEST_BUNDLES)
+    set(_test_flags "${_test_flags} -bundle")
+  endif()
   # Use a special '$TFLAGS' placeholder as last argument which will be
   # replaced by the contents of the environment variable in runtests.pl.
   # This is a workaround for CMake's limitation where commands executed by
index d3d5e804d41e6c705fd92f34ac50fa942c2c59fc..250ad3cabb419068323880a02242cae8cc1eb4e4 100644 (file)
@@ -71,6 +71,8 @@ EXTRA_DIST =        \
  http2-server.pl    \
  http3-server.pl    \
  memanalyze.pl      \
+ mk-bundle-hints.sh \
+ mk-bundle.pl       \
  negtelnetserver.py \
  nghttpx.conf       \
  pathhelp.pm        \
@@ -116,10 +118,16 @@ CLEANFILES = .http.pid .https.pid .ftp.pid .ftps.pid $(MANDISTPAGES)
 curl:
        @cd $(top_builddir) && $(MAKE)
 
+TEST_COMMON =
+
 if CROSSCOMPILING
 TEST = @echo "NOTICE: we can't run the tests when cross-compiling!"
 else # if not cross-compiling:
-TEST = srcdir=$(srcdir) $(PERL) $(PERLFLAGS) $(srcdir)/runtests.pl
+if USE_TEST_BUNDLES
+TEST_COMMON += -bundle
+endif
+
+TEST = srcdir=$(srcdir) $(PERL) $(PERLFLAGS) $(srcdir)/runtests.pl $(TEST_COMMON)
 TEST_Q = -a -s
 TEST_AM = -a -am
 TEST_F = -a -p -r
index ca78f5dbec7d0977ab4c411c5fa11d553b528182..e1f17df436cb4ca573f6fcf654b9db7bed6d5e2b 100644 (file)
@@ -65,6 +65,7 @@ BEGIN {
         %feature
         %keywords
         @protocols
+        $bundle
     );
 }
 use pathhelp qw(exe_ext);
@@ -102,6 +103,7 @@ our $VCURL=$CURL;  # what curl binary to use to verify the servers with
 # the path to the script that analyzes the memory debug output file
 our $memanalyze="$perl $srcdir/memanalyze.pl";
 our $valgrind;     # path to valgrind, or empty if disabled
+our $bundle = 0;   # use bundled server, libtest, unit binaries
 
 # paths in $LOGDIR
 our $LOCKDIR = "lock";          # root of the server directory with lock files
index 2b4dc1a362a345cfdc5473ff50bb62982febd75f..9fd1a098c7bcea72bc92eaca844af9316a825954 100644 (file)
@@ -5,6 +5,7 @@
 lib[1234][0-9][0-9][0-9]
 lib[56][0-9][0-9]
 lib1521.c
+libtests.c
 libauthretry
 libntlmconnect
 libprereq
index d11316ba691229b36bc113c50ee473b1d18defd2..2e0b848ee6dc29ccd8f0238d06f5d89ecad4f58a 100644 (file)
 #
 ###########################################################################
 
-# Get 'noinst_PROGRAMS', '*_SOURCES', WARNLESS, MULTIBYTE, TIMEDIFF variables
+# Get 'LIBTESTPROGS', '*_SOURCES', 'TESTUTIL', 'TSTTRACE', 'WARNLESS', 'MULTIBYTE', 'TIMEDIFF', 'THREADS', 'FIRSTFILES' variables
 transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
 include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
 
 set_source_files_properties("../../lib/curl_multibyte.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
 
-foreach(_target IN LISTS noinst_PROGRAMS)
+add_custom_command(
+  OUTPUT "lib1521.c"
+  COMMAND ${PERL_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl" < "${CURL_SOURCE_DIR}/include/curl/curl.h" > "lib1521.c"
+  DEPENDS
+    "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl"
+    "${CURL_SOURCE_DIR}/include/curl/curl.h"
+  VERBATIM)
+
+if(CURL_TEST_BUNDLES)
+  add_custom_command(
+    OUTPUT "libtest_bundle.c"
+    COMMAND ${PERL_EXECUTABLE} "${CURL_SOURCE_DIR}/tests/mk-bundle.pl" "${CMAKE_CURRENT_SOURCE_DIR}" > "libtest_bundle.c"
+    DEPENDS
+      "${CURL_SOURCE_DIR}/tests/mk-bundle.pl" ${FIRSTFILES} "lib1521.c"
+      "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc"
+    VERBATIM)
+
+  set(LIBTESTPROGS "libtests")
+  set(libtests_SOURCES "libtest_bundle.c")
+  list(APPEND libtests_SOURCES ${TESTUTIL} ${TSTTRACE})
+  if(LIB_SELECTED STREQUAL LIB_SHARED)
+    # These are part of the libcurl static lib. Add them here when linking shared.
+    list(APPEND libtests_SOURCES ${WARNLESS} ${MULTIBYTE} ${TIMEDIFF} ${THREADS})
+  endif()
+endif()
+
+foreach(_target IN LISTS LIBTESTPROGS)
   if(DEFINED ${_target}_SOURCES)
     set(_sources ${${_target}_SOURCES})
   else()
@@ -50,16 +76,11 @@ foreach(_target IN LISTS noinst_PROGRAMS)
     "${CURL_SOURCE_DIR}/lib"            # for "curl_setup.h"
     "${CURL_SOURCE_DIR}/tests/libtest"  # to be able to build generated tests
   )
+  if(NOT CURL_TEST_BUNDLES)
+    set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS ${_upper_target})
+  endif()
+  set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_NO_GETADDRINFO_OVERRIDE")
   set_target_properties(${_target_name} PROPERTIES
-    COMPILE_DEFINITIONS ${_upper_target}
     OUTPUT_NAME "${_target}"
     PROJECT_LABEL "Test libtest ${_target}")
 endforeach()
-
-add_custom_command(
-  OUTPUT "lib1521.c"
-  COMMAND ${PERL_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl" < "${CURL_SOURCE_DIR}/include/curl/curl.h" > "lib1521.c"
-  DEPENDS
-    "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl"
-    "${CURL_SOURCE_DIR}/include/curl/curl.h"
-  VERBATIM)
index 2e360cad443f8f3676c4e36b91998faeed186539..6358ec1bea7a8f873b3786a37754f687d7d3a976 100644 (file)
@@ -34,7 +34,8 @@ AUTOMAKE_OPTIONS = foreign nostdinc
 
 AM_CPPFLAGS = -I$(top_srcdir)/include        \
               -I$(top_builddir)/lib          \
-              -I$(top_srcdir)/lib
+              -I$(top_srcdir)/lib            \
+              -I$(top_srcdir)/tests/libtest
 
 EXTRA_DIST = test307.pl test610.pl test613.pl test1013.pl test1022.pl   \
   notexists.pl CMakeLists.txt mk-lib1521.pl .checksrc
@@ -55,7 +56,7 @@ TESTUTIL_LIBS = $(top_builddir)/lib/libcurl.la @LIBCURL_PC_LIBS_PRIVATE@
 LDADD = $(SUPPORTFILES_LIBS)
 
 # Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES,
-# noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS)
+# LIBTESTPROGS, lib*_SOURCES, and lib*_CFLAGS)
 include Makefile.inc
 
 noinst_LTLIBRARIES =
@@ -87,6 +88,26 @@ libstubgss_la_LIBADD =
 libstubgss_la_DEPENDENCIES =
 endif
 
+if USE_TEST_BUNDLES
+AM_CPPFLAGS += -DCURL_NO_GETADDRINFO_OVERRIDE
+
+libtest_bundle.c: $(top_srcdir)/tests/mk-bundle.pl lib1521.c
+       @PERL@ $(top_srcdir)/tests/mk-bundle.pl $(srcdir) > libtest_bundle.c
+
+noinst_PROGRAMS = libtests
+nodist_libtests_SOURCES = libtest_bundle.c
+libtests_SOURCES = $(TESTUTIL) $(TSTTRACE)
+libtests_LDADD = $(TESTUTIL_LIBS)
+CLEANFILES += libtest_bundle.c
+
+if USE_CPPFLAG_CURL_STATICLIB
+else
+# These are part of the libcurl static lib. Add them here when linking shared.
+libtests_SOURCES += $(WARNLESS) $(MULTIBYTE) $(TIMEDIFF) $(THREADS)
+endif
+else
+noinst_PROGRAMS = $(LIBTESTPROGS)
+endif
 
 lib1521.c: $(top_srcdir)/tests/libtest/mk-lib1521.pl $(top_srcdir)/include/curl/curl.h
        @PERL@ $(top_srcdir)/tests/libtest/mk-lib1521.pl < $(top_srcdir)/include/curl/curl.h > lib1521.c
index 492548658a57fb15d7b69162e0cb8dd3f7bedd82..948d9f76d551744bf0f783fcb1f04d5fb6d318a5 100644 (file)
@@ -35,12 +35,13 @@ MULTIBYTE = ../../lib/curl_multibyte.c ../../lib/curl_multibyte.h
 
 # these files are used in every single test program below
 TIMEDIFF = ../../lib/timediff.c ../../lib/timediff.h
-SUPPORTFILES = $(TIMEDIFF) first.c test.h
+FIRSTFILES = first.c first.h
+SUPPORTFILES = $(TIMEDIFF) $(FIRSTFILES) test.h
 
 THREADS = ../../lib/curl_threads.c ../../lib/curl_threads.h
 
 # These are all libcurl test programs
-noinst_PROGRAMS = libauthretry libntlmconnect libprereq                  \
+LIBTESTPROGS = libauthretry libntlmconnect libprereq                     \
  lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 lib508 lib509   \
  lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 lib518 lib519   \
  lib520 lib521 lib523 lib524 lib525 lib526 lib527 lib529 lib530 lib532   \
index 0e98ac87cb7d908ca94119c7768e555f8a95c1a3..68c649e08bd237148bf9db49ad904279ac98795e 100644 (file)
@@ -22,6 +22,7 @@
  *
  ***************************************************************************/
 #include "test.h"
+#include "first.h"
 
 #ifdef HAVE_LOCALE_H
 #  include <locale.h> /* for setlocale() */
@@ -137,6 +138,8 @@ int main(int argc, char **argv)
 {
   char *URL;
   CURLcode result;
+  int basearg;
+  test_func_t test_func;
 
 #ifdef O_BINARY
 #  ifdef __HIGHC__
@@ -157,25 +160,64 @@ int main(int argc, char **argv)
   setlocale(LC_ALL, "");
 #endif
 
-  if(argc < 2) {
+  test_argc = argc;
+  test_argv = argv;
+
+#ifdef CURLTESTS_BUNDLED
+  {
+    char *test_name;
+
+    --test_argc;
+    ++test_argv;
+
+    basearg = 2;
+
+    if(argc < (basearg + 1)) {
+      fprintf(stderr, "Pass testname and URL as arguments please\n");
+      return 1;
+    }
+
+    test_name = argv[basearg - 1];
+    test_func = NULL;
+    {
+      size_t tmp;
+      for(tmp = 0; tmp < (sizeof(s_tests)/sizeof((s_tests)[0])); ++tmp) {
+        if(strcmp(test_name, s_tests[tmp].name) == 0) {
+          test_func = s_tests[tmp].ptr;
+          break;
+        }
+      }
+    }
+
+    if(!test_func) {
+      fprintf(stderr, "Test '%s' not found.\n", test_name);
+      return 1;
+    }
+
+    fprintf(stderr, "Test: %s\n", test_name);
+  }
+#else
+  basearg = 1;
+
+  if(argc < (basearg + 1)) {
     fprintf(stderr, "Pass URL as argument please\n");
     return 1;
   }
 
-  test_argc = argc;
-  test_argv = argv;
+  test_func = test;
+#endif
 
-  if(argc > 2)
-    libtest_arg2 = argv[2];
+  if(argc > (basearg + 1))
+    libtest_arg2 = argv[basearg + 1];
 
-  if(argc > 3)
-    libtest_arg3 = argv[3];
+  if(argc > (basearg + 2))
+    libtest_arg3 = argv[basearg + 2];
 
-  URL = argv[1]; /* provide this to the rest */
+  URL = argv[basearg]; /* provide this to the rest */
 
   fprintf(stderr, "URL: %s\n", URL);
 
-  result = test(URL);
+  result = test_func(URL);
   fprintf(stderr, "Test ended with result %d\n", result);
 
 #ifdef _WIN32
diff --git a/tests/libtest/first.h b/tests/libtest/first.h
new file mode 100644 (file)
index 0000000..1e4ae5f
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef HEADER_LIBTEST_FIRST_H
+#define HEADER_LIBTEST_FIRST_H
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+#include "curl_setup.h"
+#include <curl/curl.h>
+
+typedef CURLcode (*test_func_t)(char *);
+
+#ifdef CURLTESTS_BUNDLED
+struct onetest {
+  const char *name;
+  test_func_t ptr;
+};
+#endif
+
+#endif /* HEADER_LIBTEST_FIRST_H */
index f514b4e41002b83e288ddb3010300f2d32b95afd..8959db76388073f0deb159e7e711cc10456de7f9 100644 (file)
@@ -47,7 +47,7 @@ struct testparams {
   CURLcode result; /* Code that should be returned by curl_easy_perform(). */
 };
 
-static const struct testparams params[] = {
+static const struct testparams testparams[] = {
   { 0,                                                             CURLE_OK },
   {                                 F_CONTENTRANGE,                CURLE_OK },
   {                        F_FAIL,                                 CURLE_OK },
@@ -143,7 +143,7 @@ CURLcode test(char *URL)
     return TEST_ERR_MAJOR_BAD;
   }
 
-  for(i = 0; i < sizeof(params) / sizeof(params[0]); i++) {
+  for(i = 0; i < sizeof(testparams) / sizeof(testparams[0]); i++) {
     curl = curl_easy_init();
     if(!curl) {
       fprintf(stderr, "curl_easy_init() failed\n");
@@ -156,7 +156,7 @@ CURLcode test(char *URL)
 #ifdef SINGLETEST
     if(SINGLETEST == i)
 #endif
-      status |= onetest(curl, URL, params + i, i);
+      status |= onetest(curl, URL, testparams + i, i);
     curl_easy_cleanup(curl);
   }
 
index 496fffc8bd776ab930822e1745aed986c9668c51..6b4e18bac0f7a2aa63539e285623532ec0e0627b 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "memdebug.h"
 
-static char data[]="dummy";
+static char testdata[]="dummy";
 
 struct WriteThis {
   char *readptr;
@@ -59,7 +59,7 @@ CURLcode test(char *URL)
   CURL *curl;
   CURLcode result = CURLE_OK;
   CURLcode res = CURLE_OK;
-  struct WriteThis pooh = { data, sizeof(data)-1 };
+  struct WriteThis pooh = { testdata, sizeof(testdata)-1 };
 
   global_init(CURL_GLOBAL_ALL);
 
index 94ebc49d229095a7c6779cd92469f352c17a5509..3957eb19904ddc446bcd50a5aa0537c841518411 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static char data[]="this is what we post to the silly web server\n";
+static char testdata[]="this is what we post to the silly web server\n";
 
 struct WriteThis {
   char *readptr;
@@ -70,8 +70,8 @@ CURLcode test(char *URL)
 #endif
   }
 
-  pooh.readptr = data;
-  pooh.sizeleft = strlen(data);
+  pooh.readptr = testdata;
+  pooh.sizeleft = strlen(testdata);
 
   if(curl_global_init(CURL_GLOBAL_ALL)) {
     fprintf(stderr, "curl_global_init() failed\n");
index d6c24fcce91fe1927dc49d501a8abac1254b223a..c8a3063f362f7493e9dea1378e9b16b0a310dde3 100644 (file)
 
 #include "memdebug.h"
 
-static char data [] = "Hello Cloud!\n";
+static char testdata[] = "Hello Cloud!\n";
 
 static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
 {
   size_t  amount = nmemb * size; /* Total bytes curl wants */
-  if(amount < strlen(data)) {
-    return strlen(data);
+  if(amount < strlen(testdata)) {
+    return strlen(testdata);
   }
   (void)stream;
-  memcpy(ptr, data, strlen(data));
-  return strlen(data);
+  memcpy(ptr, testdata, strlen(testdata));
+  return strlen(testdata);
 }
 
 
@@ -84,7 +84,7 @@ CURLcode test(char *URL)
   test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
   test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
   test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
-  test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(data));
+  test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(testdata));
 
   res = curl_easy_perform(curl);
 
index 344028c1102b9bab12e5c73b3cd6c6dbe384b94a..8093079f553ac898b39f16c3b7b1d6ddb2ede861 100644 (file)
 
 #include "memdebug.h"
 
-static char data [] = "Hello Cloud!\n";
+static char testdata[] = "Hello Cloud!\n";
 
 static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
 {
   size_t  amount = nmemb * size; /* Total bytes curl wants */
-  if(amount < strlen(data)) {
-    return strlen(data);
+  if(amount < strlen(testdata)) {
+    return strlen(testdata);
   }
   (void)stream;
-  memcpy(ptr, data, strlen(data));
-  return strlen(data);
+  memcpy(ptr, testdata, strlen(testdata));
+  return strlen(testdata);
 }
 
 CURLcode test(char *URL)
@@ -87,7 +87,7 @@ CURLcode test(char *URL)
   test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
   test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
   test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
-  test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(data));
+  test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(testdata));
 
   res = curl_easy_perform(curl);
 
index 931f2555a65c8b57ef1a1f66dfeb25ff07e6352b..26581b2a3e364240499c3695190332bc2bcf1fd5 100644 (file)
 
 #include "memdebug.h"
 
-static char data [] = "Hello Cloud!\n";
+static char testdata[] = "Hello Cloud!\n";
 
 static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
 {
   size_t  amount = nmemb * size; /* Total bytes curl wants */
-  if(amount < strlen(data)) {
-    return strlen(data);
+  if(amount < strlen(testdata)) {
+    return strlen(testdata);
   }
   (void)stream;
-  memcpy(ptr, data, strlen(data));
-  return strlen(data);
+  memcpy(ptr, testdata, strlen(testdata));
+  return strlen(testdata);
 }
 
 
@@ -85,7 +85,7 @@ CURLcode test(char *URL)
   test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
   test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
   test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
-  test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(data));
+  test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(testdata));
   test_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_UNIFIED);
 
   res = curl_easy_perform(curl);
index a8439b08e230fbb4e14f486b93768bf0446effab..3c48f3fe0851f0f0faafa1740ad58806a97aa161 100644 (file)
@@ -36,8 +36,8 @@ static const char *ldata_names[] = {
   "NULL",
 };
 
-static void my_lock(CURL *handle, curl_lock_data data,
-                    curl_lock_access laccess, void *useptr)
+static void test_lock(CURL *handle, curl_lock_data data,
+                      curl_lock_access laccess, void *useptr)
 {
   (void)handle;
   (void)data;
@@ -46,7 +46,7 @@ static void my_lock(CURL *handle, curl_lock_data data,
   printf("-> Mutex lock %s\n", ldata_names[data]);
 }
 
-static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
+static void test_unlock(CURL *handle, curl_lock_data data, void *useptr)
 {
   (void)handle;
   (void)data;
@@ -70,8 +70,8 @@ CURLcode test(char *URL)
   }
 
   curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
-  curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock);
-  curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock);
+  curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock);
+  curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock);
 
   /* Loop the transfer and cleanup the handle properly every lap. This will
      still reuse connections since the pool is in the shared object! */
index 7f833868ad6bba2f3212b2f60952b3b405ee9ff2..b6b8ecf12df02ee8f739d88fad64bba15a0eea7c 100644 (file)
@@ -40,7 +40,7 @@ static CURL *pending_handles[CONN_NUM];
 static int pending_num = 0;
 static CURLcode test_failure = CURLE_OK;
 
-static CURLM *multi = NULL;
+static CURLM *testmulti = NULL;
 static const char *url;
 
 static void *run_thread(void *ptr)
@@ -72,7 +72,7 @@ static void *run_thread(void *ptr)
 
     pthread_mutex_unlock(&lock);
 
-    res_multi_wakeup(multi);
+    res_multi_wakeup(testmulti);
   }
 
 test_cleanup:
@@ -107,7 +107,7 @@ CURLcode test(char *URL)
 
   global_init(CURL_GLOBAL_ALL);
 
-  multi_init(multi);
+  multi_init(testmulti);
 
   url = URL;
 
@@ -121,16 +121,16 @@ CURLcode test(char *URL)
   }
 
   while(1) {
-    multi_perform(multi, &still_running);
+    multi_perform(testmulti, &still_running);
 
     abort_on_test_timeout();
 
-    while((message = curl_multi_info_read(multi, &num))) {
+    while((message = curl_multi_info_read(testmulti, &num))) {
       if(message->msg == CURLMSG_DONE) {
         res = message->data.result;
         if(res)
           goto test_cleanup;
-        multi_remove_handle(multi, message->easy_handle);
+        multi_remove_handle(testmulti, message->easy_handle);
         finished_num++;
       }
       else {
@@ -146,14 +146,14 @@ CURLcode test(char *URL)
     if(CONN_NUM == finished_num)
       break;
 
-    multi_poll(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
+    multi_poll(testmulti, NULL, 0, TEST_HANG_TIMEOUT, &num);
 
     abort_on_test_timeout();
 
     pthread_mutex_lock(&lock);
 
     while(pending_num > 0) {
-      res_multi_add_handle(multi, pending_handles[pending_num - 1]);
+      res_multi_add_handle(testmulti, pending_handles[pending_num - 1]);
       if(res) {
         pthread_mutex_unlock(&lock);
         goto test_cleanup;
@@ -191,7 +191,7 @@ test_cleanup:
   if(tid_valid)
     pthread_join(tid, NULL);
 
-  curl_multi_cleanup(multi);
+  curl_multi_cleanup(testmulti);
   for(i = 0; i < pending_num; i++)
     curl_easy_cleanup(pending_handles[i]);
   for(i = 0; i < started_num; i++)
index 0a361ada16b692fa04b6713a33167a9248832ec5..c0200d5429b2f73403742c47ecdfdbb2d9d78358 100644 (file)
 #include <stdio.h>
 #include "memdebug.h"
 
-static char data [] = "Hello Cloud!\r\n";
+static char testdata[] = "Hello Cloud!\r\n";
 static size_t consumed = 0;
 
 static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
 {
   size_t  amount = nmemb * size; /* Total bytes curl wants */
 
-  if(consumed == strlen(data)) {
+  if(consumed == strlen(testdata)) {
     return 0;
   }
 
-  if(amount > strlen(data)-consumed) {
-    amount = strlen(data);
+  if(amount > strlen(testdata)-consumed) {
+    amount = strlen(testdata);
   }
 
   consumed += amount;
   (void)stream;
-  memcpy(ptr, data, amount);
+  memcpy(ptr, testdata, amount);
   return amount;
 }
 
index 91c02fce0541771b356343d9ca852aee93a2cc58..1e9e2b061754abe294c9769206c95f0e9c655148 100644 (file)
@@ -23,7 +23,7 @@
  ***************************************************************************/
 #include "test.h"
 
-static char data[]="mooaaa";
+static char testdata[]="mooaaa";
 
 struct WriteThis {
   size_t sizeleft;
@@ -32,13 +32,13 @@ struct WriteThis {
 static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
 {
   struct WriteThis *pooh = (struct WriteThis *)userp;
-  size_t len = strlen(data);
+  size_t len = strlen(testdata);
 
   if(size*nmemb < len)
     return 0;
 
   if(pooh->sizeleft) {
-    memcpy(ptr, data, strlen(data));
+    memcpy(ptr, testdata, strlen(testdata));
     pooh->sizeleft = 0;
     return len;
   }
index 625ec262a7511259c9a4e9c09800a4e44aef70c2..0fd62a8b92ae83b1205303078968ddff8bab9adc 100644 (file)
@@ -31,7 +31,7 @@
    define not publicly exposed so we set our own */
 #define MAX_INPUT_LENGTH 8000000
 
-static char buffer[MAX_INPUT_LENGTH + 2];
+static char testbuf[MAX_INPUT_LENGTH + 2];
 
 CURLcode test(char *URL)
 {
@@ -48,10 +48,10 @@ CURLcode test(char *URL)
   }
 
   /* make it a null-terminated C string with just As */
-  memset(buffer, 'A', MAX_INPUT_LENGTH + 1);
-  buffer[MAX_INPUT_LENGTH + 1] = 0;
+  memset(testbuf, 'A', MAX_INPUT_LENGTH + 1);
+  testbuf[MAX_INPUT_LENGTH + 1] = 0;
 
-  printf("string length: %d\n", (int)strlen(buffer));
+  printf("string length: %d\n", (int)strlen(testbuf));
 
   for(o = curl_easy_option_next(NULL);
       o;
@@ -76,7 +76,7 @@ CURLcode test(char *URL)
 
       /* This is a string. Make sure that passing in a string longer
          CURL_MAX_INPUT_LENGTH returns an error */
-      result = curl_easy_setopt(easy, o->id, buffer);
+      result = curl_easy_setopt(easy, o->id, testbuf);
       switch(result) {
       case CURLE_BAD_FUNCTION_ARGUMENT: /* the most normal */
       case CURLE_UNKNOWN_OPTION: /* left out from the build */
index 7ee523f1506b41f8230f83f9d12e91b61f61aa0d..e8dbcdd13f95d65dc295f06297615ba3594d2aaf 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "memdebug.h"
 
-static const char *show[]={
+static const char *testdata[]={
   "daTE",
   "Server",
   "content-type",
@@ -50,9 +50,9 @@ static void showem(CURL *easy, unsigned int type)
 {
   int i;
   struct curl_header *header;
-  for(i = 0; show[i]; i++) {
-    if(CURLHE_OK == curl_easy_header(easy, show[i], 0, type, HEADER_REQUEST,
-                                     &header)) {
+  for(i = 0; testdata[i]; i++) {
+    if(CURLHE_OK == curl_easy_header(easy, testdata[i], 0, type,
+                                     HEADER_REQUEST, &header)) {
       if(header->amount > 1) {
         /* more than one, iterate over them */
         size_t index = 0;
@@ -63,7 +63,7 @@ static void showem(CURL *easy, unsigned int type)
 
           if(++index == amount)
             break;
-          if(CURLHE_OK != curl_easy_header(easy, show[i], index, type,
+          if(CURLHE_OK != curl_easy_header(easy, testdata[i], index, type,
                                            HEADER_REQUEST, &header))
             break;
         } while(1);
index cd31207703db9e3742762ee4399d27aa7d2cebc9..bfac8305f31542a164822852c72afaa0da07b52a 100644 (file)
@@ -27,7 +27,7 @@
 #ifdef USE_WEBSOCKETS
 #if 0
 
-static CURLcode ping(CURL *curl, const char *send_payload)
+static CURLcode send_ping(CURL *curl, const char *send_payload)
 {
   size_t sent;
   CURLcode result =
@@ -80,7 +80,7 @@ static void websocket(CURL *curl)
   int i = 0;
   fprintf(stderr, "ws: websocket() starts\n");
   do {
-    if(ping(curl, "foobar"))
+    if(send_ping(curl, "foobar"))
       return;
     if(recv_pong(curl, "foobar"))
       return;
index 57329c4c7594925dfd7a7d6cd1d5ab2e2f9b30ef..0052bfdba815bea93af0704a7271b9140c870bf6 100644 (file)
@@ -26,7 +26,7 @@
 
 #ifdef USE_WEBSOCKETS
 
-static CURLcode ping(CURL *curl, const char *send_payload)
+static CURLcode send_ping(CURL *curl, const char *send_payload)
 {
   size_t sent;
   CURLcode result =
@@ -98,7 +98,7 @@ static void websocket(CURL *curl)
   do {
     recv_any(curl);
     fprintf(stderr, "Send ping\n");
-    if(ping(curl, "foobar"))
+    if(send_ping(curl, "foobar"))
       return;
     fprintf(stderr, "Receive pong\n");
     if(recv_pong(curl, "foobar")) {
index 5ccb9bfa6125f0840589672ac67d263a65aea476..2ec9c3e7f298c729d6149263e8aba4a1d9bc4cb2 100644 (file)
@@ -55,6 +55,7 @@ static void websocket(CURL *curl)
       if(result == CURLE_AGAIN)
         /* crude busy-loop */
         continue;
+      fclose(save);
       printf("curl_ws_recv returned %d\n", result);
       return;
     }
index f43f7d5b1054e42c265b405f605608acb1c74fe1..6c819b3596f2f7d63a52dcd2abf19cf1ea336772 100644 (file)
@@ -38,8 +38,7 @@
 #define THREAD_SIZE 16
 #define PER_THREAD_SIZE 8
 
-struct Ctx
-{
+struct Ctx {
   const char *URL;
   CURLSH *share;
   int result;
@@ -126,8 +125,8 @@ test_cleanup:
 
 #if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
 
-static void my_lock(CURL *handle, curl_lock_data data,
-                    curl_lock_access laccess, void *useptr)
+static void test_lock(CURL *handle, curl_lock_data data,
+                      curl_lock_access laccess, void *useptr)
 {
   curl_mutex_t *mutexes = (curl_mutex_t*) useptr;
   (void)handle;
@@ -135,14 +134,14 @@ static void my_lock(CURL *handle, curl_lock_data data,
   Curl_mutex_acquire(&mutexes[data]);
 }
 
-static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
+static void test_unlock(CURL *handle, curl_lock_data data, void *useptr)
 {
   curl_mutex_t *mutexes = (curl_mutex_t*) useptr;
   (void)handle;
   Curl_mutex_release(&mutexes[data]);
 }
 
-static void execute(struct Curl_share *share, struct Ctx *ctx)
+static void execute(CURLSH *share, struct Ctx *ctx)
 {
   int i;
   curl_mutex_t mutexes[CURL_LOCK_DATA_LAST - 1];
@@ -150,8 +149,8 @@ static void execute(struct Curl_share *share, struct Ctx *ctx)
   for(i = 0; i < CURL_LOCK_DATA_LAST - 1; i++) {
     Curl_mutex_init(&mutexes[i]);
   }
-  curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock);
-  curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock);
+  curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock);
+  curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock);
   curl_share_setopt(share, CURLSHOPT_USERDATA, (void *)mutexes);
   curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
 
@@ -173,7 +172,7 @@ static void execute(struct Curl_share *share, struct Ctx *ctx)
 
 #else /* without pthread, run serially */
 
-static void execute(struct Curl_share *share, struct Ctx *ctx)
+static void execute(CURLSH *share, struct Ctx *ctx)
 {
   int i;
   (void) share;
index 8b27aef04abb9e9c62b2407112d09640d6dcbd4f..9aa3466698fa4cd8544970832d1879bad91fe3a5 100644 (file)
@@ -28,7 +28,7 @@
 
 #ifdef LIB585
 
-static int counter;
+static int testcounter;
 
 static curl_socket_t tst_opensocket(void *clientp,
                                     curlsocktype purpose,
@@ -36,14 +36,14 @@ static curl_socket_t tst_opensocket(void *clientp,
 {
   (void)clientp;
   (void)purpose;
-  printf("[OPEN] counter: %d\n", ++counter);
+  printf("[OPEN] counter: %d\n", ++testcounter);
   return socket(addr->family, addr->socktype, addr->protocol);
 }
 
 static int tst_closesocket(void *clientp, curl_socket_t sock)
 {
   (void)clientp;
-  printf("[CLOSE] counter: %d\n", counter--);
+  printf("[CLOSE] counter: %d\n", testcounter--);
   return sclose(sock);
 }
 
@@ -51,7 +51,7 @@ static void setupcallbacks(CURL *curl)
 {
   curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, tst_opensocket);
   curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, tst_closesocket);
-  counter = 0;
+  testcounter = 0;
 }
 
 #else
@@ -174,3 +174,5 @@ test_cleanup:
 
   return res;
 }
+
+#undef setupcallbacks
index 9a5e5a2c1e0968e0dc7e04e13bf3841c622bafbc..03eb11ddda210250f99de1590a3d9c7d06305c31 100644 (file)
@@ -42,8 +42,8 @@ struct userdata {
 static int locks[3];
 
 /* lock callback */
-static void my_lock(CURL *handle, curl_lock_data data,
-                    curl_lock_access laccess, void *useptr)
+static void test_lock(CURL *handle, curl_lock_data data,
+                      curl_lock_access laccess, void *useptr)
 {
   const char *what;
   struct userdata *user = (struct userdata *)useptr;
@@ -82,7 +82,7 @@ static void my_lock(CURL *handle, curl_lock_data data,
 }
 
 /* unlock callback */
-static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
+static void test_unlock(CURL *handle, curl_lock_data data, void *useptr)
 {
   const char *what;
   struct userdata *user = (struct userdata *)useptr;
@@ -127,7 +127,7 @@ static struct curl_slist *sethost(struct curl_slist *headers)
 
 
 /* the dummy thread function */
-static void *fire(void *ptr)
+static void *test_fire(void *ptr)
 {
   CURLcode code;
   struct curl_slist *headers;
@@ -207,11 +207,11 @@ CURLcode test(char *URL)
 
   if(CURLSHE_OK == scode) {
     printf("CURLSHOPT_LOCKFUNC\n");
-    scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock);
+    scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock);
   }
   if(CURLSHE_OK == scode) {
     printf("CURLSHOPT_UNLOCKFUNC\n");
-    scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock);
+    scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock);
   }
   if(CURLSHE_OK == scode) {
     printf("CURLSHOPT_USERDATA\n");
@@ -272,7 +272,7 @@ CURLcode test(char *URL)
 
     /* simulate thread, direct call of "thread" function */
     printf("*** run %d\n",i);
-    fire(&tdata);
+    test_fire(&tdata);
 
     curl_free(tdata.url);
   }
index 00bb881d76385c9ed409b1a408cef69703ab83a3..fc25a0df60f9db5132ec4872497f826c4046ff43 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static char data[]="this is what we post to the silly web server\n";
+static char testdata[]="this is what we post to the silly web server\n";
 
 struct WriteThis {
   char *readptr;
@@ -56,8 +56,8 @@ CURLcode test(char *URL)
 
   struct WriteThis pooh;
 
-  pooh.readptr = data;
-  pooh.sizeleft = strlen(data);
+  pooh.readptr = testdata;
+  pooh.sizeleft = strlen(testdata);
 
   if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
     fprintf(stderr, "curl_global_init() failed\n");
index d293112f94ff3c66dbe8fe9063cbfcb489c18445..2abd1cb7ed299778ff87b6ab8e1112b572f9e17e 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static const char *post[]={
+static const char * const testpost[]={
   "one",
   "two",
   "three",
@@ -46,7 +46,7 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
   if(size*nmemb < 1)
     return 0;
 
-  data = post[pooh->counter];
+  data = testpost[pooh->counter];
 
   if(data) {
     size_t len = strlen(data);
index ef70e03d687157e4d1c8c917a15b05a4b04ce64b..4cde4b1e47f1d92550d4e6f0f93001b7ee6f9ab2 100644 (file)
@@ -50,7 +50,7 @@
 
 #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
 
-static int *fd = NULL;
+static int *testfd = NULL;
 static struct rlimit num_open;
 static char msgbuff[256];
 
@@ -68,10 +68,10 @@ static void close_file_descriptors(void)
   for(num_open.rlim_cur = 0;
       num_open.rlim_cur < num_open.rlim_max;
       num_open.rlim_cur++)
-    if(fd[num_open.rlim_cur] > 0)
-      close(fd[num_open.rlim_cur]);
-  free(fd);
-  fd = NULL;
+    if(testfd[num_open.rlim_cur] > 0)
+      close(testfd[num_open.rlim_cur]);
+  free(testfd);
+  testfd = NULL;
 }
 
 static int fopen_works(void)
@@ -120,7 +120,7 @@ static void rlim2str(char *buf, size_t len, rlim_t val)
   }
 }
 
-static int rlimit(int keep_open)
+static int test_rlimit(int keep_open)
 {
   rlim_t nitems, i;
   int *memchunk = NULL;
@@ -239,7 +239,7 @@ static int rlimit(int keep_open)
    * avoid a low memory condition once the file descriptors are
    * open. System conditions that could make the test fail should
    * be addressed in the precheck phase. This chunk of memory shall
-   * be always free()ed before exiting the rlimit() function so
+   * be always free()ed before exiting the test_rlimit() function so
    * that it becomes available to the test.
    */
 
@@ -276,7 +276,7 @@ static int rlimit(int keep_open)
 
   /* verify that we won't overflow size_t in malloc() */
 
-  if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) {
+  if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*testfd)) {
     rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max);
     msnprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s "
               "file descriptors, would overflow size_t", strbuff1);
@@ -291,9 +291,9 @@ static int rlimit(int keep_open)
   rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
   fprintf(stderr, "allocating array for %s file descriptors\n", strbuff);
 
-  fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max));
-  if(!fd) {
-    store_errmsg("fd, malloc() failed", errno);
+  testfd = malloc(sizeof(*testfd) * (size_t)(num_open.rlim_max));
+  if(!testfd) {
+    store_errmsg("testfd, malloc() failed", errno);
     fprintf(stderr, "%s\n", msgbuff);
     free(memchunk);
     return -7;
@@ -301,25 +301,25 @@ static int rlimit(int keep_open)
 
   /* initialize it to fight lazy allocation */
 
-  fprintf(stderr, "initializing fd array\n");
+  fprintf(stderr, "initializing testfd array\n");
 
   for(num_open.rlim_cur = 0;
       num_open.rlim_cur < num_open.rlim_max;
       num_open.rlim_cur++)
-    fd[num_open.rlim_cur] = -1;
+    testfd[num_open.rlim_cur] = -1;
 
   rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
   fprintf(stderr, "trying to open %s file descriptors\n", strbuff);
 
   /* open a dummy descriptor */
 
-  fd[0] = open(DEV_NULL, O_RDONLY);
-  if(fd[0] < 0) {
+  testfd[0] = open(DEV_NULL, O_RDONLY);
+  if(testfd[0] < 0) {
     msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
     store_errmsg(strbuff, errno);
     fprintf(stderr, "%s\n", msgbuff);
-    free(fd);
-    fd = NULL;
+    free(testfd);
+    testfd = NULL;
     free(memchunk);
     return -8;
   }
@@ -330,11 +330,11 @@ static int rlimit(int keep_open)
       num_open.rlim_cur < num_open.rlim_max;
       num_open.rlim_cur++) {
 
-    fd[num_open.rlim_cur] = dup(fd[0]);
+    testfd[num_open.rlim_cur] = dup(testfd[0]);
 
-    if(fd[num_open.rlim_cur] < 0) {
+    if(testfd[num_open.rlim_cur] < 0) {
 
-      fd[num_open.rlim_cur] = -1;
+      testfd[num_open.rlim_cur] = -1;
 
       rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur);
       msnprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1);
@@ -355,11 +355,11 @@ static int rlimit(int keep_open)
       fprintf(stderr, "%s\n", msgbuff);
 
       for(num_open.rlim_cur = 0;
-          fd[num_open.rlim_cur] >= 0;
+          testfd[num_open.rlim_cur] >= 0;
           num_open.rlim_cur++)
-        close(fd[num_open.rlim_cur]);
-      free(fd);
-      fd = NULL;
+        close(testfd[num_open.rlim_cur]);
+      free(testfd);
+      testfd = NULL;
       free(memchunk);
       return -9;
     }
@@ -396,8 +396,8 @@ static int rlimit(int keep_open)
   for(rl.rlim_cur = 0;
       rl.rlim_cur < num_open.rlim_max;
       rl.rlim_cur++) {
-    if((fd[rl.rlim_cur] > 0) &&
-       ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) {
+    if((testfd[rl.rlim_cur] > 0) &&
+       ((unsigned int)testfd[rl.rlim_cur] > num_open.rlim_cur)) {
       msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
                 FD_SETSIZE);
       store_errmsg(strbuff, 0);
@@ -452,14 +452,14 @@ CURLcode test(char *URL)
 
   if(!strcmp(URL, "check")) {
     /* used by the test script to ask if we can run this test or not */
-    if(rlimit(FALSE)) {
-      fprintf(stdout, "rlimit problem: %s\n", msgbuff);
+    if(test_rlimit(FALSE)) {
+      fprintf(stdout, "test_rlimit problem: %s\n", msgbuff);
       return (CURLcode)1;
     }
     return CURLE_OK; /* sure, run this! */
   }
 
-  if(rlimit(TRUE)) {
+  if(test_rlimit(TRUE)) {
     /* failure */
     return TEST_ERR_MAJOR_BAD;
   }
index 36a4c8af00d17434c3dbad384857aa6bca5ae214..5f24c904bc5a2291dd3384bde3d6f47a7e14860b 100644 (file)
 
 #define TEST_HANG_TIMEOUT 60 * 1000
 
-struct Sockets
-{
+struct Sockets {
   curl_socket_t *sockets;
   int count;      /* number of sockets actually stored in array */
   int max_count;  /* max number of sockets that fit in allocated array */
 };
 
-struct ReadWriteSockets
-{
+struct ReadWriteSockets {
   struct Sockets read, write;
 };
 
index 7d454b4e422533563f3ecbf376403fc3a2a8ee68..d05cd16ab11f17d210598d5aff6efe4f79ccbe0d 100644 (file)
@@ -50,7 +50,7 @@
 
 #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
 
-static int *fd = NULL;
+static int *testfd = NULL;
 static struct rlimit num_open;
 static char msgbuff[256];
 
@@ -68,10 +68,10 @@ static void close_file_descriptors(void)
   for(num_open.rlim_cur = 0;
       num_open.rlim_cur < num_open.rlim_max;
       num_open.rlim_cur++)
-    if(fd[num_open.rlim_cur] > 0)
-      close(fd[num_open.rlim_cur]);
-  free(fd);
-  fd = NULL;
+    if(testfd[num_open.rlim_cur] > 0)
+      close(testfd[num_open.rlim_cur]);
+  free(testfd);
+  testfd = NULL;
 }
 
 static int fopen_works(void)
@@ -120,7 +120,7 @@ static void rlim2str(char *buf, size_t len, rlim_t val)
   }
 }
 
-static int rlimit(int keep_open)
+static int test_rlimit(int keep_open)
 {
   int *tmpfd;
   rlim_t nitems, i;
@@ -221,7 +221,7 @@ static int rlimit(int keep_open)
    * avoid a low memory condition once the file descriptors are
    * open. System conditions that could make the test fail should
    * be addressed in the precheck phase. This chunk of memory shall
-   * be always free()ed before exiting the rlimit() function so
+   * be always free()ed before exiting the test_rlimit() function so
    * that it becomes available to the test.
    */
 
@@ -273,7 +273,7 @@ static int rlimit(int keep_open)
 
   /* verify that we won't overflow size_t in malloc() */
 
-  if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) {
+  if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*testfd)) {
     rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max);
     msnprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s "
               "file descriptors, would overflow size_t", strbuff1);
@@ -289,14 +289,14 @@ static int rlimit(int keep_open)
     rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
     fprintf(stderr, "allocating array for %s file descriptors\n", strbuff);
 
-    fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max));
-    if(!fd) {
-      fprintf(stderr, "fd, malloc() failed\n");
+    testfd = malloc(sizeof(*testfd) * (size_t)(num_open.rlim_max));
+    if(!testfd) {
+      fprintf(stderr, "testfd, malloc() failed\n");
       num_open.rlim_max /= 2;
     }
-  } while(num_open.rlim_max && !fd);
-  if(!fd) {
-    store_errmsg("fd, malloc() failed", errno);
+  } while(num_open.rlim_max && !testfd);
+  if(!testfd) {
+    store_errmsg("testfd, malloc() failed", errno);
     fprintf(stderr, "%s\n", msgbuff);
     free(memchunk);
     return -6;
@@ -304,25 +304,25 @@ static int rlimit(int keep_open)
 
   /* initialize it to fight lazy allocation */
 
-  fprintf(stderr, "initializing fd array\n");
+  fprintf(stderr, "initializing testfd array\n");
 
   for(num_open.rlim_cur = 0;
       num_open.rlim_cur < num_open.rlim_max;
       num_open.rlim_cur++)
-    fd[num_open.rlim_cur] = -1;
+    testfd[num_open.rlim_cur] = -1;
 
   rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
   fprintf(stderr, "trying to open %s file descriptors\n", strbuff);
 
   /* open a dummy descriptor */
 
-  fd[0] = open(DEV_NULL, O_RDONLY);
-  if(fd[0] < 0) {
+  testfd[0] = open(DEV_NULL, O_RDONLY);
+  if(testfd[0] < 0) {
     msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
     store_errmsg(strbuff, errno);
     fprintf(stderr, "%s\n", msgbuff);
-    free(fd);
-    fd = NULL;
+    free(testfd);
+    testfd = NULL;
     free(memchunk);
     return -7;
   }
@@ -333,11 +333,11 @@ static int rlimit(int keep_open)
       num_open.rlim_cur < num_open.rlim_max;
       num_open.rlim_cur++) {
 
-    fd[num_open.rlim_cur] = dup(fd[0]);
+    testfd[num_open.rlim_cur] = dup(testfd[0]);
 
-    if(fd[num_open.rlim_cur] < 0) {
+    if(testfd[num_open.rlim_cur] < 0) {
 
-      fd[num_open.rlim_cur] = -1;
+      testfd[num_open.rlim_cur] = -1;
 
       rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur);
       msnprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1);
@@ -357,10 +357,10 @@ static int rlimit(int keep_open)
       fprintf(stderr, "%s\n", strbuff);
 
       for(num_open.rlim_cur = num_open.rlim_max;
-          fd[num_open.rlim_cur] >= 0;
+          testfd[num_open.rlim_cur] >= 0;
           num_open.rlim_cur++) {
-        close(fd[num_open.rlim_cur]);
-        fd[num_open.rlim_cur] = -1;
+        close(testfd[num_open.rlim_cur]);
+        testfd[num_open.rlim_cur] = -1;
       }
 
       rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
@@ -368,9 +368,9 @@ static int rlimit(int keep_open)
 
       /* we don't care if we can't shrink it */
 
-      tmpfd = realloc(fd, sizeof(*fd) * (size_t)(num_open.rlim_max));
+      tmpfd = realloc(testfd, sizeof(*testfd) * (size_t)(num_open.rlim_max));
       if(tmpfd) {
-        fd = tmpfd;
+        testfd = tmpfd;
         tmpfd = NULL;
       }
 
@@ -409,8 +409,8 @@ static int rlimit(int keep_open)
   for(rl.rlim_cur = 0;
       rl.rlim_cur < num_open.rlim_max;
       rl.rlim_cur++) {
-    if((fd[rl.rlim_cur] > 0) &&
-       ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) {
+    if((testfd[rl.rlim_cur] > 0) &&
+       ((unsigned int)testfd[rl.rlim_cur] > num_open.rlim_cur)) {
       msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
                 FD_SETSIZE);
       store_errmsg(strbuff, 0);
@@ -465,14 +465,14 @@ CURLcode test(char *URL)
 
   if(!strcmp(URL, "check")) {
     /* used by the test script to ask if we can run this test or not */
-    if(rlimit(FALSE)) {
-      fprintf(stdout, "rlimit problem: %s\n", msgbuff);
+    if(test_rlimit(FALSE)) {
+      fprintf(stdout, "test_rlimit problem: %s\n", msgbuff);
       return (CURLcode)1;
     }
     return CURLE_OK; /* sure, run this! */
   }
 
-  if(rlimit(TRUE)) {
+  if(test_rlimit(TRUE)) {
     /* failure */
     return TEST_ERR_MAJOR_BAD;
   }
index 649b4d4283ea51342d4cfd6aaf2905bfe3380bfe..b53b955639f801c92c3b26fc5e736a3521c70cb1 100644 (file)
 
 #define NUM_HANDLES 2
 
-static CURL *eh[NUM_HANDLES];
+static CURL *testeh[NUM_HANDLES];
 
 static CURLcode init(int num, CURLM *cm, const char *url, const char *userpwd,
                      struct curl_slist *headers)
 {
   CURLcode res = CURLE_OK;
 
-  res_easy_init(eh[num]);
+  res_easy_init(testeh[num]);
   if(res)
     goto init_failed;
 
-  res_easy_setopt(eh[num], CURLOPT_URL, url);
+  res_easy_setopt(testeh[num], CURLOPT_URL, url);
   if(res)
     goto init_failed;
 
-  res_easy_setopt(eh[num], CURLOPT_PROXY, PROXY);
+  res_easy_setopt(testeh[num], CURLOPT_PROXY, PROXY);
   if(res)
     goto init_failed;
 
-  res_easy_setopt(eh[num], CURLOPT_PROXYUSERPWD, userpwd);
+  res_easy_setopt(testeh[num], CURLOPT_PROXYUSERPWD, userpwd);
   if(res)
     goto init_failed;
 
-  res_easy_setopt(eh[num], CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
+  res_easy_setopt(testeh[num], CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
   if(res)
     goto init_failed;
 
-  res_easy_setopt(eh[num], CURLOPT_VERBOSE, 1L);
+  res_easy_setopt(testeh[num], CURLOPT_VERBOSE, 1L);
   if(res)
     goto init_failed;
 
-  res_easy_setopt(eh[num], CURLOPT_HEADER, 1L);
+  res_easy_setopt(testeh[num], CURLOPT_HEADER, 1L);
   if(res)
     goto init_failed;
 
-  res_easy_setopt(eh[num], CURLOPT_HTTPHEADER, headers); /* custom Host: */
+  res_easy_setopt(testeh[num], CURLOPT_HTTPHEADER, headers); /* custom Host: */
   if(res)
     goto init_failed;
 
-  res_multi_add_handle(cm, eh[num]);
+  res_multi_add_handle(cm, testeh[num]);
   if(res)
     goto init_failed;
 
@@ -93,8 +93,8 @@ static CURLcode init(int num, CURLM *cm, const char *url, const char *userpwd,
 
 init_failed:
 
-  curl_easy_cleanup(eh[num]);
-  eh[num] = NULL;
+  curl_easy_cleanup(testeh[num]);
+  testeh[num] = NULL;
 
   return res; /* failure */
 }
@@ -174,8 +174,8 @@ static CURLcode loop(int num, CURLM *cm, const char *url, const char *userpwd,
         curl_multi_remove_handle(cm, e);
         curl_easy_cleanup(e);
         for(i = 0; i < NUM_HANDLES; i++) {
-          if(eh[i] == e) {
-            eh[i] = NULL;
+          if(testeh[i] == e) {
+            testeh[i] = NULL;
             break;
           }
         }
@@ -201,7 +201,7 @@ CURLcode test(char *URL)
   int i;
 
   for(i = 0; i < NUM_HANDLES; i++)
-    eh[i] = NULL;
+    testeh[i] = NULL;
 
   start_test_timing();
 
@@ -243,8 +243,8 @@ test_cleanup:
   /* proper cleanup sequence - type PB */
 
   for(i = 0; i < NUM_HANDLES; i++) {
-    curl_multi_remove_handle(cm, eh[i]);
-    curl_easy_cleanup(eh[i]);
+    curl_multi_remove_handle(cm, testeh[i]);
+    curl_easy_cleanup(testeh[i]);
   }
 
   curl_multi_cleanup(cm);
index 5900a20fb5c86023c3c6c7ddd868b37e98dfc7ec..76244ab339374367b4667e82f5844377de2380c7 100644 (file)
@@ -30,7 +30,7 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-struct data {
+struct testdata {
   char trace_ascii; /* 1 or 0 */
 };
 
@@ -89,7 +89,7 @@ int my_trace(CURL *handle, curl_infotype type,
              char *data, size_t size,
              void *userp)
 {
-  struct data *config = (struct data *)userp;
+  struct testdata *config = (struct testdata *)userp;
   const char *text;
   (void)handle; /* prevent compiler warning */
 
@@ -170,7 +170,7 @@ CURLcode test(char *URL)
 {
   CURL *curl;
   CURLcode res = CURLE_OK;
-  struct data config;
+  struct testdata config;
   size_t i;
   static const char fill[] = "test data";
 
index 95fdf9eff343e7eafa94e2c0818b51633ec27db0..10c19a38045a0df25969af92e8d9551b9ae983dc 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static char data[]=
+static char testdata[]=
   "this is what we post to the silly web server\n";
 
 struct WriteThis {
@@ -59,7 +59,7 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
 #endif
 }
 
-static CURLcode once(char *URL, bool oldstyle)
+static CURLcode test_once(char *URL, bool oldstyle)
 {
   CURL *curl;
   CURLcode res = CURLE_OK;
@@ -70,8 +70,8 @@ static CURLcode once(char *URL, bool oldstyle)
   struct WriteThis pooh;
   struct WriteThis pooh2;
 
-  pooh.readptr = data;
-  pooh.sizeleft = strlen(data);
+  pooh.readptr = testdata;
+  pooh.sizeleft = strlen(testdata);
 
   /* Fill in the file upload field */
   if(oldstyle) {
@@ -104,8 +104,8 @@ static CURLcode once(char *URL, bool oldstyle)
   /* Now add the same data with another name and make it not look like
      a file upload but still using the callback */
 
-  pooh2.readptr = data;
-  pooh2.sizeleft = strlen(data);
+  pooh2.readptr = testdata;
+  pooh2.sizeleft = strlen(testdata);
 
   CURL_IGNORE_DEPRECATION(
     /* Fill in the file upload field */
@@ -213,9 +213,9 @@ CURLcode test(char *URL)
     return TEST_ERR_MAJOR_BAD;
   }
 
-  res = once(URL, TRUE); /* old */
+  res = test_once(URL, TRUE); /* old */
   if(!res)
-    res = once(URL, FALSE); /* new */
+    res = test_once(URL, FALSE); /* new */
 
   curl_global_cleanup();
 
index 89b4b9ca45b8d740eeee25aad5742c483223a013..82b7f7f5a90e0c98858626e12ece83fde6974bc8 100644 (file)
@@ -27,8 +27,6 @@
  * curl_m*printf formatting capabilities and handling of some data types.
  */
 
-#define CURL_NO_FMT_CHECKS /* disable compiler *printf format checks */
-
 #include "test.h"
 
 #include <limits.h>
 
 #include "memdebug.h"
 
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat"
+#pragma GCC diagnostic ignored "-Wformat-extra-args"
+#endif
+
 #if (SIZEOF_CURL_OFF_T > SIZEOF_LONG)
 #  define MPRNT_SUFFIX_CURL_OFF_T  LL
 #else
@@ -1507,3 +1511,7 @@ CURLcode test(char *URL)
   else
     return CURLE_OK;
 }
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
index bc632a17e71e36bd206eab8a48815bb7502dcac6..6be64a1aa1df2902baa0809c2179f03987cfa7e0 100644 (file)
@@ -26,9 +26,9 @@
 #include "memdebug.h"
 
 /* The size of data should be kept below MAX_INITIAL_POST_SIZE! */
-static char data[]="this is a short string.\n";
+static char testdata[]="this is a short string.\n";
 
-static size_t data_size = sizeof(data) / sizeof(char);
+static size_t data_size = sizeof(testdata) / sizeof(char);
 
 static int progress_callback(void *clientp, double dltotal, double dlnow,
                              double ultotal, double ulnow)
@@ -75,7 +75,7 @@ CURLcode test(char *URL)
 
   /* Set the expected POST size */
   test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)data_size);
-  test_setopt(curl, CURLOPT_POSTFIELDS, data);
+  test_setopt(curl, CURLOPT_POSTFIELDS, testdata);
 
   /* we want to use our own progress function */
   CURL_IGNORE_DEPRECATION(
index 7e314c308c79f13220563bf3a2582150e075f8fe..9b1591fad1be2154a74104b869c6b65f249d631c 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static const char * const post[]={
+static const char * const testpost[]={
   "one",
   "two",
   "three",
@@ -81,7 +81,7 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
   if(size*nmemb < 1)
     return 0;
 
-  data = post[pooh->counter];
+  data = testpost[pooh->counter];
 
   if(data) {
     size_t len = strlen(data);
index 5f393d66211834bf48bae29a364821230eaa3fb7..d1609a83d3ff4fc76d0bdcfb427fa779fcdb08bc 100644 (file)
 
 #define TEST_HANG_TIMEOUT 60 * 1000
 
-struct Sockets
-{
+struct Sockets {
   curl_socket_t *sockets;
   int count;      /* number of sockets actually stored in array */
   int max_count;  /* max number of sockets that fit in allocated array */
 };
 
-struct ReadWriteSockets
-{
+struct ReadWriteSockets {
   struct Sockets read, write;
 };
 
index 8a510a586bf079655f115741ebbe7781a8232ff4..c6d9f7d7f178dca59428623a335b7d9e8f24ade1 100644 (file)
@@ -38,8 +38,8 @@ struct userdata {
 };
 
 /* lock callback */
-static void my_lock(CURL *handle, curl_lock_data data,
-                    curl_lock_access laccess, void *useptr)
+static void test_lock(CURL *handle, curl_lock_data data,
+                      curl_lock_access laccess, void *useptr)
 {
   const char *what;
   struct userdata *user = (struct userdata *)useptr;
@@ -69,7 +69,7 @@ static void my_lock(CURL *handle, curl_lock_data data,
 }
 
 /* unlock callback */
-static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
+static void test_unlock(CURL *handle, curl_lock_data data, void *useptr)
 {
   const char *what;
   struct userdata *user = (struct userdata *)useptr;
@@ -96,7 +96,7 @@ static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
 }
 
 /* the dummy thread function */
-static void *fire(void *ptr)
+static void *test_fire(void *ptr)
 {
   CURLcode code;
   struct Tdata *tdata = (struct Tdata*)ptr;
@@ -160,11 +160,11 @@ CURLcode test(char *URL)
 
   if(CURLSHE_OK == scode) {
     printf("CURLSHOPT_LOCKFUNC\n");
-    scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock);
+    scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock);
   }
   if(CURLSHE_OK == scode) {
     printf("CURLSHOPT_UNLOCKFUNC\n");
-    scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock);
+    scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock);
   }
   if(CURLSHE_OK == scode) {
     printf("CURLSHOPT_USERDATA\n");
@@ -193,7 +193,7 @@ CURLcode test(char *URL)
 
     /* simulate thread, direct call of "thread" function */
     printf("*** run %d\n",i);
-    fire(&tdata);
+    test_fire(&tdata);
   }
 
 
index 9207caae829c1248fa4d830633de8441daba8286..bd7f5e0f8c1c53b5b0f2199f34e035c400cbf268 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static char data[]=
+static char testdata[]=
   "dummy\n";
 
 struct WriteThis {
@@ -56,7 +56,7 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
   return 0;                         /* no more data left to deliver */
 }
 
-static CURLcode once(char *URL, bool oldstyle)
+static CURLcode test_once(char *URL, bool oldstyle)
 {
   CURL *curl;
   CURLcode res = CURLE_OK;
@@ -67,9 +67,9 @@ static CURLcode once(char *URL, bool oldstyle)
   struct WriteThis pooh2;
   curl_off_t datasize = -1;
 
-  pooh.readptr = data;
+  pooh.readptr = testdata;
 #ifndef LIB645
-  datasize = (curl_off_t)strlen(data);
+  datasize = (curl_off_t)strlen(testdata);
 #endif
   pooh.sizeleft = datasize;
 
@@ -122,9 +122,9 @@ static CURLcode once(char *URL, bool oldstyle)
   /* Now add the same data with another name and make it not look like
      a file upload but still using the callback */
 
-  pooh2.readptr = data;
+  pooh2.readptr = testdata;
 #ifndef LIB645
-  datasize = (curl_off_t)strlen(data);
+  datasize = (curl_off_t)strlen(testdata);
 #endif
   pooh2.sizeleft = datasize;
 
@@ -256,9 +256,9 @@ CURLcode test(char *URL)
     return TEST_ERR_MAJOR_BAD;
   }
 
-  res = once(URL, TRUE); /* old */
+  res = test_once(URL, TRUE); /* old */
   if(!res)
-    res = once(URL, FALSE); /* new */
+    res = test_once(URL, FALSE); /* new */
 
   if(!res)
     res = cyclic_add();
index 2945e366f6bde5e4e10cb5cdc0f830a33f63e2d2..f0d459e663bfc05070c5386d5700464a29cd9da9 100644 (file)
 
 #include "memdebug.h"
 
-static char data[] =
+static char testdata[] =
   "this is what we post to the silly web server";
 
-static const char name[] = "fieldname";
+static const char testname[] = "fieldname";
 
 
 /* This test attempts to use all form API features that are not
@@ -81,8 +81,8 @@ CURLcode test(char *URL)
   headers = headers2;
   CURL_IGNORE_DEPRECATION(
     formrc = curl_formadd(&formpost, &lastptr,
-                          CURLFORM_COPYNAME, &name,
-                          CURLFORM_COPYCONTENTS, &data,
+                          CURLFORM_COPYNAME, &testname,
+                          CURLFORM_COPYCONTENTS, &testdata,
                           CURLFORM_CONTENTHEADER, headers,
                           CURLFORM_END);
   )
@@ -91,20 +91,20 @@ CURLcode test(char *URL)
     goto test_cleanup;
   }
 
-  contentlength = (long)(strlen(data) - 1);
+  contentlength = (long)(strlen(testdata) - 1);
 
   CURL_IGNORE_DEPRECATION(
     /* Use a form array for the non-copy test. */
     formarray[0].option = CURLFORM_PTRCONTENTS;
-    formarray[0].value = data;
+    formarray[0].value = testdata;
     formarray[1].option = CURLFORM_CONTENTSLENGTH;
     formarray[1].value = (char *)(size_t)contentlength;
     formarray[2].option = CURLFORM_END;
     formarray[2].value = NULL;
     formrc = curl_formadd(&formpost,
                           &lastptr,
-                          CURLFORM_PTRNAME, name,
-                          CURLFORM_NAMELENGTH, strlen(name) - 1,
+                          CURLFORM_PTRNAME, testname,
+                          CURLFORM_NAMELENGTH, strlen(testname) - 1,
                           CURLFORM_ARRAY, formarray,
                           CURLFORM_FILENAME, "remotefile.txt",
                           CURLFORM_END);
@@ -117,7 +117,7 @@ CURLcode test(char *URL)
   /* Now change in-memory data to affect CURLOPT_PTRCONTENTS value.
      Copied values (first field) must not be affected.
      CURLOPT_PTRNAME actually copies the name thus we do not test this here. */
-  data[0]++;
+  testdata[0]++;
 
   CURL_IGNORE_DEPRECATION(
     /* Check multi-files and content type propagation. */
index 3993dfa6222fefcce58a8d8d48b0de846e008ce6..7fb97def86501ac3f013c47a5c3a19e576a2b98f 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static char buffer[17000]; /* more than 16K */
+static char testbuf[17000]; /* more than 16K */
 
 CURLcode test(char *URL)
 {
@@ -37,12 +37,12 @@ CURLcode test(char *URL)
 
   /* create a buffer with AAAA...BBBBB...CCCC...etc */
   int i;
-  int size = (int)sizeof(buffer)/1000;
+  int size = (int)sizeof(testbuf)/1000;
 
   for(i = 0; i < size ; i++)
-    memset(&buffer[i * 1000], 65 + i, 1000);
+    memset(&testbuf[i * 1000], 65 + i, 1000);
 
-  buffer[ sizeof(buffer)-1] = 0; /* null-terminate */
+  testbuf[sizeof(testbuf)-1] = 0; /* null-terminate */
 
   if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
     fprintf(stderr, "curl_global_init() failed\n");
@@ -53,7 +53,7 @@ CURLcode test(char *URL)
     /* Check proper name and data copying. */
     formrc = curl_formadd(&formpost, &lastptr,
                           CURLFORM_COPYNAME, "hello",
-                          CURLFORM_COPYCONTENTS, buffer,
+                          CURLFORM_COPYCONTENTS, testbuf,
                           CURLFORM_END);
   )
   if(formrc)
index 50c645fffd5ad4c476531c64a4601bb4e673cbb1..591aa7269a31addb8d8383c9a91e399ef091805c 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static char buffer[17000]; /* more than 16K */
+static char testbuf[17000]; /* more than 16K */
 
 CURLcode test(char *URL)
 {
@@ -35,12 +35,12 @@ CURLcode test(char *URL)
   curl_mimepart *part;
   struct curl_slist *recipients = NULL;
 
-  /* create a buffer with AAAA...BBBBB...CCCC...etc */
+  /* create a testbuf with AAAA...BBBBB...CCCC...etc */
   int i;
-  int size = (int)sizeof(buffer) / 10;
+  int size = (int)sizeof(testbuf) / 10;
 
   for(i = 0; i < size ; i++)
-    memset(&buffer[i * 10], 65 + (i % 26), 10);
+    memset(&testbuf[i * 10], 65 + (i % 26), 10);
 
   if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
     fprintf(stderr, "curl_global_init() failed\n");
@@ -77,7 +77,7 @@ CURLcode test(char *URL)
     fprintf(stderr, "curl_mime_type() failed\n");
     goto test_cleanup;
   }
-  res = curl_mime_data(part, buffer, sizeof(buffer));
+  res = curl_mime_data(part, testbuf, sizeof(testbuf));
   if(res) {
     fprintf(stderr, "curl_mime_data() failed\n");
     goto test_cleanup;
index b85edcff85e3cc4f5d32da61a7a7ac7487e34fa3..66ec29d17c69f779c158abc5f4432e00371acf9a 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static char data[]=
+static char testdata[]=
   "dummy\n";
 
 struct WriteThis {
@@ -94,8 +94,8 @@ CURLcode test(char *URL)
   test_setopt(easy, CURLOPT_HEADER, 1L);
 
   /* Prepare the callback structure. */
-  pooh.readptr = data;
-  pooh.sizeleft = (curl_off_t) strlen(data);
+  pooh.readptr = testdata;
+  pooh.sizeleft = (curl_off_t) strlen(testdata);
   pooh.freecount = 0;
 
   /* Build the mime tree. */
index e010e27f1831c42a77dba5a084144e1d3ee0cc7e..dd172be4ab2a95c1f6be6a7b072aa822a612b9f9 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static char buffer[17000]; /* more than 16K */
+static char testbuf[17000]; /* more than 16K */
 
 CURLcode test(char *URL)
 {
@@ -37,12 +37,12 @@ CURLcode test(char *URL)
 
   /* Checks huge binary-encoded mime post. */
 
-  /* Create a buffer with pseudo-binary data. */
-  for(i = 0; i < sizeof(buffer); i++)
+  /* Create a testbuf with pseudo-binary data. */
+  for(i = 0; i < sizeof(testbuf); i++)
     if(i % 77 == 76)
-      buffer[i] = '\n';
+      testbuf[i] = '\n';
     else
-      buffer[i] = (char) (0x41 + i % 26); /* A...Z */
+      testbuf[i] = (char) (0x41 + i % 26); /* A...Z */
 
   if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
     fprintf(stderr, "curl_global_init() failed\n");
@@ -79,7 +79,7 @@ CURLcode test(char *URL)
     fprintf(stderr, "curl_mime_filename() failed\n");
     goto test_cleanup;
   }
-  res = curl_mime_data(part, buffer, sizeof(buffer));
+  res = curl_mime_data(part, testbuf, sizeof(testbuf));
   if(res) {
     fprintf(stderr, "curl_mime_data() failed\n");
     goto test_cleanup;
index c54323277cb4d12066dd29663d52c5304dbd20ea..d190601464fa3187815cf93d42db7bdf859a9617 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static char data[]=
+static char testdata[]=
   "dummy";
 
 struct WriteThis {
@@ -84,8 +84,8 @@ CURLcode test(char *URL)
   test_setopt(easy, CURLOPT_HEADER, 1L);
 
   /* Prepare the callback structure. */
-  pooh.readptr = data;
-  pooh.sizeleft = (curl_off_t) strlen(data);
+  pooh.readptr = testdata;
+  pooh.sizeleft = (curl_off_t) strlen(testdata);
 
   /* Build the mime tree. */
   mime = curl_mime_init(easy);
index 2ee0008dfb34808093d6f9bd5fc1f27e6680188e..141e0ea5716ef8309a99e178a08e48039fa043ee 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "memdebug.h"
 
-static char data[]= "dummy";
+static char testdata[]= "dummy";
 
 struct WriteThis {
   char *readptr;
@@ -77,8 +77,8 @@ CURLcode test(char *URL)
   test_setopt(easy, CURLOPT_HEADER, 1L);
 
   /* Prepare the callback structures. */
-  pooh1.readptr = data;
-  pooh1.sizeleft = (curl_off_t) strlen(data);
+  pooh1.readptr = testdata;
+  pooh1.sizeleft = (curl_off_t) strlen(testdata);
   pooh2 = pooh1;
 
   /* Build the mime tree. */
@@ -86,7 +86,7 @@ CURLcode test(char *URL)
   part = curl_mime_addpart(mime);
   curl_mime_name(part, "field1");
   /* Early end of data detection can be done because the data size is known. */
-  curl_mime_data_cb(part, (curl_off_t) strlen(data),
+  curl_mime_data_cb(part, (curl_off_t) strlen(testdata),
                     read_callback, NULL, NULL, &pooh1);
   part = curl_mime_addpart(mime);
   curl_mime_name(part, "field2");
index 8c4a7b9651e864e4893dee30b081d8e7d6602766..4f797c583a20e86e2ffdfce146aef7363ae52159 100644 (file)
@@ -30,7 +30,7 @@
 #define PAUSE_TIME      5
 
 
-static const char name[] = "field";
+static const char testname[] = "field";
 
 struct ReadThis {
   CURL *easy;
@@ -139,7 +139,7 @@ CURLcode test(char *URL)
   /* Build the mime tree. */
   mime = curl_mime_init(pooh.easy);
   part = curl_mime_addpart(mime);
-  res = curl_mime_name(part, name);
+  res = curl_mime_name(part, testname);
   if(res != CURLE_OK) {
     fprintf(stderr,
             "Something went wrong when building the mime structure: %d\n",
@@ -157,7 +157,7 @@ CURLcode test(char *URL)
   CURL_IGNORE_DEPRECATION(
     /* Build the form. */
     formrc = curl_formadd(&formpost, &lastptr,
-                          CURLFORM_COPYNAME, name,
+                          CURLFORM_COPYNAME, testname,
                           CURLFORM_STREAM, &pooh,
                           CURLFORM_CONTENTLEN, (curl_off_t) 2,
                           CURLFORM_END);
index d3bc1574eb4e4f57a5eca4d0bd69dd6fd9241b82..ebb9f40848fc2a38ab72a7a9d4e8ed6041de2096 100644 (file)
@@ -27,7 +27,7 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-static const char cmd[] = "A1 IDLE\r\n";
+static const char testcmd[] = "A1 IDLE\r\n";
 static char testbuf[1024];
 
 CURLcode test(char *URL)
@@ -82,7 +82,8 @@ CURLcode test(char *URL)
 
       if(!state) {
         CURLcode ec;
-        ec = curl_easy_send(curl, cmd + pos, sizeof(cmd) - 1 - pos, &len);
+        ec = curl_easy_send(curl, testcmd + pos,
+                            sizeof(testcmd) - 1 - pos, &len);
         if(ec == CURLE_AGAIN) {
           continue;
         }
@@ -96,7 +97,7 @@ CURLcode test(char *URL)
           pos += len;
         else
           pos = 0;
-        if(pos == sizeof(cmd) - 1) {
+        if(pos == sizeof(testcmd) - 1) {
           state++;
           pos = 0;
         }
index e2e5b64103712031e8107225ef54f1c33614865c..9cbcb50bb55ff92a2b619d51d5e374670f21b37e 100644 (file)
 #define TEST_HANG_TIMEOUT 60 * 1000
 #define MAX_EASY_HANDLES 3
 
-static int counter[MAX_EASY_HANDLES];
-static CURL *easy[MAX_EASY_HANDLES];
-static curl_socket_t sockets[MAX_EASY_HANDLES];
-static CURLcode res = CURLE_OK;
+static int ntlm_counter[MAX_EASY_HANDLES];
+static CURL *ntlm_easy[MAX_EASY_HANDLES];
+static curl_socket_t ntlm_sockets[MAX_EASY_HANDLES];
+static CURLcode ntlmcb_res = CURLE_OK;
 
 static size_t callback(char *ptr, size_t size, size_t nmemb, void *data)
 {
-  ssize_t idx = ((CURL **) data) - easy;
+  ssize_t idx = ((CURL **) data) - ntlm_easy;
   curl_socket_t sock;
   long longdata;
   CURLcode code;
   const size_t failure = (size && nmemb) ? 0 : 1;
   (void)ptr;
 
-  counter[idx] += (int)(size * nmemb);
+  ntlm_counter[idx] += (int)(size * nmemb);
 
   /* Get socket being used for this easy handle, otherwise CURL_SOCKET_BAD */
   CURL_IGNORE_DEPRECATION(
-    code = curl_easy_getinfo(easy[idx], CURLINFO_LASTSOCKET, &longdata);
+    code = curl_easy_getinfo(ntlm_easy[idx], CURLINFO_LASTSOCKET, &longdata);
   )
   if(CURLE_OK != code) {
     fprintf(stderr, "%s:%d curl_easy_getinfo() failed, "
             "with code %d (%s)\n",
             __FILE__, __LINE__, (int)code, curl_easy_strerror(code));
-    res = TEST_ERR_MAJOR_BAD;
+    ntlmcb_res = TEST_ERR_MAJOR_BAD;
     return failure;
   }
   if(longdata == -1L)
@@ -67,16 +67,16 @@ static size_t callback(char *ptr, size_t size, size_t nmemb, void *data)
 
   if(sock != CURL_SOCKET_BAD) {
     /* Track relationship between this easy handle and the socket. */
-    if(sockets[idx] == CURL_SOCKET_BAD) {
+    if(ntlm_sockets[idx] == CURL_SOCKET_BAD) {
       /* An easy handle without previous socket, record the socket. */
-      sockets[idx] = sock;
+      ntlm_sockets[idx] = sock;
     }
-    else if(sock != sockets[idx]) {
+    else if(sock != ntlm_sockets[idx]) {
       /* An easy handle with a socket different to previously
          tracked one, log and fail right away. Known bug #37. */
       fprintf(stderr, "Handle %d started on socket %d and moved to %d\n",
-              curlx_sztosi(idx), (int)sockets[idx], (int)sock);
-      res = TEST_ERR_MAJOR_BAD;
+              curlx_sztosi(idx), (int)ntlm_sockets[idx], (int)sock);
+      ntlmcb_res = TEST_ERR_MAJOR_BAD;
       return failure;
     }
   }
@@ -91,6 +91,7 @@ enum HandleState {
 
 CURLcode test(char *url)
 {
+  CURLcode res = CURLE_OK;
   CURLM *multi = NULL;
   int running;
   int i;
@@ -107,8 +108,8 @@ CURLcode test(char *url)
   }
 
   for(i = 0; i < MAX_EASY_HANDLES; ++i) {
-    easy[i] = NULL;
-    sockets[i] = CURL_SOCKET_BAD;
+    ntlm_easy[i] = NULL;
+    ntlm_sockets[i] = CURL_SOCKET_BAD;
   }
 
   res_global_init(CURL_GLOBAL_ALL);
@@ -130,28 +131,31 @@ CURLcode test(char *url)
 
     /* Start a new handle if we aren't at the max */
     if(state == ReadyForNewHandle) {
-      easy_init(easy[num_handles]);
+      easy_init(ntlm_easy[num_handles]);
 
       if(num_handles % 3 == 2) {
         msnprintf(full_url, urllen, "%s0200", url);
-        easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
+        easy_setopt(ntlm_easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
       }
       else {
         msnprintf(full_url, urllen, "%s0100", url);
-        easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
+        easy_setopt(ntlm_easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
       }
-      easy_setopt(easy[num_handles], CURLOPT_FRESH_CONNECT, 1L);
-      easy_setopt(easy[num_handles], CURLOPT_URL, full_url);
-      easy_setopt(easy[num_handles], CURLOPT_VERBOSE, 1L);
-      easy_setopt(easy[num_handles], CURLOPT_HTTPGET, 1L);
-      easy_setopt(easy[num_handles], CURLOPT_USERPWD, "testuser:testpass");
-      easy_setopt(easy[num_handles], CURLOPT_WRITEFUNCTION, callback);
-      easy_setopt(easy[num_handles], CURLOPT_WRITEDATA, easy + num_handles);
-      easy_setopt(easy[num_handles], CURLOPT_HEADER, 1L);
-
-      multi_add_handle(multi, easy[num_handles]);
+      easy_setopt(ntlm_easy[num_handles], CURLOPT_FRESH_CONNECT, 1L);
+      easy_setopt(ntlm_easy[num_handles], CURLOPT_URL, full_url);
+      easy_setopt(ntlm_easy[num_handles], CURLOPT_VERBOSE, 1L);
+      easy_setopt(ntlm_easy[num_handles], CURLOPT_HTTPGET, 1L);
+      easy_setopt(ntlm_easy[num_handles], CURLOPT_USERPWD,
+                  "testuser:testpass");
+      easy_setopt(ntlm_easy[num_handles], CURLOPT_WRITEFUNCTION, callback);
+      easy_setopt(ntlm_easy[num_handles], CURLOPT_WRITEDATA,
+                  ntlm_easy + num_handles);
+      easy_setopt(ntlm_easy[num_handles], CURLOPT_HEADER, 1L);
+
+      multi_add_handle(multi, ntlm_easy[num_handles]);
       num_handles += 1;
       state = NeedSocketForNewHandle;
+      res = ntlmcb_res;
     }
 
     multi_perform(multi, &running);
@@ -223,9 +227,9 @@ test_cleanup:
   /* proper cleanup sequence - type PB */
 
   for(i = 0; i < MAX_EASY_HANDLES; i++) {
-    printf("Data connection %d: %d\n", i, counter[i]);
-    curl_multi_remove_handle(multi, easy[i]);
-    curl_easy_cleanup(easy[i]);
+    printf("Data connection %d: %d\n", i, ntlm_counter[i]);
+    curl_multi_remove_handle(multi, ntlm_easy[i]);
+    curl_easy_cleanup(ntlm_easy[i]);
   }
 
   curl_multi_cleanup(multi);
index 0eee841c2769c3ff2865c5d5f64a5bc13bc31dca..b5dae5cb94d8d96636f50e325f798f7a2692abe5 100755 (executable)
@@ -201,7 +201,7 @@ print <<HEADER
 
 /* This source code is generated by mk-lib1521.pl ! */
 
-struct data {
+struct testdata {
     char *blaha;
 };
 
@@ -332,7 +332,7 @@ CURLcode test(char *URL)
   struct curl_httppost *httppost = NULL;
   curl_mime *mimepost = NULL;
   FILE *stream = stderr;
-  struct data object;
+  struct testdata object;
   char *charp;
   long val;
   curl_off_t oval;
index 24ad9a837b4f0611de391d9bb39155ac546c8da7..28673c6f9d27a834ddca7b58f43ee9fb8811efe9 100644 (file)
@@ -70,8 +70,10 @@ extern int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
 
 extern void wait_ms(int ms); /* wait this many milliseconds */
 
+#ifndef CURLTESTS_BUNDLED_TEST_H
 extern CURLcode test(char *URL); /* the actual test function provided by each
                                     individual libXXX.c file */
+#endif
 
 extern char *hexdump(const unsigned char *buffer, size_t len);
 
@@ -491,6 +493,7 @@ extern int unitfail;
 #define global_init(A) \
   chk_global_init((A), (__FILE__), (__LINE__))
 
+#ifndef CURLTESTS_BUNDLED_TEST_H
 #define NO_SUPPORT_BUILT_IN                     \
   CURLcode test(char *URL)                      \
   {                                             \
@@ -498,7 +501,22 @@ extern int unitfail;
     fprintf(stderr, "Missing support\n");       \
     return (CURLcode)1;                         \
   }
+#endif
 
 /* ---------------------------------------------------------------- */
 
 #endif /* HEADER_CURL_TEST_H */
+
+#ifdef CURLTESTS_BUNDLED_TEST_H
+extern CURLcode test(char *URL); /* the actual test function provided by each
+                                    individual libXXX.c file */
+
+#undef NO_SUPPORT_BUILT_IN
+#define NO_SUPPORT_BUILT_IN                     \
+  CURLcode test(char *URL)                      \
+  {                                             \
+    (void)URL;                                  \
+    fprintf(stderr, "Missing support\n");       \
+    return (CURLcode)1;                         \
+  }
+#endif
diff --git a/tests/mk-bundle-hints.sh b/tests/mk-bundle-hints.sh
new file mode 100755 (executable)
index 0000000..67bf936
--- /dev/null
@@ -0,0 +1,74 @@
+#!/usr/bin/env bash
+#***************************************************************************
+#                                  _   _ ____  _
+#  Project                     ___| | | |  _ \| |
+#                             / __| | | | |_) | |
+#                            | (__| |_| |  _ <| |___
+#                             \___|\___/|_| \_\_____|
+#
+# Copyright (C) Viktor Szakats
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at https://curl.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+# SPDX-License-Identifier: curl
+#
+###########################################################################
+
+detect_in_reused_sources=1
+
+if [ "$detect_in_reused_sources" = '1' ]; then
+  # Make symlinks for all re-used sources
+  grep -E '^(lib|unit)[0-9]+_SOURCES = ' libtest/Makefile.inc unit/Makefile.inc \
+    | sed -E 's@^([a-z]+)/[a-zA-Z.]+:(lib|unit)([0-9]+)_SOURCES = (lib|unit)([0-9]+).+@\1 \2 \3 \5@g' | \
+  while read -r l; do
+    if [[ "${l}" =~ ([a-z]+)\ ([a-z]+)\ ([0-9]+)\ ([0-9]+) ]]; then
+      trg="${BASH_REMATCH[3]}"
+      src="${BASH_REMATCH[4]}"
+      if [ "${trg}" != "${src}" ]; then
+        dir="${BASH_REMATCH[1]}"
+        pfx="${BASH_REMATCH[2]}"
+        ln -s "${pfx}${src}.c" "${dir}/${pfx}${trg}.c"
+      fi
+    fi
+  done
+fi
+
+# Look for symbols possibly re-used in multiple sources.
+#
+# Falsely picks ups symbols in re-used sources, but guarded for a single use.
+# Misses shadowed variables.
+# shellcheck disable=SC2046
+grep -E '^ *(static|struct) +' $(find libtest unit -maxdepth 1 -name 'lib*.c' -o -name 'unit*.c' -o -name 'mk-*.pl') \
+  | grep -E '^(libtest|unit)/' \
+  | grep -E '\.(c|pl):(static|struct)( +[a-zA-Z_* ]+)? +[a-zA-Z_][a-zA-Z0-9_]+ *' | sort -u \
+  | grep -o -E '[a-zA-Z_][a-zA-Z0-9_]+ *[=;[({]' | tr -d '=;[({ ' \
+  | grep -v -E '^(NULL$|sizeof$|CURLE_)' \
+  | sort | uniq -c | sort -k 2 | grep -v -E '^ +1 ' \
+  | awk '{print "    \"" $2 "\","}'
+
+echo '---'
+
+# Extract list of macros that may be re-used by multiple tests.
+#
+# Picks up false-positive when the macro is defined to the same value everywhere.
+# shellcheck disable=SC2046
+grep -E '^ *# *define +' $(find libtest unit -maxdepth 1 -name 'lib*.c' -o -name 'unit*.c' -o -name 'mk-*.pl') \
+  | grep -E '^(libtest|unit)/' \
+  | grep -o -E '.+\.(c|pl): *# *define +[A-Z_][A-Z0-9_]+' | sort -u \
+  | grep -o -E '[A-Z_][A-Z0-9_]+' \
+  | sort | uniq -c | sort -k 2 | grep -v -E '^ +1 ' \
+  | awk '{print "    \"" $2 "\","}'
+
+if [ "$detect_in_reused_sources" = '1' ]; then
+  # Delete symlinks for all re-used sources
+  find libtest unit -type l -delete
+fi
diff --git a/tests/mk-bundle.pl b/tests/mk-bundle.pl
new file mode 100755 (executable)
index 0000000..5ed28a0
--- /dev/null
@@ -0,0 +1,162 @@
+#!/usr/bin/env perl
+#***************************************************************************
+#                                  _   _ ____  _
+#  Project                     ___| | | |  _ \| |
+#                             / __| | | | |_) | |
+#                            | (__| |_| |  _ <| |___
+#                             \___|\___/|_| \_\_____|
+#
+# Copyright (C) Viktor Szakats
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at https://curl.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+# SPDX-License-Identifier: curl
+#
+###########################################################################
+
+# Bundle up individual tests into a single binary. The resulting binary can run
+# individual tests by passing their name (without '.c') as the first argument.
+#
+# Usage: mk-bundle.pl [<directory>]
+
+use strict;
+use warnings;
+
+my $src_dir = @ARGV ? $ARGV[0] : ".";
+
+# Read list of tests
+open my $fh, "<", "$src_dir/Makefile.inc" or die "Cannot open '$src_dir/Makefile.inc': $!";
+
+print <<HEADER
+/* !checksrc! disable COPYRIGHT all */
+/* !checksrc! disable INCLUDEDUP all */
+
+#define CURLTESTS_BUNDLED
+#define CURLTESTS_BUNDLED_TEST_H
+#include "first.h"
+HEADER
+    ;
+
+# TODO: Some of these might be subject for de-duplication or sync.
+my @reused_symbols = (
+    "ReadThis",
+    "ReadWriteSockets",
+    "Sockets",
+    "Tdata",
+    "WriteThis",
+    "addFd",
+    "checkFdSet",
+    "checkForCompletion",
+    "close_file_descriptors",
+    "curl",  # shadow
+    "curlSocketCallback",
+    "curlTimerCallback",
+    "cyclic_add",
+    "easy",  # unit
+    "fopen_works",
+    "getMicroSecondTimeout",
+    "geterr",
+    "hash_static",  # unit
+    "header_callback",
+    "ioctlcallback",
+    "msgbuff",
+    "mydtor",  # unit
+    "num_open",
+    "progress_callback",
+    "read_callback",
+    "readcallback",
+    "recv_pong",
+    "removeFd",
+    "rlim2str",
+    "run_thread",
+    "send_ping",
+    "showem",
+    "store_errmsg",
+    "suburl",
+    "test_failure",  # shadow
+    "test_fire",
+    "test_lock",
+    "test_once",
+    "test_parse",  # unit
+    "test_rlimit",
+    "test_unlock",
+    "testbuf",
+    "testcase",  # unit
+    "testdata",
+    "testfd",
+    "testname",
+    "testpost",
+    "tests",  # unit
+    "teststring",
+    "trailers_callback",
+    "transfer_status",
+    "unit_setup",  # unit
+    "unit_stop",  # unit
+    "updateFdSet",
+    "userdata",
+    "websocket",
+    "websocket_close",
+    "write_callback",
+    "write_cb",
+    "writecb",
+    "xferinfo",
+    );
+
+# TODO: Some of these may be #undef-ed manually at the end of each source
+my @reused_macros = (
+    "HEADER_REQUEST",
+    "NUM_HANDLES",
+    "SAFETY_MARGIN",
+    "TEST_HANG_TIMEOUT",
+    );
+
+my $tlist = "";
+
+while(my $line = <$fh>) {
+    chomp $line;
+    if($line =~ /([a-z0-9]+)_SOURCES\ =\ ([a-z0-9]+)\.c/) {
+        my $name = $1;
+        my $namu = uc($name);
+        my $src = "$2.c";
+
+        # Make common symbols unique across test sources
+        foreach my $symb ("test", @reused_symbols) {
+            print "#undef $symb\n";
+            print "#define $symb ${symb}_$name\n";
+        }
+
+        print "#define $namu\n";
+        print "#include \"$src\"\n";
+        print "#undef $namu\n";
+
+        # Reset macros re-used by multiple tests
+        foreach my $undef ("test", @reused_macros) {
+            print "#undef $undef\n";
+        }
+
+        print "\n";
+
+        $tlist .= "  {\"$name\", test_$name},\n";
+    }
+}
+
+close $fh;
+
+print <<FOOTER
+static const struct onetest s_tests[] = {
+$tlist};
+
+#undef CURLTESTS_BUNDLED_TEST_H
+
+#include "first.c"
+FOOTER
+    ;
index 49aa75e54a16d838555bb817d544b03e78bacc47..5b83a1a6606d171ed765fda43501d4a4b040f6f0 100644 (file)
@@ -848,10 +848,11 @@ sub singletest_run {
 
     my @codepieces = getpart("client", "tool");
     my $tool="";
+    my $tool_name="";  # without exe extension
     if(@codepieces) {
-        $tool = $codepieces[0];
-        chomp $tool;
-        $tool .= exe_ext('TOOL');
+        $tool_name = $codepieces[0];
+        chomp $tool_name;
+        $tool = $tool_name . exe_ext('TOOL');
     }
 
     my $disablevalgrind;
@@ -904,20 +905,36 @@ sub singletest_run {
 
         # Default the tool to a unit test with the same name as the test spec
         if($keywords{"unittest"} && !$tool) {
-            $tool="unit$testnum";
+            $tool_name="unit$testnum";
+            $tool = $tool_name;
         }
 
         if($tool =~ /^lib/) {
-            $CMDLINE="$LIBDIR/$tool";
+            if($bundle) {
+                $CMDLINE="$LIBDIR/libtests";
+            }
+            else {
+                $CMDLINE="$LIBDIR/$tool";
+            }
         }
         elsif($tool =~ /^unit/) {
-            $CMDLINE="$UNITDIR/$tool";
+            if($bundle) {
+                $CMDLINE="$UNITDIR/units";
+            }
+            else {
+                $CMDLINE="$UNITDIR/$tool";
+            }
         }
 
         if(! -f $CMDLINE) {
             logmsg " $testnum: IGNORED: The tool set in the test case for this: '$tool' does not exist\n";
             return (-1, 0, 0, "", "", 0);
         }
+
+        if($bundle) {
+            $CMDLINE.=" $tool_name";
+        }
+
         $DBGCURL=$CMDLINE;
     }
 
index 1e8c7f74ee29ebb48f7b31daab7cef800ea3cb18..e836911b91d2df8d7ff3f3f2f9ffb87386e675c2 100644 (file)
@@ -91,6 +91,11 @@ Provide a path to a curl binary to talk to APIs (currently only CI test APIs).
 
 Display test results in automake style output (`PASS/FAIL: [number] [name]`).
 
+## `-bundle`
+
+Run tests via bundled test binaries. Bundled test binaries contain all tests,
+and the test name passed as the first argument selects which test run.
+
 ## `-c\<curl\>`
 
 Provide a path to a custom curl binary to run the tests with. Default is the
index 97c5b76b76d49adf2faf3f7eb8a38c4381c80671..31485585e63fce80d1ac3919b3da5415a6424cfd 100755 (executable)
@@ -869,8 +869,9 @@ sub checksystemfeatures {
                "*\n");
     }
 
-    logmsg sprintf("* Env: %s%s%s", $valgrind?"Valgrind ":"",
+    logmsg sprintf("* Env: %s%s%s%s", $valgrind?"Valgrind ":"",
                    $run_event_based?"event-based ":"",
+                   $bundle?"bundle ":"",
                    $nghttpx_h3);
     logmsg sprintf("%s\n", $libtool?"Libtool ":"");
     logmsg ("* Seed: $randseed\n");
@@ -2240,6 +2241,10 @@ while(@ARGV) {
         $ACURL=shell_quote($ARGV[1]);
         shift @ARGV;
     }
+    elsif ($ARGV[0] eq "-bundle") {
+        # use test bundles
+        $bundle=1;
+    }
     elsif ($ARGV[0] eq "-d") {
         # have the servers display protocol output
         $debugprotocol=1;
@@ -2417,6 +2422,7 @@ Usage: runtests.pl [options] [test selection(s)]
   -a       continue even if a test fails
   -ac path use this curl only to talk to APIs (currently only CI test APIs)
   -am      automake style output PASS/FAIL: [number] [name]
+  -bundle  use test bundles
   -c path  use this curl executable
   -d       display server debug info
   -e       event-based execution
index 8f0bb90bdf5ad0909cb5cb528444c4faddd0d549..a91670e0d5a69059daa81f67b4216b29fffd0991 100644 (file)
@@ -3,3 +3,4 @@
 # SPDX-License-Identifier: curl
 
 /unit[0-9][0-9][0-9][0-9]
+units.c
index 1e04b99599b28fae5c47dc9cbba6a32924a3b307..9540fcdcd2203a6882a8a434fa8d3c29e4c4a481 100644 (file)
 #
 ###########################################################################
 
-# Get 'UNITPROGS', 'UNITFILES' variables
+# Get 'UNITPROGS', '*_SOURCES', 'FIRSTFILES' variables
 transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
 include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
 
+if(CURL_TEST_BUNDLES)
+  add_custom_command(
+    OUTPUT "unit_bundle.c"
+    COMMAND ${PERL_EXECUTABLE} "${CURL_SOURCE_DIR}/tests/mk-bundle.pl" "${CMAKE_CURRENT_SOURCE_DIR}" > "unit_bundle.c"
+    DEPENDS
+      "${CURL_SOURCE_DIR}/tests/mk-bundle.pl" ${FIRSTFILES}
+      "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc"
+    VERBATIM)
+
+  set(UNITPROGS "units")
+  set(units_SOURCES "unit_bundle.c")
+endif()
+
 foreach(_target IN LISTS UNITPROGS)
   set(_target_name "${_target}")
-  add_executable(${_target_name} EXCLUDE_FROM_ALL "${_target}.c" ${UNITFILES})
+  add_executable(${_target_name} EXCLUDE_FROM_ALL ${${_target}_SOURCES})
   add_dependencies(testdeps ${_target_name})
   target_link_libraries(${_target_name} curltool curlu)
   target_include_directories(${_target_name} PRIVATE
@@ -37,6 +50,9 @@ foreach(_target IN LISTS UNITPROGS)
     "${CURL_SOURCE_DIR}/src"
     "${CURL_SOURCE_DIR}/tests/libtest"
   )
+  if(CURL_TEST_BUNDLES)
+    target_include_directories(${_target_name} PRIVATE "${CURL_SOURCE_DIR}/tests/unit")
+  endif()
   set_target_properties(${_target_name} PROPERTIES
     OUTPUT_NAME "${_target}"
     PROJECT_LABEL "Test unit ${_target}")
index ff05e1d5ac2c189667890889e7ba830348289928..b00189dd63bc0dd8cf146228d364a28edcb6624f 100644 (file)
@@ -36,7 +36,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include        \
               -I$(top_builddir)/lib          \
               -I$(top_srcdir)/lib            \
               -I$(top_srcdir)/src            \
-              -I$(top_srcdir)/tests/libtest
+              -I$(top_srcdir)/tests/libtest  \
+              -I$(top_srcdir)/tests/unit
 
 EXTRA_DIST = CMakeLists.txt README.md
 
@@ -51,19 +52,27 @@ LDADD = $(top_builddir)/src/libcurltool.la   \
 
 AM_CPPFLAGS += -DCURL_STATICLIB -DUNITTESTS
 
-CHECKSRC = $(CS_$(V))
-CS_0 = @echo "  RUN     " $@;
-CS_1 =
-CS_ = $(CS_0)
-
-checksrc:
-       $(CHECKSRC)@PERL@ $(top_srcdir)/scripts/checksrc.pl $(srcdir)/*.[ch]
+if BUILD_UNITTESTS
+if USE_TEST_BUNDLES
+unit_bundle.c: $(top_srcdir)/tests/mk-bundle.pl
+       @PERL@ $(top_srcdir)/tests/mk-bundle.pl $(srcdir) > unit_bundle.c
 
+noinst_PROGRAMS = units
+nodist_units_SOURCES = unit_bundle.c
+CLEANFILES = unit_bundle.c
+else
 # Makefile.inc provides neat definitions
 include Makefile.inc
-
-if BUILD_UNITTESTS
 noinst_PROGRAMS = $(UNITPROGS)
+endif
 else
 noinst_PROGRAMS =
 endif
+
+CHECKSRC = $(CS_$(V))
+CS_0 = @echo "  RUN     " $@;
+CS_1 =
+CS_ = $(CS_0)
+
+checksrc:
+       $(CHECKSRC)@PERL@ $(top_srcdir)/scripts/checksrc.pl $(srcdir)/*.[ch]
index 5b23c2559280f05e840659c00f1239eace1b1236..d17540bceaff447fbd06f830ebab234250c8959a 100644 (file)
 
 # these files are used in every single unit test program
 
-UNITFILES = curlcheck.h \
- ../libtest/test.h \
- ../libtest/first.c
+FIRSTFILES = \
+ ../libtest/first.c \
+ ../libtest/first.h
+
+UNITFILES = curlcheck.h $(FIRSTFILES)
 
 # These are all unit test programs
 UNITPROGS = unit1300          unit1302 unit1303 unit1304 unit1305 unit1307 \
index cf3c9b07e69a496ceb205085d3daec4f2291960a..83c58177dba2aad547b3270d03d27891f5ac0663 100644 (file)
 #include "curl_base64.h"
 #include "memdebug.h" /* LAST include file */
 
-static struct Curl_easy *data;
+static struct Curl_easy *testdata;
 
 static CURLcode unit_setup(void)
 {
   CURLcode res = CURLE_OK;
 
   global_init(CURL_GLOBAL_ALL);
-  data = curl_easy_init();
-  if(!data) {
+  testdata = curl_easy_init();
+  if(!testdata) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
@@ -45,7 +45,7 @@ static CURLcode unit_setup(void)
 
 static void unit_stop(void)
 {
-  curl_easy_cleanup(data);
+  curl_easy_cleanup(testdata);
   curl_global_cleanup();
 }
 
index 65bba3bf4a051594cd833ab0bef80e6fdb47e3f3..93262706b3a5ddabbe9b008ba68422e44ae8e58d 100644 (file)
 #include "connect.h"
 #include "memdebug.h" /* LAST include file */
 
-static struct Curl_easy *data;
+static struct Curl_easy *testdata;
 
 static CURLcode unit_setup(void)
 {
   CURLcode res = CURLE_OK;
 
   global_init(CURL_GLOBAL_ALL);
-  data = curl_easy_init();
-  if(!data) {
+  testdata = curl_easy_init();
+  if(!testdata) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
@@ -44,7 +44,7 @@ static CURLcode unit_setup(void)
 
 static void unit_stop(void)
 {
-  curl_easy_cleanup(data);
+  curl_easy_cleanup(testdata);
   curl_global_cleanup();
 }
 
@@ -55,7 +55,8 @@ static void unit_stop(void)
 /* macro to set the pretended current time */
 #define NOW(x,y) now.tv_sec = x; now.tv_usec = y
 /* macro to set the millisecond based timeouts to use */
-#define TIMEOUTS(x,y) data->set.timeout = x; data->set.connecttimeout = y
+#define TIMEOUTS(x,y) testdata->set.timeout = x; \
+                      testdata->set.connecttimeout = y
 
 /*
  * To test:
@@ -136,16 +137,16 @@ UNITTEST_START
   };
 
   /* this is the pretended start time of the transfer */
-  data->progress.t_startsingle.tv_sec = BASE;
-  data->progress.t_startsingle.tv_usec = 0;
-  data->progress.t_startop.tv_sec = BASE;
-  data->progress.t_startop.tv_usec = 0;
+  testdata->progress.t_startsingle.tv_sec = BASE;
+  testdata->progress.t_startsingle.tv_usec = 0;
+  testdata->progress.t_startop.tv_sec = BASE;
+  testdata->progress.t_startop.tv_usec = 0;
 
   for(i = 0; i < sizeof(run)/sizeof(run[0]); i++) {
     timediff_t timeout;
     NOW(run[i].now_s, run[i].now_us);
     TIMEOUTS(run[i].timeout_ms, run[i].connecttimeout_ms);
-    timeout =  Curl_timeleft(data, &now, run[i].connecting);
+    timeout =  Curl_timeleft(testdata, &now, run[i].connecting);
     if(timeout != run[i].result)
       fail(run[i].comment);
   }
index 0288562c6f5285d7881a9a5c74ac27788b4101d2..2171c0736e8a4cdb2113db75d57a519bbae94bb6 100644 (file)
 
 #ifndef CURL_DISABLE_NETRC
 
-static char *login;
-static char *password;
+static char *s_login;
+static char *s_password;
 
 static CURLcode unit_setup(void)
 {
-  password = strdup("");
-  login = strdup("");
-  if(!password || !login) {
-    Curl_safefree(password);
-    Curl_safefree(login);
+  s_password = strdup("");
+  s_login = strdup("");
+  if(!s_password || !s_login) {
+    Curl_safefree(s_password);
+    Curl_safefree(s_login);
     return CURLE_OUT_OF_MEMORY;
   }
   return CURLE_OK;
@@ -44,8 +44,8 @@ static CURLcode unit_setup(void)
 
 static void unit_stop(void)
 {
-  Curl_safefree(password);
-  Curl_safefree(login);
+  Curl_safefree(s_password);
+  Curl_safefree(s_login);
 }
 
 UNITTEST_START
@@ -54,133 +54,133 @@ UNITTEST_START
   /*
    * Test a non existent host in our netrc file.
    */
-  result = Curl_parsenetrc("test.example.com", &login, &password, arg);
+  result = Curl_parsenetrc("test.example.com", &s_login, &s_password, arg);
   fail_unless(result == 1, "Host not found should return 1");
-  abort_unless(password != NULL, "returned NULL!");
-  fail_unless(password[0] == 0, "password should not have been changed");
-  abort_unless(login != NULL, "returned NULL!");
-  fail_unless(login[0] == 0, "login should not have been changed");
+  abort_unless(s_password != NULL, "returned NULL!");
+  fail_unless(s_password[0] == 0, "password should not have been changed");
+  abort_unless(s_login != NULL, "returned NULL!");
+  fail_unless(s_login[0] == 0, "login should not have been changed");
 
   /*
    * Test a non existent login in our netrc file.
    */
-  free(login);
-  login = strdup("me");
-  abort_unless(login != NULL, "returned NULL!");
-  result = Curl_parsenetrc("example.com", &login, &password, arg);
+  free(s_login);
+  s_login = strdup("me");
+  abort_unless(s_login != NULL, "returned NULL!");
+  result = Curl_parsenetrc("example.com", &s_login, &s_password, arg);
   fail_unless(result == 0, "Host should have been found");
-  abort_unless(password != NULL, "returned NULL!");
-  fail_unless(password[0] == 0, "password should not have been changed");
-  abort_unless(login != NULL, "returned NULL!");
-  fail_unless(strncmp(login, "me", 2) == 0,
+  abort_unless(s_password != NULL, "returned NULL!");
+  fail_unless(s_password[0] == 0, "password should not have been changed");
+  abort_unless(s_login != NULL, "returned NULL!");
+  fail_unless(strncmp(s_login, "me", 2) == 0,
               "login should not have been changed");
 
   /*
    * Test a non existent login and host in our netrc file.
    */
-  free(login);
-  login = strdup("me");
-  abort_unless(login != NULL, "returned NULL!");
-  result = Curl_parsenetrc("test.example.com", &login, &password, arg);
+  free(s_login);
+  s_login = strdup("me");
+  abort_unless(s_login != NULL, "returned NULL!");
+  result = Curl_parsenetrc("test.example.com", &s_login, &s_password, arg);
   fail_unless(result == 1, "Host not found should return 1");
-  abort_unless(password != NULL, "returned NULL!");
-  fail_unless(password[0] == 0, "password should not have been changed");
-  abort_unless(login != NULL, "returned NULL!");
-  fail_unless(strncmp(login, "me", 2) == 0,
+  abort_unless(s_password != NULL, "returned NULL!");
+  fail_unless(s_password[0] == 0, "password should not have been changed");
+  abort_unless(s_login != NULL, "returned NULL!");
+  fail_unless(strncmp(s_login, "me", 2) == 0,
               "login should not have been changed");
 
   /*
    * Test a non existent login (substring of an existing one) in our
    * netrc file.
    */
-  free(login);
-  login = strdup("admi");
-  abort_unless(login != NULL, "returned NULL!");
-  result = Curl_parsenetrc("example.com", &login, &password, arg);
+  free(s_login);
+  s_login = strdup("admi");
+  abort_unless(s_login != NULL, "returned NULL!");
+  result = Curl_parsenetrc("example.com", &s_login, &s_password, arg);
   fail_unless(result == 0, "Host should have been found");
-  abort_unless(password != NULL, "returned NULL!");
-  fail_unless(password[0] == 0, "password should not have been changed");
-  abort_unless(login != NULL, "returned NULL!");
-  fail_unless(strncmp(login, "admi", 4) == 0,
+  abort_unless(s_password != NULL, "returned NULL!");
+  fail_unless(s_password[0] == 0, "password should not have been changed");
+  abort_unless(s_login != NULL, "returned NULL!");
+  fail_unless(strncmp(s_login, "admi", 4) == 0,
               "login should not have been changed");
 
   /*
    * Test a non existent login (superstring of an existing one)
    * in our netrc file.
    */
-  free(login);
-  login = strdup("adminn");
-  abort_unless(login != NULL, "returned NULL!");
-  result = Curl_parsenetrc("example.com", &login, &password, arg);
+  free(s_login);
+  s_login = strdup("adminn");
+  abort_unless(s_login != NULL, "returned NULL!");
+  result = Curl_parsenetrc("example.com", &s_login, &s_password, arg);
   fail_unless(result == 0, "Host should have been found");
-  abort_unless(password != NULL, "returned NULL!");
-  fail_unless(password[0] == 0, "password should not have been changed");
-  abort_unless(login != NULL, "returned NULL!");
-  fail_unless(strncmp(login, "adminn", 6) == 0,
+  abort_unless(s_password != NULL, "returned NULL!");
+  fail_unless(s_password[0] == 0, "password should not have been changed");
+  abort_unless(s_login != NULL, "returned NULL!");
+  fail_unless(strncmp(s_login, "adminn", 6) == 0,
               "login should not have been changed");
 
   /*
    * Test for the first existing host in our netrc file
-   * with login[0] = 0.
+   * with s_login[0] = 0.
    */
-  free(login);
-  login = strdup("");
-  abort_unless(login != NULL, "returned NULL!");
-  result = Curl_parsenetrc("example.com", &login, &password, arg);
+  free(s_login);
+  s_login = strdup("");
+  abort_unless(s_login != NULL, "returned NULL!");
+  result = Curl_parsenetrc("example.com", &s_login, &s_password, arg);
   fail_unless(result == 0, "Host should have been found");
-  abort_unless(password != NULL, "returned NULL!");
-  fail_unless(strncmp(password, "passwd", 6) == 0,
+  abort_unless(s_password != NULL, "returned NULL!");
+  fail_unless(strncmp(s_password, "passwd", 6) == 0,
               "password should be 'passwd'");
-  abort_unless(login != NULL, "returned NULL!");
-  fail_unless(strncmp(login, "admin", 5) == 0, "login should be 'admin'");
+  abort_unless(s_login != NULL, "returned NULL!");
+  fail_unless(strncmp(s_login, "admin", 5) == 0, "login should be 'admin'");
 
   /*
    * Test for the first existing host in our netrc file
-   * with login[0] != 0.
+   * with s_login[0] != 0.
    */
-  free(password);
-  password = strdup("");
-  abort_unless(password != NULL, "returned NULL!");
-  result = Curl_parsenetrc("example.com", &login, &password, arg);
+  free(s_password);
+  s_password = strdup("");
+  abort_unless(s_password != NULL, "returned NULL!");
+  result = Curl_parsenetrc("example.com", &s_login, &s_password, arg);
   fail_unless(result == 0, "Host should have been found");
-  abort_unless(password != NULL, "returned NULL!");
-  fail_unless(strncmp(password, "passwd", 6) == 0,
+  abort_unless(s_password != NULL, "returned NULL!");
+  fail_unless(strncmp(s_password, "passwd", 6) == 0,
               "password should be 'passwd'");
-  abort_unless(login != NULL, "returned NULL!");
-  fail_unless(strncmp(login, "admin", 5) == 0, "login should be 'admin'");
+  abort_unless(s_login != NULL, "returned NULL!");
+  fail_unless(strncmp(s_login, "admin", 5) == 0, "login should be 'admin'");
 
   /*
    * Test for the second existing host in our netrc file
-   * with login[0] = 0.
+   * with s_login[0] = 0.
    */
-  free(password);
-  password = strdup("");
-  abort_unless(password != NULL, "returned NULL!");
-  free(login);
-  login = strdup("");
-  abort_unless(login != NULL, "returned NULL!");
-  result = Curl_parsenetrc("curl.example.com", &login, &password, arg);
+  free(s_password);
+  s_password = strdup("");
+  abort_unless(s_password != NULL, "returned NULL!");
+  free(s_login);
+  s_login = strdup("");
+  abort_unless(s_login != NULL, "returned NULL!");
+  result = Curl_parsenetrc("curl.example.com", &s_login, &s_password, arg);
   fail_unless(result == 0, "Host should have been found");
-  abort_unless(password != NULL, "returned NULL!");
-  fail_unless(strncmp(password, "none", 4) == 0,
+  abort_unless(s_password != NULL, "returned NULL!");
+  fail_unless(strncmp(s_password, "none", 4) == 0,
               "password should be 'none'");
-  abort_unless(login != NULL, "returned NULL!");
-  fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'");
+  abort_unless(s_login != NULL, "returned NULL!");
+  fail_unless(strncmp(s_login, "none", 4) == 0, "login should be 'none'");
 
   /*
    * Test for the second existing host in our netrc file
-   * with login[0] != 0.
+   * with s_login[0] != 0.
    */
-  free(password);
-  password = strdup("");
-  abort_unless(password != NULL, "returned NULL!");
-  result = Curl_parsenetrc("curl.example.com", &login, &password, arg);
+  free(s_password);
+  s_password = strdup("");
+  abort_unless(s_password != NULL, "returned NULL!");
+  result = Curl_parsenetrc("curl.example.com", &s_login, &s_password, arg);
   fail_unless(result == 0, "Host should have been found");
-  abort_unless(password != NULL, "returned NULL!");
-  fail_unless(strncmp(password, "none", 4) == 0,
+  abort_unless(s_password != NULL, "returned NULL!");
+  fail_unless(strncmp(s_password, "none", 4) == 0,
               "password should be 'none'");
-  abort_unless(login != NULL, "returned NULL!");
-  fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'");
+  abort_unless(s_login != NULL, "returned NULL!");
+  fail_unless(strncmp(s_login, "none", 4) == 0, "login should be 'none'");
 
 UNITTEST_STOP
 
index ad8c85c442ba7c42d4cee0e5c98c85d5095be7a5..03011a577a9acfaeaffcc7724918ed98bf75d13a 100644 (file)
 
 #include "memdebug.h" /* LAST include file */
 
-static struct Curl_easy *data;
+static struct Curl_easy *testdata;
 static struct Curl_hash hp;
 static char *data_key;
 static struct Curl_dns_entry *data_node;
 
 static CURLcode unit_setup(void)
 {
-  data = curl_easy_init();
-  if(!data) {
+  testdata = curl_easy_init();
+  if(!testdata) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
@@ -66,7 +66,7 @@ static void unit_stop(void)
   free(data_key);
   Curl_hash_destroy(&hp);
 
-  curl_easy_cleanup(data);
+  curl_easy_cleanup(testdata);
   curl_global_cleanup();
 }
 
index 696eb023bdff18a1408efada83db17214d56e77a..b73288518f8dd8dd8894897f86a87ac0bca8ab57 100644 (file)
  * SPDX-License-Identifier: curl
  *
  ***************************************************************************/
-#define CURL_NO_FMT_CHECKS
-
 #include "curlcheck.h"
 
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat"
+#endif
+
 static CURLcode unit_setup(void) {return CURLE_OK;}
 static void unit_stop(void) {}
 
@@ -182,3 +185,7 @@ rc = curl_msnprintf(output, 129,
 fail_unless(rc == 128, "return code should be 128");
 
 UNITTEST_STOP
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
index faa89415573db673b8da6cb7f230ecfdf41c3b6d..b7f557d6898f577905c5c466c2bee2106a19eb7f 100644 (file)
@@ -26,7 +26,7 @@
 #include "speedcheck.h"
 #include "urldata.h"
 
-static CURL *easy;
+static struct Curl_easy *easy;
 
 static CURLcode unit_setup(void)
 {
index e7e1643c553c6dfd8e12e7036a4df44b1c24bd67..0052d0d68022d843ad7c735fc01626f63f6faf4e 100644 (file)
  * SPDX-License-Identifier: curl
  *
  ***************************************************************************/
-#define CURL_NO_FMT_CHECKS
-
 #include "curlcheck.h"
 
 #include "urldata.h"
 #include "sendf.h"
 
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat"
+#pragma GCC diagnostic ignored "-Wformat-zero-length"
+#endif
+
 /*
  * This test hardcodes the knowledge of the buffer size which is internal to
  * Curl_infof(). If that buffer is changed in size, this tests needs to be
  * updated to still be valid.
  */
 
-static struct Curl_easy *data;
+static struct Curl_easy *testdata;
 
 static char input[4096];
 static char output[4096];
@@ -66,20 +70,20 @@ unit_setup(void)
   CURLcode res = CURLE_OK;
 
   global_init(CURL_GLOBAL_ALL);
-  data = curl_easy_init();
-  if(!data) {
+  testdata = curl_easy_init();
+  if(!testdata) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
-  curl_easy_setopt(data, CURLOPT_DEBUGFUNCTION, debugf_cb);
-  curl_easy_setopt(data, CURLOPT_VERBOSE, 1L);
+  curl_easy_setopt(testdata, CURLOPT_DEBUGFUNCTION, debugf_cb);
+  curl_easy_setopt(testdata, CURLOPT_VERBOSE, 1L);
   return res;
 }
 
 static void
 unit_stop(void)
 {
-  curl_easy_cleanup(data);
+  curl_easy_cleanup(testdata);
   curl_global_cleanup();
 }
 
@@ -96,24 +100,24 @@ UNITTEST_START
 
 /* Injecting a simple short string via a format */
 msnprintf(input, sizeof(input), "Simple Test");
-Curl_infof(data, "%s", input);
+Curl_infof(testdata, "%s", input);
 fail_unless(verify(output, input) == 0, "Simple string test");
 
 /* Injecting a few different variables with a format */
-Curl_infof(data, "%s %u testing %lu", input, 42, 43L);
+Curl_infof(testdata, "%s %u testing %lu", input, 42, 43L);
 fail_unless(verify(output, "Simple Test 42 testing 43\n") == 0,
             "Format string");
 
 /* Variations of empty strings */
-Curl_infof(data, "");
+Curl_infof(testdata, "");
 fail_unless(strlen(output) == 1, "Empty string");
-Curl_infof(data, "%s", (char *)NULL);
+Curl_infof(testdata, "%s", (char *)NULL);
 fail_unless(verify(output, "(nil)") == 0, "Passing NULL as string");
 
 /* A string just long enough to not be truncated */
 memset(input, '\0', sizeof(input));
 memset(input, 'A', 2047);
-Curl_infof(data, "%s", input);
+Curl_infof(testdata, "%s", input);
 fail_unless(strlen(output) == 2048, "No truncation of infof input");
 fail_unless(verify(output, input) == 0, "No truncation of infof input");
 fail_unless(output[sizeof(output) - 1] == '\0',
@@ -121,22 +125,26 @@ fail_unless(output[sizeof(output) - 1] == '\0',
 
 /* Just over the limit without newline for truncation via '...' */
 memset(input + 2047, 'A', 4);
-Curl_infof(data, "%s", input);
+Curl_infof(testdata, "%s", input);
 fail_unless(strlen(output) == 2051, "Truncation of infof input 1");
 fail_unless(output[sizeof(output) - 1] == '\0', "Truncation of infof input 1");
 
 /* Just over the limit with newline for truncation via '...' */
 memset(input + 2047, 'A', 4);
 memset(input + 2047 + 4, '\n', 1);
-Curl_infof(data, "%s", input);
+Curl_infof(testdata, "%s", input);
 fail_unless(strlen(output) == 2051, "Truncation of infof input 2");
 fail_unless(output[sizeof(output) - 1] == '\0', "Truncation of infof input 2");
 
 /* Way over the limit for truncation via '...' */
 memset(input, '\0', sizeof(input));
 memset(input, 'A', sizeof(input) - 1);
-Curl_infof(data, "%s", input);
+Curl_infof(testdata, "%s", input);
 fail_unless(strlen(output) == 2051, "Truncation of infof input 3");
 fail_unless(output[sizeof(output) - 1] == '\0', "Truncation of infof input 3");
 
 UNITTEST_STOP
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
index 265e483b5a32fde64f72932c91696df4e74a561e..4ba57e4c54d2d909c7b20e226e29e90b7e6805f6 100644 (file)
@@ -44,6 +44,7 @@ static CURLcode unit_setup(void)
 
 static void unit_stop(void)
 {
+  Curl_bufref_free(&bufref);
 }
 
 UNITTEST_START
index e7fe621666c349fd42c4d564aeac69d39a69cf09..6967c0231f06e986d79f31146dec7cd1529900e9 100644 (file)
@@ -49,7 +49,7 @@ static void unit_stop(void)
 }
 
 static void test_parse(
-  const char *input,
+  const char *input_data,
   const char *exp_dev,
   const char *exp_iface,
   const char *exp_host,
@@ -58,7 +58,7 @@ static void test_parse(
   char *dev = NULL;
   char *iface = NULL;
   char *host = NULL;
-  CURLcode rc = Curl_parse_interface(input, &dev, &iface, &host);
+  CURLcode rc = Curl_parse_interface(input_data, &dev, &iface, &host);
   fail_unless(rc == exp_rc, "Curl_parse_interface() failed");
 
   fail_unless(!!exp_dev == !!dev, "dev expectation failed.");