mirror of
https://github.com/curl/curl.git
synced 2026-07-23 21:37:41 +03:00
tests: always make bundles, adapt build and tests
Make test bundles the default. Drop non-bundle build mode.
Also do all the optimizations and tidy-ups this allows, simpler builds,
less bundle exceptions, streamlined build mechanics.
Also rework the init/deinit macro magic for unit tests. The new method
allows using unique init/deinit function names, and calling them with
arguments. This is in turn makes it possible to reduce the use of global
variables.
Note this drop existing build options `-DCURL_TEST_BUNDLES=` from cmake
and `--enable-test-bundles` / `--disable-test-bundles` from autotools.
Also:
- rename test entry functions to have unique names: `test_<testname>`
This removes the last exception that was handled in the generator.
- fix `make dist` to not miss test sources with test bundles enabled.
- sync and merge `tests/mk-bundle.pl` into `scripts/mk-unity.pl`.
- mk-unity.pl: add `--embed` option and use it when `CURL_CLANG_TIDY=ON`
to ensure that `clang-tidy` does not miss external test C sources.
(because `clang-tidy` ignores code that's #included.)
- tests/unit: drop no-op setup/stop functions.
- tests: reduce symbol scopes, global macros, other fixes and tidy-ups.
- tool1621: fix to run, also fix it to pass.
- sockfilt: fix Windows compiler warning in certain unity include order,
by explicitly including `warnless.h`.
Follow-up to 6897aeb105 #17468
Closes #17590
This commit is contained in:
parent
1cdac95e2e
commit
2c27a67daa
386 changed files with 2996 additions and 4164 deletions
11
tests/server/.gitignore
vendored
11
tests/server/.gitignore
vendored
|
|
@ -2,14 +2,5 @@
|
|||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
|
||||
server_bundle.c
|
||||
servers
|
||||
buildinfo
|
||||
dnsd
|
||||
mqttd
|
||||
resolve
|
||||
rtspd
|
||||
sockfilt
|
||||
socksd
|
||||
sws
|
||||
tftpd
|
||||
servers.c
|
||||
|
|
|
|||
|
|
@ -22,53 +22,43 @@
|
|||
#
|
||||
###########################################################################
|
||||
|
||||
# Get 'SERVERPROGS', '<target>_SOURCES' variables, 'MEMDEBUG', 'CURLX_SRCS', 'USEFUL', 'INET_PTON', 'UTIL', 'FIRSTFILES'
|
||||
# Get BUNDLE, BUNDLE_SRC, FIRSTFILES, UTILS, MEMDEBUG, CURLX_SRCS, TESTFILES variables
|
||||
curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
|
||||
include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${BUNDLE_SRC}"
|
||||
COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" --test ${TESTFILES}
|
||||
${CURL_MK_UNITY_OPTION} --srcdir "${CMAKE_CURRENT_SOURCE_DIR}" > "${BUNDLE_SRC}"
|
||||
DEPENDS
|
||||
"${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc" ${FIRSTFILES} ${TESTFILES}
|
||||
VERBATIM)
|
||||
|
||||
if(ENABLE_SERVER_DEBUG AND ENABLE_CURLDEBUG)
|
||||
set_source_files_properties("../../lib/memdebug.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
||||
endif()
|
||||
|
||||
if(CURL_TEST_BUNDLES)
|
||||
add_custom_command(
|
||||
OUTPUT "server_bundle.c"
|
||||
COMMAND ${PERL_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/mk-bundle.pl" ${SERVERPROGS} > "server_bundle.c"
|
||||
DEPENDS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mk-bundle.pl" ${FIRSTFILES}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc"
|
||||
VERBATIM)
|
||||
|
||||
set(SERVERPROGS "servers")
|
||||
set(servers_SOURCES ${MEMDEBUG} ${CURLX_SRCS} ${USEFUL} ${INET_PTON} ${UTIL} "server_bundle.c")
|
||||
add_executable(servers EXCLUDE_FROM_ALL ${MEMDEBUG} ${CURLX_SRCS} ${UTILS} "${BUNDLE_SRC}")
|
||||
add_dependencies(testdeps servers)
|
||||
target_include_directories(servers PRIVATE
|
||||
"${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"
|
||||
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h"
|
||||
"${PROJECT_SOURCE_DIR}/lib/curlx" # for curlx
|
||||
"${PROJECT_SOURCE_DIR}/src" # for "tool_binmode.h", "tool_xattr.h"
|
||||
"${PROJECT_SOURCE_DIR}/tests/server" # for "first.h"
|
||||
)
|
||||
target_link_libraries(servers ${CURL_LIBS})
|
||||
if(ENABLE_SERVER_DEBUG)
|
||||
set_property(TARGET servers APPEND PROPERTY COMPILE_DEFINITIONS "${CURL_DEBUG_MACROS}")
|
||||
endif()
|
||||
|
||||
foreach(_target IN LISTS SERVERPROGS)
|
||||
set(_target_name "${_target}")
|
||||
add_executable(${_target_name} EXCLUDE_FROM_ALL ${${_target}_SOURCES})
|
||||
add_dependencies(testdeps ${_target_name})
|
||||
target_include_directories(${_target_name} PRIVATE
|
||||
"${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"
|
||||
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h"
|
||||
"${PROJECT_SOURCE_DIR}/lib/curlx" # for curlx
|
||||
"${PROJECT_SOURCE_DIR}/src" # for "tool_binmode.h", "tool_xattr.h"
|
||||
"${PROJECT_SOURCE_DIR}/tests/server" # for "first.h"
|
||||
)
|
||||
target_link_libraries(${_target_name} ${CURL_LIBS})
|
||||
if(ENABLE_SERVER_DEBUG)
|
||||
set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "${CURL_DEBUG_MACROS}")
|
||||
endif()
|
||||
set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "WITHOUT_LIBCURL")
|
||||
# Test servers simply are standalone programs that do not use libcurl
|
||||
# library. For convenience and to ease portability of these servers,
|
||||
# some source code files from the libcurl subdirectory are also used
|
||||
# to build the servers. In order to achieve proper linkage of these
|
||||
# files on Windows targets it is necessary to build the test servers
|
||||
# with CURL_STATICLIB defined, independently of how libcurl is built.
|
||||
if(WIN32)
|
||||
set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_STATICLIB")
|
||||
endif()
|
||||
set_target_properties(${_target_name} PROPERTIES
|
||||
OUTPUT_NAME "${_target}"
|
||||
PROJECT_LABEL "Test server ${_target}")
|
||||
endforeach()
|
||||
set_property(TARGET servers APPEND PROPERTY COMPILE_DEFINITIONS "WITHOUT_LIBCURL" "CURL_NO_OLDIES")
|
||||
# Test servers simply are standalone programs that do not use libcurl
|
||||
# library. For convenience and to ease portability of these servers,
|
||||
# some source code files from the libcurl subdirectory are also used
|
||||
# to build the servers. In order to achieve proper linkage of these
|
||||
# files on Windows targets it is necessary to build the test servers
|
||||
# with CURL_STATICLIB defined, independently of how libcurl is built.
|
||||
if(WIN32)
|
||||
set_property(TARGET servers APPEND PROPERTY COMPILE_DEFINITIONS "CURL_STATICLIB")
|
||||
endif()
|
||||
set_target_properties(servers PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}")
|
||||
|
|
|
|||
|
|
@ -40,11 +40,16 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \
|
|||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/tests/server
|
||||
|
||||
# Prevent LIBS from being used for all link targets
|
||||
LIBS = $(BLANK_AT_MAKETIME)
|
||||
# Get BUNDLE, BUNDLE_SRC, FIRSTFILES, UTILS, MEMDEBUG, CURLX_SRCS, TESTFILES variables
|
||||
include Makefile.inc
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt .checksrc $(FIRSTFILES) $(UTILS) $(TESTFILES)
|
||||
|
||||
CFLAGS += @CURL_CFLAG_EXTRAS@
|
||||
|
||||
# Prevent LIBS from being used for all link targets
|
||||
LIBS = $(BLANK_AT_MAKETIME)
|
||||
|
||||
if DOING_NATIVE_WINDOWS
|
||||
AM_CPPFLAGS += -DCURL_STATICLIB
|
||||
endif
|
||||
|
|
@ -57,32 +62,23 @@ AM_CPPFLAGS += -DCURLDEBUG
|
|||
endif
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS += -DWITHOUT_LIBCURL
|
||||
AM_CPPFLAGS += -DWITHOUT_LIBCURL -DCURL_NO_OLDIES
|
||||
|
||||
# Makefile.inc provides neat definitions
|
||||
include Makefile.inc
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt .checksrc mk-bundle.pl $(FIRSTFILES)
|
||||
|
||||
if USE_TEST_BUNDLES
|
||||
server_EXCLUDE =
|
||||
bundle_EXCLUDE =
|
||||
if ENABLE_SERVER_DEBUG
|
||||
if CURLDEBUG
|
||||
server_EXCLUDE += $(MEMDEBUG)
|
||||
bundle_EXCLUDE += $(MEMDEBUG)
|
||||
endif
|
||||
endif
|
||||
server_bundle.c: $(top_srcdir)/tests/server/mk-bundle.pl $(MEMDEBUG) $(CURLX_SRCS) $(USEFUL) $(INET_PTON) $(UTIL) $(FIRSTFILES)
|
||||
@PERL@ $(top_srcdir)/tests/server/mk-bundle.pl $(MEMDEBUG) $(CURLX_SRCS) $(USEFUL) $(INET_PTON) $(UTIL) $(SERVERPROGS) --exclude $(server_EXCLUDE) > server_bundle.c
|
||||
$(BUNDLE_SRC): $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRSTFILES) $(UTILS) $(MEMDEBUG) $(CURLX_SRCS) $(TESTFILES)
|
||||
@PERL@ $(top_srcdir)/scripts/mk-unity.pl --include $(UTILS) $(MEMDEBUG) $(CURLX_SRCS) --test $(TESTFILES) --exclude $(bundle_EXCLUDE) > $(BUNDLE_SRC)
|
||||
|
||||
noinst_PROGRAMS = servers
|
||||
nodist_servers_SOURCES = server_bundle.c
|
||||
servers_SOURCES = $(server_EXCLUDE)
|
||||
noinst_PROGRAMS = $(BUNDLE)
|
||||
nodist_servers_SOURCES = $(BUNDLE_SRC)
|
||||
servers_SOURCES = $(bundle_EXCLUDE)
|
||||
servers_LDADD = @CURL_NETWORK_AND_TIME_LIBS@
|
||||
servers_CFLAGS = $(AM_CFLAGS)
|
||||
CLEANFILES = server_bundle.c
|
||||
else
|
||||
noinst_PROGRAMS = $(SERVERPROGS)
|
||||
endif
|
||||
CLEANFILES = $(BUNDLE_SRC)
|
||||
|
||||
CHECKSRC = $(CS_$(V))
|
||||
CS_0 = @echo " RUN " $@;
|
||||
|
|
@ -92,9 +88,12 @@ CS_ = $(CS_0)
|
|||
# ignore generated C files since they play by slightly different rules!
|
||||
checksrc:
|
||||
$(CHECKSRC)(@PERL@ $(top_srcdir)/scripts/checksrc.pl -D$(srcdir) \
|
||||
-W$(srcdir)/server_bundle.c \
|
||||
-W$(srcdir)/$(BUNDLE_SRC) \
|
||||
$(srcdir)/*.[ch])
|
||||
|
||||
if NOT_CURL_CI
|
||||
all-local: checksrc
|
||||
endif
|
||||
|
||||
clean-local:
|
||||
rm -f $(BUNDLE)
|
||||
|
|
|
|||
|
|
@ -21,8 +21,16 @@
|
|||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
###########################################################################
|
||||
# Shared between CMakeLists.txt and Makefile.am
|
||||
|
||||
SERVERPROGS = resolve rtspd sockfilt sws tftpd socksd mqttd dnsd
|
||||
BUNDLE = servers
|
||||
BUNDLE_SRC = servers.c
|
||||
|
||||
# Files referenced from the bundle source
|
||||
FIRSTFILES = first.c first.h
|
||||
|
||||
# Common files used by test programs
|
||||
UTILS = getpart.c getpart.h util.c util.h
|
||||
|
||||
MEMDEBUG = \
|
||||
../../lib/memdebug.c \
|
||||
|
|
@ -30,6 +38,7 @@ MEMDEBUG = \
|
|||
|
||||
CURLX_SRCS = \
|
||||
../../lib/curlx/base64.c \
|
||||
../../lib/curlx/inet_pton.c \
|
||||
../../lib/curlx/multibyte.c \
|
||||
../../lib/curlx/nonblock.c \
|
||||
../../lib/curlx/strparse.c \
|
||||
|
|
@ -39,74 +48,13 @@ CURLX_SRCS = \
|
|||
../../lib/curlx/warnless.c \
|
||||
../../lib/curlx/winapi.c
|
||||
|
||||
CURLX_HDRS = \
|
||||
../../lib/curlx/base64.h \
|
||||
../../lib/curlx/curlx.h \
|
||||
../../lib/curlx/multibyte.h \
|
||||
../../lib/curlx/nonblock.h \
|
||||
../../lib/curlx/timediff.h \
|
||||
../../lib/curlx/timeval.h \
|
||||
../../lib/curlx/version_win32.h \
|
||||
../../lib/curlx/warnless.h \
|
||||
../../lib/curlx/winapi.h
|
||||
|
||||
UTIL = \
|
||||
getpart.c \
|
||||
getpart.h \
|
||||
util.c \
|
||||
util.h \
|
||||
server_setup.h
|
||||
|
||||
FIRSTFILES = \
|
||||
first.c \
|
||||
first.h
|
||||
|
||||
INET_PTON = \
|
||||
../../lib/curlx/inet_pton.c
|
||||
|
||||
resolve_SOURCES = $(MEMDEBUG) $(CURLX_SRCS) $(CURLX_HDRS) $(UTIL) \
|
||||
resolve.c
|
||||
resolve_LDADD = @CURL_NETWORK_AND_TIME_LIBS@
|
||||
resolve_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
rtspd_SOURCES = $(MEMDEBUG) $(CURLX_SRCS) $(CURLX_HDRS) $(UTIL) \
|
||||
server_sockaddr.h \
|
||||
rtspd.c
|
||||
rtspd_LDADD = @CURL_NETWORK_AND_TIME_LIBS@
|
||||
rtspd_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
sockfilt_SOURCES = $(MEMDEBUG) $(CURLX_SRCS) $(CURLX_HDRS) $(UTIL) $(INET_PTON) \
|
||||
server_sockaddr.h \
|
||||
sockfilt.c
|
||||
sockfilt_LDADD = @CURL_NETWORK_AND_TIME_LIBS@
|
||||
sockfilt_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
socksd_SOURCES = $(MEMDEBUG) $(CURLX_SRCS) $(CURLX_HDRS) $(UTIL) $(INET_PTON) \
|
||||
server_sockaddr.h \
|
||||
socksd.c
|
||||
socksd_LDADD = @CURL_NETWORK_AND_TIME_LIBS@
|
||||
socksd_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
mqttd_SOURCES = $(MEMDEBUG) $(CURLX_SRCS) $(CURLX_HDRS) $(UTIL) \
|
||||
server_sockaddr.h \
|
||||
mqttd.c
|
||||
mqttd_LDADD = @CURL_NETWORK_AND_TIME_LIBS@
|
||||
mqttd_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
sws_SOURCES = $(MEMDEBUG) $(CURLX_SRCS) $(CURLX_HDRS) $(UTIL) $(INET_PTON) \
|
||||
server_sockaddr.h \
|
||||
sws.c
|
||||
sws_LDADD = @CURL_NETWORK_AND_TIME_LIBS@
|
||||
sws_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
tftpd_SOURCES = $(MEMDEBUG) $(CURLX_SRCS) $(CURLX_HDRS) $(UTIL) \
|
||||
server_sockaddr.h \
|
||||
tftpd.c \
|
||||
tftp.h
|
||||
tftpd_LDADD = @CURL_NETWORK_AND_TIME_LIBS@
|
||||
tftpd_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
dnsd_SOURCES = $(MEMDEBUG) $(CURLX_SRCS) $(CURLX_HDRS) $(UTIL) \
|
||||
dnsd.c
|
||||
dnsd_LDADD = @CURL_NETWORK_AND_TIME_LIBS@
|
||||
dnsd_CFLAGS = $(AM_CFLAGS)
|
||||
# All test servers
|
||||
TESTFILES = \
|
||||
dnsd.c \
|
||||
mqttd.c \
|
||||
resolve.c \
|
||||
rtspd.c \
|
||||
sockfilt.c \
|
||||
socksd.c \
|
||||
sws.c \
|
||||
tftpd.c
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
|
|
@ -54,7 +54,6 @@
|
|||
#include <curlx.h> /* from the private lib dir */
|
||||
#include "getpart.h"
|
||||
#include "util.h"
|
||||
#include "server_sockaddr.h"
|
||||
|
||||
/* include memdebug.h last */
|
||||
#include <memdebug.h>
|
||||
|
|
@ -385,7 +384,7 @@ static int send_response(curl_socket_t sock,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
static int test_dnsd(int argc, char **argv)
|
||||
{
|
||||
srvr_sockaddr_union_t me;
|
||||
ssize_t n = 0;
|
||||
|
|
|
|||
|
|
@ -23,37 +23,36 @@
|
|||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "first.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
main_func_t main_func;
|
||||
char *main_name;
|
||||
entry_func_t entry_func;
|
||||
char *entry_name;
|
||||
|
||||
if(argc < 2) {
|
||||
fprintf(stderr, "Pass servername as first argument\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
main_name = argv[1];
|
||||
main_func = NULL;
|
||||
entry_name = argv[1];
|
||||
entry_func = NULL;
|
||||
{
|
||||
size_t tmp;
|
||||
for(tmp = 0; tmp < CURL_ARRAYSIZE(s_mains); ++tmp) {
|
||||
if(strcmp(main_name, s_mains[tmp].name) == 0) {
|
||||
main_func = s_mains[tmp].ptr;
|
||||
for(tmp = 0; tmp < CURL_ARRAYSIZE(s_entries); ++tmp) {
|
||||
if(strcmp(entry_name, s_entries[tmp].name) == 0) {
|
||||
entry_func = s_entries[tmp].ptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!main_func) {
|
||||
fprintf(stderr, "Test '%s' not found.\n", main_name);
|
||||
if(!entry_func) {
|
||||
fprintf(stderr, "Test '%s' not found.\n", entry_name);
|
||||
return 99;
|
||||
}
|
||||
|
||||
--argc;
|
||||
++argv;
|
||||
|
||||
return main_func(argc, argv);
|
||||
return entry_func(argc, argv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
typedef int (*main_func_t)(int, char **);
|
||||
typedef int (*entry_func_t)(int, char **);
|
||||
|
||||
struct onemain {
|
||||
struct entry_s {
|
||||
const char *name;
|
||||
main_func_t ptr;
|
||||
entry_func_t ptr;
|
||||
};
|
||||
|
||||
#endif /* HEADER_SERVER_FIRST_H */
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
|
||||
#include "getpart.h"
|
||||
#include <curlx.h> /* from the private lib dir */
|
||||
|
|
@ -64,7 +64,6 @@ curl_wcsdup_callback Curl_cwcsdup = NULL; /* not use in test code */
|
|||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* line_length()
|
||||
*
|
||||
|
|
@ -109,7 +108,6 @@ static size_t line_length(const char *buffer, int bytestocheck)
|
|||
* GPE_END_OF_FILE
|
||||
* GPE_OK
|
||||
*/
|
||||
|
||||
static int readline(char **buffer, size_t *bufsize, size_t *length,
|
||||
FILE *stream)
|
||||
{
|
||||
|
|
@ -174,7 +172,6 @@ static int readline(char **buffer, size_t *bufsize, size_t *length,
|
|||
* GPE_OUT_OF_MEMORY
|
||||
* GPE_OK
|
||||
*/
|
||||
|
||||
static int appenddata(char **dst_buf, /* dest buffer */
|
||||
size_t *dst_len, /* dest buffer data length */
|
||||
size_t *dst_alloc, /* dest buffer allocated size */
|
||||
|
|
@ -274,7 +271,6 @@ static int decodedata(char **buf, /* dest buffer */
|
|||
* GPE_OUT_OF_MEMORY
|
||||
* GPE_OK
|
||||
*/
|
||||
|
||||
int getpart(char **outbuf, size_t *outlen,
|
||||
const char *main, const char *sub, FILE *stream)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
|
||||
#include "strdup.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
#!/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.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
if(!@ARGV) {
|
||||
die "Usage: $0 [<inputs>] [--exclude <exclude-c-sources>]\n";
|
||||
}
|
||||
|
||||
# Specific sources to exclude or add as an extra source file
|
||||
my @src;
|
||||
my %exclude;
|
||||
my $in_exclude = 0;
|
||||
foreach my $src (@ARGV) {
|
||||
if($in_exclude) {
|
||||
$exclude{$src} = 1;
|
||||
}
|
||||
elsif($src eq "--exclude") {
|
||||
$in_exclude = 1;
|
||||
}
|
||||
else {
|
||||
push @src, $src;
|
||||
}
|
||||
}
|
||||
|
||||
print <<HEADER
|
||||
/* !checksrc! disable COPYRIGHT all */
|
||||
|
||||
#include "first.h"
|
||||
|
||||
HEADER
|
||||
;
|
||||
|
||||
my $tlist = "";
|
||||
|
||||
foreach my $src (@src) {
|
||||
if($src =~ /\.c$/) {
|
||||
if(!exists $exclude{$src}) {
|
||||
# Misc .c source to include
|
||||
print "#include \"$src\"\n\n";
|
||||
}
|
||||
}
|
||||
elsif($src !~ /\.h$/) {
|
||||
# Make 'main' unique across server sources
|
||||
print "#undef main\n";
|
||||
print "#define main main_$src\n";
|
||||
print "int main_$src(int argc, char **argv);\n";
|
||||
print "#include \"$src.c\"\n";
|
||||
print "#undef main\n";
|
||||
print "\n";
|
||||
$tlist .= " {\"$src\", main_$src},\n";
|
||||
}
|
||||
}
|
||||
|
||||
print <<FOOTER
|
||||
static const struct onemain s_mains[] = {
|
||||
$tlist};
|
||||
|
||||
#include "first.c"
|
||||
FOOTER
|
||||
;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "util.h"
|
||||
|
|
@ -55,7 +55,6 @@
|
|||
|
||||
#include <curlx.h> /* from the private lib dir */
|
||||
#include "getpart.h"
|
||||
#include "server_sockaddr.h"
|
||||
|
||||
#include "tool_binmode.h"
|
||||
|
||||
|
|
@ -882,7 +881,7 @@ static curl_socket_t mqttd_sockdaemon(curl_socket_t sock,
|
|||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static int test_mqttd(int argc, char *argv[])
|
||||
{
|
||||
curl_socket_t sock = CURL_SOCKET_BAD;
|
||||
curl_socket_t msgsock = CURL_SOCKET_BAD;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
|
||||
/* Purpose
|
||||
*
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
/* include memdebug.h last */
|
||||
#include <memdebug.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static int test_resolve(int argc, char *argv[])
|
||||
{
|
||||
int arg = 1;
|
||||
const char *host = NULL;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
|
||||
/*
|
||||
* curl's test suite Real Time Streaming Protocol (RTSP) server.
|
||||
|
|
@ -51,7 +51,6 @@
|
|||
#include <curlx.h> /* from the private lib dir */
|
||||
#include "getpart.h"
|
||||
#include "util.h"
|
||||
#include "server_sockaddr.h"
|
||||
|
||||
/* include memdebug.h last */
|
||||
#include <memdebug.h>
|
||||
|
|
@ -1000,7 +999,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req)
|
|||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static int test_rtspd(int argc, char *argv[])
|
||||
{
|
||||
srvr_sockaddr_union_t me;
|
||||
curl_socket_t sock = CURL_SOCKET_BAD;
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
#ifndef HEADER_CURL_SERVER_SETUP_H
|
||||
#define HEADER_CURL_SERVER_SETUP_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
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#define CURL_NO_OLDIES
|
||||
|
||||
#include "curl_setup.h" /* portability help from the lib directory */
|
||||
|
||||
#endif /* HEADER_CURL_SERVER_SETUP_H */
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
#ifndef HEADER_CURL_SERVER_SOCKADDR_H
|
||||
#define HEADER_CURL_SERVER_SOCKADDR_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 "server_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
#include <sys/un.h> /* for sockaddr_un */
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in sa4;
|
||||
#ifdef USE_IPV6
|
||||
struct sockaddr_in6 sa6;
|
||||
#endif
|
||||
#ifdef USE_UNIX_SOCKETS
|
||||
struct sockaddr_un sau;
|
||||
#endif
|
||||
} srvr_sockaddr_union_t;
|
||||
|
||||
#endif /* HEADER_CURL_SERVER_SOCKADDR_H */
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
|
||||
/* Purpose
|
||||
*
|
||||
|
|
@ -104,8 +104,8 @@
|
|||
#include <curlx.h> /* from the private lib dir */
|
||||
#include "inet_pton.h"
|
||||
#include "util.h"
|
||||
#include "server_sockaddr.h"
|
||||
#include "timediff.h"
|
||||
#include "warnless.h" /* for read() */
|
||||
|
||||
#include "tool_binmode.h"
|
||||
|
||||
|
|
@ -1373,7 +1373,7 @@ static curl_socket_t sockfilt_sockdaemon(curl_socket_t sock,
|
|||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static int test_sockfilt(int argc, char *argv[])
|
||||
{
|
||||
srvr_sockaddr_union_t me;
|
||||
curl_socket_t sock = CURL_SOCKET_BAD;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Function
|
||||
|
|
@ -76,7 +76,6 @@
|
|||
#include <curlx.h> /* from the private lib dir */
|
||||
#include "inet_pton.h"
|
||||
#include "util.h"
|
||||
#include "server_sockaddr.h"
|
||||
#include "tool_binmode.h"
|
||||
|
||||
/* include memdebug.h last */
|
||||
|
|
@ -914,7 +913,7 @@ static curl_socket_t socksd_sockdaemon(curl_socket_t sock,
|
|||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static int test_socksd(int argc, char *argv[])
|
||||
{
|
||||
curl_socket_t sock = CURL_SOCKET_BAD;
|
||||
curl_socket_t msgsock = CURL_SOCKET_BAD;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
|
||||
/* sws.c: simple (silly?) web server
|
||||
|
||||
|
|
@ -53,7 +53,6 @@
|
|||
#include "getpart.h"
|
||||
#include "inet_pton.h"
|
||||
#include "util.h"
|
||||
#include "server_sockaddr.h"
|
||||
|
||||
/* include memdebug.h last */
|
||||
#include <memdebug.h>
|
||||
|
|
@ -1989,7 +1988,7 @@ static int service_connection(curl_socket_t msgsock,
|
|||
return -1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static int test_sws(int argc, char *argv[])
|
||||
{
|
||||
srvr_sockaddr_union_t me;
|
||||
curl_socket_t sock = CURL_SOCKET_BAD;
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
#ifndef HEADER_CURL_SERVER_TFTP_H
|
||||
#define HEADER_CURL_SERVER_TFTP_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 "server_setup.h"
|
||||
|
||||
/* This file is a rewrite/clone of the arpa/tftp.h file for systems without
|
||||
it. */
|
||||
|
||||
#define SEGSIZE 512 /* data segment size */
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ >= 3) || \
|
||||
((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7)))
|
||||
# define PACKED_STRUCT __attribute__((__packed__))
|
||||
#else
|
||||
# define PACKED_STRUCT /* NOTHING */
|
||||
#endif
|
||||
|
||||
/* Using a packed struct as binary in a program is begging for problems, but
|
||||
the tftpd server was written like this so we have this struct here to make
|
||||
things build. */
|
||||
|
||||
struct tftphdr {
|
||||
unsigned short th_opcode; /* packet type */
|
||||
unsigned short th_block; /* all sorts of things */
|
||||
char th_data[1]; /* data or error string */
|
||||
} PACKED_STRUCT;
|
||||
|
||||
#define th_stuff th_block
|
||||
#define th_code th_block
|
||||
#define th_msg th_data
|
||||
|
||||
#define TFTP_EUNDEF 0
|
||||
#define TFTP_ENOTFOUND 1
|
||||
#define TFTP_EACCESS 2
|
||||
#define TFTP_ENOSPACE 3
|
||||
#define TFTP_EBADOP 4
|
||||
#define TFTP_EBADID 5
|
||||
#define TFTP_EEXISTS 6
|
||||
#define TFTP_ENOUSER 7
|
||||
|
||||
#endif /* HEADER_CURL_SERVER_TFTP_H */
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
* SPDX-License-Identifier: BSD-4-Clause-UC
|
||||
*/
|
||||
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
|
|
@ -86,8 +86,42 @@
|
|||
#include <curlx.h> /* from the private lib dir */
|
||||
#include "getpart.h"
|
||||
#include "util.h"
|
||||
#include "server_sockaddr.h"
|
||||
#include "tftp.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* This is a rewrite/clone of the arpa/tftp.h file for systems without it. *
|
||||
*****************************************************************************/
|
||||
#define SEGSIZE 512 /* data segment size */
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ >= 3) || \
|
||||
((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7)))
|
||||
# define PACKED_STRUCT __attribute__((__packed__))
|
||||
#else
|
||||
# define PACKED_STRUCT /* NOTHING */
|
||||
#endif
|
||||
|
||||
/* Using a packed struct as binary in a program is begging for problems, but
|
||||
the tftpd server was written like this so we have this struct here to make
|
||||
things build. */
|
||||
|
||||
struct tftphdr {
|
||||
unsigned short th_opcode; /* packet type */
|
||||
unsigned short th_block; /* all sorts of things */
|
||||
char th_data[1]; /* data or error string */
|
||||
} PACKED_STRUCT;
|
||||
|
||||
#define th_stuff th_block
|
||||
#define th_code th_block
|
||||
#define th_msg th_data
|
||||
|
||||
#define TFTP_EUNDEF 0
|
||||
#define TFTP_ENOTFOUND 1
|
||||
#define TFTP_EACCESS 2
|
||||
#define TFTP_ENOSPACE 3
|
||||
#define TFTP_EBADOP 4
|
||||
#define TFTP_EBADID 5
|
||||
#define TFTP_EEXISTS 6
|
||||
#define TFTP_ENOUSER 7
|
||||
/****************************************************************************/
|
||||
|
||||
/* include memdebug.h last */
|
||||
#include <memdebug.h>
|
||||
|
|
@ -528,7 +562,7 @@ static int synchnet(curl_socket_t f /* socket to flush */)
|
|||
return j;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
static int test_tftpd(int argc, char **argv)
|
||||
{
|
||||
srvr_sockaddr_union_t me;
|
||||
struct tftphdr *tp;
|
||||
|
|
@ -826,7 +860,6 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
logmsg("end of one transfer");
|
||||
|
||||
}
|
||||
|
||||
tftpd_cleanup:
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
|
||||
#ifndef UNDER_CE
|
||||
#include <signal.h>
|
||||
|
|
|
|||
|
|
@ -23,13 +23,11 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "server_setup.h"
|
||||
#include "curl_setup.h"
|
||||
|
||||
/* adjust for old MSVC */
|
||||
#ifdef _MSC_VER
|
||||
# if _MSC_VER < 1900
|
||||
# define snprintf _snprintf
|
||||
# endif
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
@ -124,6 +122,17 @@ int bind_unix_socket(curl_socket_t sock, const char *unix_socket,
|
|||
struct sockaddr_un *sau);
|
||||
#endif /* USE_UNIX_SOCKETS */
|
||||
|
||||
typedef union {
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in sa4;
|
||||
#ifdef USE_IPV6
|
||||
struct sockaddr_in6 sa6;
|
||||
#endif
|
||||
#ifdef USE_UNIX_SOCKETS
|
||||
struct sockaddr_un sau;
|
||||
#endif
|
||||
} srvr_sockaddr_union_t;
|
||||
|
||||
unsigned short util_ultous(unsigned long ulnum);
|
||||
|
||||
#endif /* HEADER_CURL_SERVER_UTIL_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue