- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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
- run: cmake --install build --prefix $HOME/curl --strip
name: 'cmake install'
+
+ - run: cmake --build build --parallel --target testdeps
+ name: 'cmake build tests'
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 \
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 \
- 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
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
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
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
- 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)'
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'
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}
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 }}
[ '${{ 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 \
[ '${{ 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)" \
# 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 \
|| { 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
# 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 \
|| { 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
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 \
--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'
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 \
|| { 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
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 \
- 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'
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 \
"-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 \
'-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 \
- 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 \
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
-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
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
'-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= \
- 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
"-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}" \
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'
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'
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
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'
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'
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'
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'
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
# 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")
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
http2-server.pl \
http3-server.pl \
memanalyze.pl \
+ mk-bundle-hints.sh \
+ mk-bundle.pl \
negtelnetserver.py \
nghttpx.conf \
pathhelp.pm \
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
%feature
%keywords
@protocols
+ $bundle
);
}
use pathhelp qw(exe_ext);
# 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
lib[1234][0-9][0-9][0-9]
lib[56][0-9][0-9]
lib1521.c
+libtests.c
libauthretry
libntlmconnect
libprereq
#
###########################################################################
-# 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()
"${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)
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
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 =
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
# 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 \
*
***************************************************************************/
#include "test.h"
+#include "first.h"
#ifdef HAVE_LOCALE_H
# include <locale.h> /* for setlocale() */
{
char *URL;
CURLcode result;
+ int basearg;
+ test_func_t test_func;
#ifdef O_BINARY
# ifdef __HIGHC__
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
--- /dev/null
+#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 */
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 },
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");
#ifdef SINGLETEST
if(SINGLETEST == i)
#endif
- status |= onetest(curl, URL, params + i, i);
+ status |= onetest(curl, URL, testparams + i, i);
curl_easy_cleanup(curl);
}
#include "memdebug.h"
-static char data[]="dummy";
+static char testdata[]="dummy";
struct WriteThis {
char *readptr;
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);
#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;
#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");
#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);
}
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);
#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)
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);
#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);
}
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);
"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;
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;
}
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! */
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)
pthread_mutex_unlock(&lock);
- res_multi_wakeup(multi);
+ res_multi_wakeup(testmulti);
}
test_cleanup:
global_init(CURL_GLOBAL_ALL);
- multi_init(multi);
+ multi_init(testmulti);
url = 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 {
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;
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++)
#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;
}
***************************************************************************/
#include "test.h"
-static char data[]="mooaaa";
+static char testdata[]="mooaaa";
struct WriteThis {
size_t sizeleft;
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;
}
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)
{
}
/* 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;
/* 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 */
#include "memdebug.h"
-static const char *show[]={
+static const char *testdata[]={
"daTE",
"Server",
"content-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;
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);
#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 =
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;
#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 =
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")) {
if(result == CURLE_AGAIN)
/* crude busy-loop */
continue;
+ fclose(save);
printf("curl_ws_recv returned %d\n", result);
return;
}
#define THREAD_SIZE 16
#define PER_THREAD_SIZE 8
-struct Ctx
-{
+struct Ctx {
const char *URL;
CURLSH *share;
int result;
#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;
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];
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);
#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;
#ifdef LIB585
-static int counter;
+static int testcounter;
static curl_socket_t tst_opensocket(void *clientp,
curlsocktype purpose,
{
(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);
}
{
curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, tst_opensocket);
curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, tst_closesocket);
- counter = 0;
+ testcounter = 0;
}
#else
return res;
}
+
+#undef setupcallbacks
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;
}
/* 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;
/* the dummy thread function */
-static void *fire(void *ptr)
+static void *test_fire(void *ptr)
{
CURLcode code;
struct curl_slist *headers;
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");
/* simulate thread, direct call of "thread" function */
printf("*** run %d\n",i);
- fire(&tdata);
+ test_fire(&tdata);
curl_free(tdata.url);
}
#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;
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");
#include "memdebug.h"
-static const char *post[]={
+static const char * const testpost[]={
"one",
"two",
"three",
if(size*nmemb < 1)
return 0;
- data = post[pooh->counter];
+ data = testpost[pooh->counter];
if(data) {
size_t len = strlen(data);
#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
-static int *fd = NULL;
+static int *testfd = NULL;
static struct rlimit num_open;
static char msgbuff[256];
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)
}
}
-static int rlimit(int keep_open)
+static int test_rlimit(int keep_open)
{
rlim_t nitems, i;
int *memchunk = NULL;
* 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.
*/
/* 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);
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;
/* 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;
}
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);
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;
}
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);
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;
}
#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;
};
#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
-static int *fd = NULL;
+static int *testfd = NULL;
static struct rlimit num_open;
static char msgbuff[256];
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)
}
}
-static int rlimit(int keep_open)
+static int test_rlimit(int keep_open)
{
int *tmpfd;
rlim_t nitems, i;
* 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.
*/
/* 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);
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;
/* 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;
}
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);
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);
/* 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;
}
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);
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;
}
#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;
init_failed:
- curl_easy_cleanup(eh[num]);
- eh[num] = NULL;
+ curl_easy_cleanup(testeh[num]);
+ testeh[num] = NULL;
return res; /* failure */
}
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;
}
}
int i;
for(i = 0; i < NUM_HANDLES; i++)
- eh[i] = NULL;
+ testeh[i] = NULL;
start_test_timing();
/* 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);
#include "warnless.h"
#include "memdebug.h"
-struct data {
+struct testdata {
char trace_ascii; /* 1 or 0 */
};
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 */
{
CURL *curl;
CURLcode res = CURLE_OK;
- struct data config;
+ struct testdata config;
size_t i;
static const char fill[] = "test data";
#include "memdebug.h"
-static char data[]=
+static char testdata[]=
"this is what we post to the silly web server\n";
struct WriteThis {
#endif
}
-static CURLcode once(char *URL, bool oldstyle)
+static CURLcode test_once(char *URL, bool oldstyle)
{
CURL *curl;
CURLcode res = CURLE_OK;
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) {
/* 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 */
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();
* 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
else
return CURLE_OK;
}
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
#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)
/* 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(
#include "memdebug.h"
-static const char * const post[]={
+static const char * const testpost[]={
"one",
"two",
"three",
if(size*nmemb < 1)
return 0;
- data = post[pooh->counter];
+ data = testpost[pooh->counter];
if(data) {
size_t len = strlen(data);
#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;
};
};
/* 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;
}
/* 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;
}
/* the dummy thread function */
-static void *fire(void *ptr)
+static void *test_fire(void *ptr)
{
CURLcode code;
struct Tdata *tdata = (struct Tdata*)ptr;
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");
/* simulate thread, direct call of "thread" function */
printf("*** run %d\n",i);
- fire(&tdata);
+ test_fire(&tdata);
}
#include "memdebug.h"
-static char data[]=
+static char testdata[]=
"dummy\n";
struct WriteThis {
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;
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;
/* 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;
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();
#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
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);
)
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);
/* 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. */
#include "memdebug.h"
-static char buffer[17000]; /* more than 16K */
+static char testbuf[17000]; /* more than 16K */
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");
/* Check proper name and data copying. */
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, "hello",
- CURLFORM_COPYCONTENTS, buffer,
+ CURLFORM_COPYCONTENTS, testbuf,
CURLFORM_END);
)
if(formrc)
#include "memdebug.h"
-static char buffer[17000]; /* more than 16K */
+static char testbuf[17000]; /* more than 16K */
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");
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;
#include "memdebug.h"
-static char data[]=
+static char testdata[]=
"dummy\n";
struct WriteThis {
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. */
#include "memdebug.h"
-static char buffer[17000]; /* more than 16K */
+static char testbuf[17000]; /* more than 16K */
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");
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;
#include "memdebug.h"
-static char data[]=
+static char testdata[]=
"dummy";
struct WriteThis {
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);
#include "memdebug.h"
-static char data[]= "dummy";
+static char testdata[]= "dummy";
struct WriteThis {
char *readptr;
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. */
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");
#define PAUSE_TIME 5
-static const char name[] = "field";
+static const char testname[] = "field";
struct ReadThis {
CURL *easy;
/* 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",
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);
#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)
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;
}
pos += len;
else
pos = 0;
- if(pos == sizeof(cmd) - 1) {
+ if(pos == sizeof(testcmd) - 1) {
state++;
pos = 0;
}
#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)
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;
}
}
CURLcode test(char *url)
{
+ CURLcode res = CURLE_OK;
CURLM *multi = NULL;
int running;
int i;
}
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);
/* 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);
/* 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);
/* This source code is generated by mk-lib1521.pl ! */
-struct data {
+struct testdata {
char *blaha;
};
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;
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);
#define global_init(A) \
chk_global_init((A), (__FILE__), (__LINE__))
+#ifndef CURLTESTS_BUNDLED_TEST_H
#define NO_SUPPORT_BUILT_IN \
CURLcode test(char *URL) \
{ \
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
--- /dev/null
+#!/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
--- /dev/null
+#!/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
+ ;
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;
# 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;
}
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
"*\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");
$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;
-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
# SPDX-License-Identifier: curl
/unit[0-9][0-9][0-9][0-9]
+units.c
#
###########################################################################
-# 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
"${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}")
-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
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]
# 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 \
#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;
}
static void unit_stop(void)
{
- curl_easy_cleanup(data);
+ curl_easy_cleanup(testdata);
curl_global_cleanup();
}
#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;
}
static void unit_stop(void)
{
- curl_easy_cleanup(data);
+ curl_easy_cleanup(testdata);
curl_global_cleanup();
}
/* 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:
};
/* 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);
}
#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;
static void unit_stop(void)
{
- Curl_safefree(password);
- Curl_safefree(login);
+ Curl_safefree(s_password);
+ Curl_safefree(s_login);
}
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
#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;
}
free(data_key);
Curl_hash_destroy(&hp);
- curl_easy_cleanup(data);
+ curl_easy_cleanup(testdata);
curl_global_cleanup();
}
* 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) {}
fail_unless(rc == 128, "return code should be 128");
UNITTEST_STOP
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
#include "speedcheck.h"
#include "urldata.h"
-static CURL *easy;
+static struct Curl_easy *easy;
static CURLcode unit_setup(void)
{
* 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];
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();
}
/* 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',
/* 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
static void unit_stop(void)
{
+ Curl_bufref_free(&bufref);
}
UNITTEST_START
}
static void test_parse(
- const char *input,
+ const char *input_data,
const char *exp_dev,
const char *exp_iface,
const char *exp_host,
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.");