From: Viktor Szakats Date: Sun, 4 Aug 2024 15:18:39 +0000 (+0200) Subject: cmake: add Linux CI job, fix pytest with cmake X-Git-Tag: curl-8_10_0~369 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=232302f88a152a1d1722da9f69c383a766528918;p=thirdparty%2Fcurl.git cmake: add Linux CI job, fix pytest with cmake - extend existing Linux workflow with CMake support. Including running pytest the first time with CMake. - cmake: generate `tests/config` and `tests/http/config.ini`. Required for pytest tests. Uses basic detection logic. Feel free to take it from here. Also dump config files in a CI step for debugging purposes. - cmake: build `tests/http/clients` programs. - fix portability issues with `tests/http/clients` programs. Some of them use `getopt()`, which is not supported by MSVC. Fix the rest to compile in CI (old-mingw-w64, MSVC, Windows). - GHA/linux: add CMake job matching an existing autotools one. - GHA/linux: test `-DCURL_LIBCURL_VERSIONED_SYMBOLS=ON` in the new CMake job. - reorder testdeps to build server, client tests first and then libtests and units, to catch errors in the more complex/unique sources earlier. - sort list in `tests/http/clients/Makefile.inc`. Closes #14382 --- diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index bde8fb60aa..bd5208c689 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -57,8 +57,8 @@ env: rustls-version: 0.13.0 jobs: - autotools: - name: ${{ matrix.build.name }} + linux: + name: ${{ matrix.build.generate && 'CM' || 'AM' }} ${{ matrix.build.name }} runs-on: 'ubuntu-latest' container: ${{ matrix.build.container }} timeout-minutes: 90 @@ -84,6 +84,12 @@ jobs: configure: LDFLAGS="-Wl,-rpath,$HOME/libressl/lib" --with-openssl=$HOME/libressl --enable-debug singleuse: --unit + - name: libressl + install_packages: zlib1g-dev valgrind + install_steps: libressl pytest + generate: -DOPENSSL_ROOT_DIR=$HOME/libressl -DENABLE_DEBUG=ON -DCURL_LIBCURL_VERSIONED_SYMBOLS=ON + singleuse: --unit + - name: libressl-clang install_packages: zlib1g-dev clang install_steps: libressl @@ -412,29 +418,57 @@ jobs: sudo make install - run: autoreconf -fi + if: ${{ matrix.build.configure }} name: 'autoreconf' - run: ./configure --disable-dependency-tracking --enable-warnings --enable-werror ${{ matrix.build.configure }} - name: 'configure' + if: ${{ matrix.build.configure }} + name: 'configure (autotools)' - - run: make V=1 + - run: | + cmake . \ + -DCMAKE_C_COMPILER_TARGET=$(uname -m)-pc-linux-gnu -DBUILD_STATIC_LIBS=ON \ + -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON \ + -DBUILD_EXAMPLES=ON \ + -DCURL_BROTLI=ON -DCURL_ZSTD=ON \ + ${{ matrix.build.generate }} + if: ${{ matrix.build.generate }} + name: 'configure (cmake)' + + - name: 'test configs' + run: | + cat tests/config || true + cat tests/http/config.ini || true + + - run: make V=1 VERBOSE=1 name: 'make' - run: | git config --global --add safe.directory "*" - ./scripts/singleuse.pl ${{ matrix.build.singleuse }} lib/.libs/libcurl.a + if [ -n '${{ matrix.build.generate }}' ]; then + libcurla=lib/libcurl.a + else + libcurla=lib/.libs/libcurl.a + fi + ./scripts/singleuse.pl ${{ matrix.build.singleuse }} ${libcurla} name: single-use function check - run: ./src/curl -V name: 'check curl -V output' - run: make V=1 examples + if: ${{ matrix.build.configure }} name: 'make examples' - run: make V=1 -C tests - name: 'make tests' + if: ${{ matrix.build.configure }} + name: 'make tests (autotools)' + + - run: make VERBOSE=1 testdeps + if: ${{ matrix.build.generate }} + name: 'make tests (cmake)' - - run: make V=1 test-ci + - run: make V=1 VERBOSE=1 test-ci name: 'run tests' env: TFLAGS: "${{ matrix.build.tflags }}" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dc75298efb..7df56918b1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,9 +23,18 @@ ########################################################################### set(CMAKE_UNITY_BUILD OFF) +find_program(TEST_NGHTTPX "nghttpx") +if(NOT TEST_NGHTTPX) + set(TEST_NGHTTPX "nghttpx") +endif() +# TEST_NGHTTPX +configure_file("config.in" "${CMAKE_CURRENT_BINARY_DIR}/config" @ONLY) + add_custom_target(testdeps) -add_subdirectory(libtest) +add_subdirectory(http) +add_subdirectory(http/clients) add_subdirectory(server) +add_subdirectory(libtest) add_subdirectory(unit) function(add_runtests targetname test_flags) diff --git a/tests/http/CMakeLists.txt b/tests/http/CMakeLists.txt new file mode 100644 index 0000000000..2ccf4cf852 --- /dev/null +++ b/tests/http/CMakeLists.txt @@ -0,0 +1,51 @@ +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### + +find_program(CADDY "caddy") # /usr/bin/caddy +if(NOT CADDY) + set(CADDY "") +endif() +find_program(VSFTPD "vsftpd") # /usr/sbin/vsftpd +if(NOT VSFTPD) + set(VSFTPD "") +endif() +find_program(HTTPD "apache2") # /usr/sbin/apache2 +if(NOT HTTPD) + set(HTTPD "") +endif() +find_program(APACHECTL "apache2ctl") # /usr/sbin/apache2ctl +if(NOT APACHECTL) + set(APACHECTL "") +endif() +find_program(APXS "apxs") +if(NOT APXS) + set(APXS "") +endif() +find_program(HTTPD_NGHTTPX "nghttpx" PATHS "/usr/bin" "/usr/local/bin") +if(NOT HTTPD_NGHTTPX) + set(HTTPD_NGHTTPX "") +endif() + +# APXS, HTTPD, APACHECTL, HTTPD_NGHTTPX, CADDY, VSFTPD +configure_file("config.ini.in" "${CMAKE_CURRENT_BINARY_DIR}/config.ini" @ONLY) diff --git a/tests/http/Makefile.am b/tests/http/Makefile.am index d9ab29686c..92652aa622 100644 --- a/tests/http/Makefile.am +++ b/tests/http/Makefile.am @@ -39,6 +39,7 @@ testenv/vsftpd.py \ testenv/ws_echo_server.py EXTRA_DIST = \ +CMakeLists.txt \ config.ini.in \ conftest.py \ requirements.txt \ diff --git a/tests/http/clients/CMakeLists.txt b/tests/http/clients/CMakeLists.txt new file mode 100644 index 0000000000..46d887adb4 --- /dev/null +++ b/tests/http/clients/CMakeLists.txt @@ -0,0 +1,44 @@ +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### + +# Get 'check_PROGRAMS' variable +transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") +include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") + +foreach(_client IN LISTS check_PROGRAMS) + set(_client_target "curl-test-client-${_client}") + add_executable(${_client_target} "${_client}.c") + add_dependencies(testdeps ${_client_target}) + target_include_directories(${_client_target} PRIVATE + "${CURL_SOURCE_DIR}/lib" # for "curl_setup_once.h" + "${CURL_BINARY_DIR}/lib" # for "curl_config.h" + "${CURL_BINARY_DIR}/include" # for "curl/curl.h" + ) + target_link_libraries(${_client_target} ${LIB_SELECTED} ${CURL_LIBS}) + target_compile_definitions(${_client_target} PRIVATE "CURL_NO_OLDIES") + if(LIB_SELECTED STREQUAL LIB_STATIC AND WIN32) + set_property(TARGET ${_client_target} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_STATICLIB") + endif() + set_target_properties(${_client_target} PROPERTIES OUTPUT_NAME "${_client}" UNITY_BUILD OFF) +endforeach() diff --git a/tests/http/clients/Makefile.am b/tests/http/clients/Makefile.am index 8fdc190b94..5395b22bfb 100644 --- a/tests/http/clients/Makefile.am +++ b/tests/http/clients/Makefile.am @@ -24,6 +24,7 @@ AUTOMAKE_OPTIONS = foreign nostdinc +EXTRA_DIST = CMakeLists.txt # Specify our include paths here, and do it relative to $(top_srcdir) and # $(top_builddir), to ensure that these paths which belong to the library @@ -59,7 +60,7 @@ endif # This might hold -Werror CFLAGS += @CURL_CFLAG_EXTRAS@ -# Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines +# Makefile.inc provides the check_PROGRAMS define include Makefile.inc all: $(check_PROGRAMS) diff --git a/tests/http/clients/Makefile.inc b/tests/http/clients/Makefile.inc index 07b6ae4aaf..e2ab2143b5 100644 --- a/tests/http/clients/Makefile.inc +++ b/tests/http/clients/Makefile.inc @@ -24,11 +24,11 @@ # These are all libcurl example programs to be test compiled check_PROGRAMS = \ - h2-serverpush \ h2-download \ - ws-data \ - ws-pingpong \ + h2-pausing \ + h2-serverpush \ h2-upgrade-extreme \ tls-session-reuse \ - h2-pausing \ - upload-pausing + upload-pausing \ + ws-data \ + ws-pingpong diff --git a/tests/http/clients/h2-download.c b/tests/http/clients/h2-download.c index 12af781de5..29745311cb 100644 --- a/tests/http/clients/h2-download.c +++ b/tests/http/clients/h2-download.c @@ -25,23 +25,27 @@ * HTTP/2 server push * */ - /* curl stuff */ #include -#include #include #include #include +#ifndef _MSC_VER /* somewhat Unix-specific */ -#include -#include +#include /* getopt() */ +#endif + +#ifdef _MSC_VER +#define snprintf _snprintf +#endif #ifndef CURLPIPE_MULTIPLEX #error "too old libcurl, cannot do HTTP/2 server push!" #endif +#ifndef _MSC_VER static int verbose = 1; static void log_line_start(FILE *log, const char *idsbuf, curl_infotype type) @@ -81,11 +85,10 @@ static int debug_cb(CURL *handle, curl_infotype type, if(!curl_easy_getinfo(handle, CURLINFO_XFER_ID, &xfer_id) && xfer_id >= 0) { if(!curl_easy_getinfo(handle, CURLINFO_CONN_ID, &conn_id) && conn_id >= 0) { - curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, - xfer_id, conn_id); + snprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, xfer_id, conn_id); } else { - curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id); + snprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id); } } else @@ -181,8 +184,7 @@ static size_t my_write_cb(char *buf, size_t nitems, size_t buflen, fprintf(stderr, "[t-%d] RECV %ld bytes, total=%ld, pause_at=%ld\n", t->idx, (long)blen, (long)t->recv_size, (long)t->pause_at); if(!t->out) { - curl_msnprintf(t->filename, sizeof(t->filename)-1, "download_%u.data", - t->idx); + snprintf(t->filename, sizeof(t->filename)-1, "download_%u.data", t->idx); t->out = fopen(t->filename, "wb"); if(!t->out) return 0; @@ -272,12 +274,14 @@ static void usage(const char *msg) " -V http_version (http/1.1, h2, h3) http version to use\n" ); } +#endif /* !_MSC_VER */ /* * Download a file over HTTP/2, take care of server push. */ int main(int argc, char *argv[]) { +#ifndef _MSC_VER CURLM *multi_handle; struct CURLMsg *m; const char *url; @@ -477,4 +481,10 @@ int main(int argc, char *argv[]) curl_multi_cleanup(multi_handle); return 0; +#else + (void)argc; + (void)argv; + fprintf(stderr, "Not supported with this compiler.\n"); + return 1; +#endif /* !_MSC_VER */ } diff --git a/tests/http/clients/h2-pausing.c b/tests/http/clients/h2-pausing.c index c12e8fab00..dd27b2ff2e 100644 --- a/tests/http/clients/h2-pausing.c +++ b/tests/http/clients/h2-pausing.c @@ -25,17 +25,25 @@ * HTTP/2 download pausing * */ -/* This is based on the poc client of issue #11982 +/* This is based on the PoC client of issue #11982 */ +#include + #include #include #include -#include -#include #include -#include -#include +#ifndef _MSC_VER +/* somewhat Unix-specific */ +#include /* getopt() */ +#endif + +#ifdef _MSC_VER +#define snprintf _snprintf +#endif + +#ifndef _MSC_VER #define HANDLECOUNT 2 static void log_line_start(FILE *log, const char *idsbuf, curl_infotype type) @@ -75,11 +83,10 @@ static int debug_cb(CURL *handle, curl_infotype type, if(!curl_easy_getinfo(handle, CURLINFO_XFER_ID, &xfer_id) && xfer_id >= 0) { if(!curl_easy_getinfo(handle, CURLINFO_CONN_ID, &conn_id) && conn_id >= 0) { - curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, - xfer_id, conn_id); + snprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, xfer_id, conn_id); } else { - curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id); + snprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id); } } else @@ -192,9 +199,11 @@ static size_t cb(void *data, size_t size, size_t nmemb, void *clientp) handle->idx, (long)realsize); return realsize; } +#endif /* !_MSC_VER */ int main(int argc, char *argv[]) { +#ifndef _MSC_VER struct handle handles[HANDLECOUNT]; CURLM *multi_handle; int i, still_running = 1, msgs_left, numfds; @@ -263,8 +272,7 @@ int main(int argc, char *argv[]) exit(1); } memset(&resolve, 0, sizeof(resolve)); - curl_msnprintf(resolve_buf, sizeof(resolve_buf)-1, - "%s:%s:127.0.0.1", host, port); + snprintf(resolve_buf, sizeof(resolve_buf)-1, "%s:%s:127.0.0.1", host, port); resolve = curl_slist_append(resolve, resolve_buf); for(i = 0; imsg == CURLMSG_DONE) { for(i = 0; ieasy_handle == handles[i].h) { @@ -394,4 +403,10 @@ out: curl_global_cleanup(); return rc; +#else + (void)argc; + (void)argv; + fprintf(stderr, "Not supported with this compiler.\n"); + return 1; +#endif /* !_MSC_VER */ } diff --git a/tests/http/clients/h2-serverpush.c b/tests/http/clients/h2-serverpush.c index a9b5537a5e..0055add615 100644 --- a/tests/http/clients/h2-serverpush.c +++ b/tests/http/clients/h2-serverpush.c @@ -25,23 +25,21 @@ * HTTP/2 server push * */ - /* curl stuff */ #include -#include #include #include #include -/* somewhat Unix-specific */ -#include -#include - #ifndef CURLPIPE_MULTIPLEX #error "too old libcurl, cannot do HTTP/2 server push!" #endif +#ifdef _MSC_VER +#define snprintf _snprintf +#endif + static void dump(const char *text, unsigned char *ptr, size_t size, char nohex) @@ -172,7 +170,7 @@ static int server_push_callback(CURL *parent, int rv; (void)parent; /* we have no use for this */ - curl_msnprintf(filename, sizeof(filename)-1, "push%u", count++); + snprintf(filename, sizeof(filename)-1, "push%u", count++); /* here's a new stream, save it in a new file for each new push */ out = fopen(filename, "wb"); diff --git a/tests/http/clients/h2-upgrade-extreme.c b/tests/http/clients/h2-upgrade-extreme.c index e15e34ce0a..697362f974 100644 --- a/tests/http/clients/h2-upgrade-extreme.c +++ b/tests/http/clients/h2-upgrade-extreme.c @@ -25,15 +25,16 @@ * HTTP/2 Upgrade test * */ +#include + #include #include -#include -#include /* #include */ #include -#include -#include +#ifdef _MSC_VER +#define snprintf _snprintf +#endif static void log_line_start(FILE *log, const char *idsbuf, curl_infotype type) { @@ -72,11 +73,10 @@ static int debug_cb(CURL *handle, curl_infotype type, if(!curl_easy_getinfo(handle, CURLINFO_XFER_ID, &xfer_id) && xfer_id >= 0) { if(!curl_easy_getinfo(handle, CURLINFO_CONN_ID, &conn_id) && conn_id >= 0) { - curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, - xfer_id, conn_id); + snprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, xfer_id, conn_id); } else { - curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id); + snprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id); } } else @@ -181,8 +181,7 @@ int main(int argc, char *argv[]) curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, write_cb); curl_easy_setopt(easy, CURLOPT_WRITEDATA, NULL); curl_easy_setopt(easy, CURLOPT_HTTPGET, 1L); - curl_msnprintf(range, sizeof(range), "%" PRIu64 "-%" PRIu64, - UINT64_C(0), UINT64_C(16384)); + snprintf(range, sizeof(range), "%d-%d", 0, 16384); curl_easy_setopt(easy, CURLOPT_RANGE, range); mc = curl_multi_add_handle(multi, easy); @@ -211,7 +210,8 @@ int main(int argc, char *argv[]) } /* Check for finished handles and remove. */ - while((msg = curl_multi_info_read(multi, &msgs_in_queue))) { + /* !checksrc! disable EQUALSNULL 1 */ + while((msg = curl_multi_info_read(multi, &msgs_in_queue)) != NULL) { if(msg->msg == CURLMSG_DONE) { long status = 0; curl_off_t xfer_id; diff --git a/tests/http/clients/tls-session-reuse.c b/tests/http/clients/tls-session-reuse.c index 2750ba7776..97ec862c8b 100644 --- a/tests/http/clients/tls-session-reuse.c +++ b/tests/http/clients/tls-session-reuse.c @@ -25,16 +25,17 @@ * TLS session reuse * */ +#include + #include #include -#include #include -#include /* #include */ #include -#include -#include +#ifdef _MSC_VER +#define snprintf _snprintf +#endif static void log_line_start(FILE *log, const char *idsbuf, curl_infotype type) { @@ -73,11 +74,10 @@ static int debug_cb(CURL *handle, curl_infotype type, if(!curl_easy_getinfo(handle, CURLINFO_XFER_ID, &xfer_id) && xfer_id >= 0) { if(!curl_easy_getinfo(handle, CURLINFO_CONN_ID, &conn_id) && conn_id >= 0) { - curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, - xfer_id, conn_id); + snprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, xfer_id, conn_id); } else { - curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id); + snprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id); } } else @@ -222,9 +222,8 @@ int main(int argc, char *argv[]) exit(1); } - memset(&resolve, 0, sizeof(resolve)); - curl_msnprintf(resolve_buf, sizeof(resolve_buf)-1, - "%s:%s:127.0.0.1", host, port); + memset(&resolve, 0, sizeof(resolve)); + snprintf(resolve_buf, sizeof(resolve_buf)-1, "%s:%s:127.0.0.1", host, port); curl_slist_append(&resolve, resolve_buf); multi = curl_multi_init(); @@ -274,7 +273,8 @@ int main(int argc, char *argv[]) } /* Check for finished handles and remove. */ - while((msg = curl_multi_info_read(multi, &msgs_in_queue))) { + /* !checksrc! disable EQUALSNULL 1 */ + while((msg = curl_multi_info_read(multi, &msgs_in_queue)) != NULL) { if(msg->msg == CURLMSG_DONE) { long status = 0; curl_off_t xfer_id; diff --git a/tests/http/clients/upload-pausing.c b/tests/http/clients/upload-pausing.c index 58f3c9118f..80c030b89c 100644 --- a/tests/http/clients/upload-pausing.c +++ b/tests/http/clients/upload-pausing.c @@ -25,16 +25,24 @@ * upload pausing * */ -/* This is based on the poc client of issue #11769 +/* This is based on the PoC client of issue #11769 */ +#include + #include #include -#include -#include #include -#include -#include +#ifndef _MSC_VER +/* somewhat Unix-specific */ +#include /* getopt() */ +#endif + +#ifdef _MSC_VER +#define snprintf _snprintf +#endif + +#ifndef _MSC_VER static void log_line_start(FILE *log, const char *idsbuf, curl_infotype type) { /* @@ -72,11 +80,10 @@ static int debug_cb(CURL *handle, curl_infotype type, if(!curl_easy_getinfo(handle, CURLINFO_XFER_ID, &xfer_id) && xfer_id >= 0) { if(!curl_easy_getinfo(handle, CURLINFO_CONN_ID, &conn_id) && conn_id >= 0) { - curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, - xfer_id, conn_id); + snprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, xfer_id, conn_id); } else { - curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id); + snprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id); } } else @@ -192,9 +199,11 @@ static void usage(const char *msg) " -V http_version (http/1.1, h2, h3) http version to use\n" ); } +#endif /* !_MSC_VER */ int main(int argc, char *argv[]) { +#ifndef _MSC_VER CURL *curl; CURLcode rc = CURLE_OK; CURLU *cu; @@ -254,8 +263,7 @@ int main(int argc, char *argv[]) exit(1); } memset(&resolve, 0, sizeof(resolve)); - curl_msnprintf(resolve_buf, sizeof(resolve_buf)-1, - "%s:%s:127.0.0.1", host, port); + snprintf(resolve_buf, sizeof(resolve_buf)-1, "%s:%s:127.0.0.1", host, port); resolve = curl_slist_append(resolve, resolve_buf); curl = curl_easy_init(); @@ -306,4 +314,10 @@ int main(int argc, char *argv[]) curl_global_cleanup(); return (int)rc; +#else + (void)argc; + (void)argv; + fprintf(stderr, "Not supported with this compiler.\n"); + return 1; +#endif /* !_MSC_VER */ } diff --git a/tests/http/clients/ws-data.c b/tests/http/clients/ws-data.c index 183f982b16..d045c5d2cb 100644 --- a/tests/http/clients/ws-data.c +++ b/tests/http/clients/ws-data.c @@ -25,7 +25,6 @@ * Websockets data echos * */ - /* curl stuff */ #include "curl_setup.h" #include @@ -34,12 +33,17 @@ #include #include -/* somewhat Unix-specific */ -#include -#include - #ifdef USE_WEBSOCKETS +#ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#else +#include +#endif + static void dump(const char *text, unsigned char *ptr, size_t size, char nohex) @@ -112,7 +116,11 @@ static CURLcode recv_binary(CURL *curl, char *exp_data, size_t exp_len) result = curl_ws_recv(curl, recvbuf, sizeof(recvbuf), &nread, &frame); if(result == CURLE_AGAIN) { fprintf(stderr, "EAGAIN, sleep, try again\n"); +#ifdef _WIN32 + Sleep(100); +#else usleep(100*1000); +#endif continue; } fprintf(stderr, "ws: curl_ws_recv(offset=%ld, len=%ld) -> %d, %ld\n", diff --git a/tests/http/clients/ws-pingpong.c b/tests/http/clients/ws-pingpong.c index 31904712ff..c86d7daed8 100644 --- a/tests/http/clients/ws-pingpong.c +++ b/tests/http/clients/ws-pingpong.c @@ -25,7 +25,6 @@ * Websockets pingpong * */ - /* curl stuff */ #include "curl_setup.h" #include @@ -34,9 +33,14 @@ #include #include -/* somewhat Unix-specific */ +#ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#else #include -#include +#endif #ifdef USE_WEBSOCKETS @@ -102,7 +106,11 @@ static CURLcode pingpong(CURL *curl, const char *payload) fprintf(stderr, "Receive pong\n"); res = recv_pong(curl, payload); if(res == CURLE_AGAIN) { +#ifdef _WIN32 + Sleep(100); +#else usleep(100*1000); +#endif continue; } websocket_close(curl);