1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-24 09:08:49 -05:00

Added missing tests in CMake, added Makefile.inc for tests (+ use in CMake scripts), and fixed a missing define under windows in a test source file.

This commit is contained in:
Benoit Neil 2009-04-07 21:59:15 +00:00
parent 070d89a561
commit e9dd099870
8 changed files with 273 additions and 207 deletions

View File

@ -786,11 +786,15 @@ ENDFUNCTION()
# Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
FUNCTION(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)
FILE(READ ${INPUT_FILE} MAKEFILE_INC_TEXT)
STRING(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
STRING(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
STRING(REPLACE "$(top_builddir)" "\${CURL_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
STRING(REGEX REPLACE "\\\\\n" "§!§" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
STRING(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*\n)" "SET(\\1 \\2)\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
STRING(REPLACE "§!§" "\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
STRING(REGEX REPLACE "\\$\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
STRING(REGEX REPLACE "\\$\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace $() with ${}
STRING(REGEX REPLACE "@([a-zA-Z_][a-zA-Z0-9_]*)@" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace @@ with ${}, even if that may not be read by CMake scripts.
FILE(WRITE ${OUTPUT_FILE} ${MAKEFILE_INC_TEXT})
### BUGGY METHOD 1

View File

@ -27,50 +27,92 @@ MACRO(SETUP_TEST TEST_NAME) # ARGN are the files in the test
ENDMACRO()
# files used only in some libcurl test programs
SET(TESTUTIL testutil.c testutil.h)
# these files are used in every single test program below
SET(SUPPORTFILES first.c test.h)
# These are all libcurl test programs
SET(noinst_PROGRAMS
lib500 lib501 lib502 lib503 lib504 lib505 lib506
lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516
lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 #lib527
#lib529
lib530
#lib532
lib533 lib536 lib537 lib540 lib541 lib542 lib543
lib544
#lib545
lib547
#lib548
lib549 lib552 lib553 lib554 lib555 lib556
lib539 lib557 lib558
#lib559
lib560
)
SET(noinst_PROGRAMS_USE_TESTUTIL
lib502 lib503 lib504
lib507
lib525 lib526 #lib527
#lib529
lib530
#lib532
lib533 lib536
lib555
)
TRANSFORM_MAKEFILE_INC("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
FOREACH(TEST_NAME ${noinst_PROGRAMS})
SET(SOURCE "${TEST_NAME}.c" ${SUPPORTFILES})
LIST(FIND noinst_PROGRAMS_USE_TESTUTIL ${TEST_NAME} USES_TESTUTIL)
IF(NOT ${USES_TESTUTIL} EQUAL -1)
LIST(APPEND SOURCE ${TESTUTIL}) # Need TestUtil
ENDIF()
SETUP_TEST(${TEST_NAME} ${SOURCE})
SETUP_TEST(${TEST_NAME} ${${TEST_NAME}_SOURCES})
ENDFOREACH()
# # files used only in some libcurl test programs
# SET(TESTUTIL testutil.c testutil.h)
# # these files are used in every single test program below
# SET(SUPPORTFILES first.c test.h)
# # These are all libcurl test programs
# SET(noinst_PROGRAMS
# lib500 lib501 lib502 lib503 lib504 lib505 lib506
# lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516
# lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526
# #lib527
# #lib529
# lib530
# #lib532
# lib533 lib536 lib537 lib540 lib541 lib542 lib543
# lib544
# #lib545
# lib547
# #lib548
# lib549 lib552 lib553 lib554 lib555 lib556
# lib539 lib557 lib558
# #lib559
# lib560
# )
# SET(noinst_PROGRAMS_USE_TESTUTIL
# lib502 lib503 lib504
# lib507
# lib525 lib526 lib527
# lib529
# lib530
# lib532
# lib533 lib536
# lib555
# )
# MACRO(ADD_TESTUTIL_IF_NECESSARY TEST_NAME)
# LIST(FIND noinst_PROGRAMS_USE_TESTUTIL ${TEST_NAME} USES_TESTUTIL)
# IF(NOT ${USES_TESTUTIL} EQUAL -1)
# LIST(APPEND SOURCE ${TESTUTIL}) # Need TestUtil
# ENDIF()
# ENDMACRO()
# # General case
# FOREACH(TEST_NAME ${noinst_PROGRAMS})
# SET(SOURCE "${TEST_NAME}.c" ${SUPPORTFILES})
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
# SETUP_TEST(${TEST_NAME} ${SOURCE})
# ENDFOREACH()
# # Special cases
# SET(TEST_NAME lib527)
# SET(SOURCE "lib526.c" ${SUPPORTFILES})
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
# SETUP_TEST(${TEST_NAME} ${SOURCE})
# SET(TEST_NAME lib529)
# SET(SOURCE "lib525.c" ${SUPPORTFILES})
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
# SETUP_TEST(${TEST_NAME} ${SOURCE})
# SET(TEST_NAME lib532)
# SET(SOURCE "lib526.c" ${SUPPORTFILES})
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
# SETUP_TEST(${TEST_NAME} ${SOURCE})
# SET(TEST_NAME lib545)
# SET(SOURCE "lib544.c" ${SUPPORTFILES})
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
# SETUP_TEST(${TEST_NAME} ${SOURCE})
# SET(TEST_NAME lib548)
# SET(SOURCE "lib547.c" ${SUPPORTFILES})
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
# SETUP_TEST(${TEST_NAME} ${SOURCE})
# SET(TEST_NAME lib559)
# SET(SOURCE "lib558.c" ${SUPPORTFILES})
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
# SETUP_TEST(${TEST_NAME} ${SOURCE})

View File

@ -41,132 +41,9 @@ LIBDIR = $(top_builddir)/lib
EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl test1022.pl
# files used only in some libcurl test programs
TESTUTIL = testutil.c testutil.h
# these files are used in every single test program below
SUPPORTFILES = first.c test.h
# These are all libcurl test programs
noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \
lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \
lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \
lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \
lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \
lib539 lib557 lib558 lib559 lib560
# Dependencies (may need to be overriden)
LDADD = $(LIBDIR)/libcurl.la
DEPENDENCIES = $(LIBDIR)/libcurl.la
lib500_SOURCES = lib500.c $(SUPPORTFILES)
lib501_SOURCES = lib501.c $(SUPPORTFILES)
lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL)
lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL)
lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL)
lib505_SOURCES = lib505.c $(SUPPORTFILES)
lib506_SOURCES = lib506.c $(SUPPORTFILES)
lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL)
lib508_SOURCES = lib508.c $(SUPPORTFILES)
lib510_SOURCES = lib510.c $(SUPPORTFILES)
lib511_SOURCES = lib511.c $(SUPPORTFILES)
lib512_SOURCES = lib512.c $(SUPPORTFILES)
lib513_SOURCES = lib513.c $(SUPPORTFILES)
lib514_SOURCES = lib514.c $(SUPPORTFILES)
lib515_SOURCES = lib515.c $(SUPPORTFILES)
lib516_SOURCES = lib516.c $(SUPPORTFILES)
lib517_SOURCES = lib517.c $(SUPPORTFILES)
lib518_SOURCES = lib518.c $(SUPPORTFILES)
lib519_SOURCES = lib519.c $(SUPPORTFILES)
lib520_SOURCES = lib520.c $(SUPPORTFILES)
lib521_SOURCES = lib521.c $(SUPPORTFILES)
lib523_SOURCES = lib523.c $(SUPPORTFILES)
lib524_SOURCES = lib524.c $(SUPPORTFILES)
lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL)
lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
lib526_CFLAGS = -DLIB526
lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
lib527_CFLAGS = -DLIB527
lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL)
lib529_CFLAGS = -DLIB529
lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL)
lib530_CFLAGS = -DLIB530
lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
lib532_CFLAGS = -DLIB532
lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL)
lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL)
lib537_SOURCES = lib537.c $(SUPPORTFILES)
lib539_SOURCES = lib539.c $(SUPPORTFILES)
lib540_SOURCES = lib540.c $(SUPPORTFILES)
lib541_SOURCES = lib541.c $(SUPPORTFILES)
lib542_SOURCES = lib542.c $(SUPPORTFILES)
lib543_SOURCES = lib543.c $(SUPPORTFILES)
lib544_SOURCES = lib544.c $(SUPPORTFILES)
lib545_SOURCES = lib544.c $(SUPPORTFILES)
lib545_CFLAGS = -DLIB545
lib547_SOURCES = lib547.c $(SUPPORTFILES)
lib548_SOURCES = lib547.c $(SUPPORTFILES)
lib548_CFLAGS = -DLIB548
lib549_SOURCES = lib549.c $(SUPPORTFILES)
lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL)
lib552_SOURCES = lib552.c $(SUPPORTFILES)
lib553_SOURCES = lib553.c $(SUPPORTFILES)
lib554_SOURCES = lib554.c $(SUPPORTFILES)
lib556_SOURCES = lib556.c $(SUPPORTFILES)
lib557_SOURCES = lib557.c $(SUPPORTFILES)
lib558_SOURCES = lib558.c $(SUPPORTFILES)
lib558_CFLAGS = -DLIB558
lib559_SOURCES = lib558.c $(SUPPORTFILES)
lib559_CFLAGS = -DLIB559
lib560_SOURCES = lib560.c $(SUPPORTFILES)
# Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES, noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS)
include Makefile.inc

125
tests/libtest/Makefile.inc Normal file
View File

@ -0,0 +1,125 @@
# files used only in some libcurl test programs
TESTUTIL = testutil.c testutil.h
# these files are used in every single test program below
SUPPORTFILES = first.c test.h
# These are all libcurl test programs
noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \
lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \
lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \
lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \
lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \
lib539 lib557 lib558 lib559 lib560
lib500_SOURCES = lib500.c $(SUPPORTFILES)
lib501_SOURCES = lib501.c $(SUPPORTFILES)
lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL)
lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL)
lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL)
lib505_SOURCES = lib505.c $(SUPPORTFILES)
lib506_SOURCES = lib506.c $(SUPPORTFILES)
lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL)
lib508_SOURCES = lib508.c $(SUPPORTFILES)
lib510_SOURCES = lib510.c $(SUPPORTFILES)
lib511_SOURCES = lib511.c $(SUPPORTFILES)
lib512_SOURCES = lib512.c $(SUPPORTFILES)
lib513_SOURCES = lib513.c $(SUPPORTFILES)
lib514_SOURCES = lib514.c $(SUPPORTFILES)
lib515_SOURCES = lib515.c $(SUPPORTFILES)
lib516_SOURCES = lib516.c $(SUPPORTFILES)
lib517_SOURCES = lib517.c $(SUPPORTFILES)
lib518_SOURCES = lib518.c $(SUPPORTFILES)
lib519_SOURCES = lib519.c $(SUPPORTFILES)
lib520_SOURCES = lib520.c $(SUPPORTFILES)
lib521_SOURCES = lib521.c $(SUPPORTFILES)
lib523_SOURCES = lib523.c $(SUPPORTFILES)
lib524_SOURCES = lib524.c $(SUPPORTFILES)
lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL)
lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
lib526_CFLAGS = -DLIB526
lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
lib527_CFLAGS = -DLIB527
lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL)
lib529_CFLAGS = -DLIB529
lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL)
lib530_CFLAGS = -DLIB530
lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
lib532_CFLAGS = -DLIB532
lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL)
lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL)
lib537_SOURCES = lib537.c $(SUPPORTFILES)
lib539_SOURCES = lib539.c $(SUPPORTFILES)
lib540_SOURCES = lib540.c $(SUPPORTFILES)
lib541_SOURCES = lib541.c $(SUPPORTFILES)
lib542_SOURCES = lib542.c $(SUPPORTFILES)
lib543_SOURCES = lib543.c $(SUPPORTFILES)
lib544_SOURCES = lib544.c $(SUPPORTFILES)
lib545_SOURCES = lib544.c $(SUPPORTFILES)
lib545_CFLAGS = -DLIB545
lib547_SOURCES = lib547.c $(SUPPORTFILES)
lib548_SOURCES = lib547.c $(SUPPORTFILES)
lib548_CFLAGS = -DLIB548
lib549_SOURCES = lib549.c $(SUPPORTFILES)
lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL)
lib552_SOURCES = lib552.c $(SUPPORTFILES)
lib553_SOURCES = lib553.c $(SUPPORTFILES)
lib554_SOURCES = lib554.c $(SUPPORTFILES)
lib556_SOURCES = lib556.c $(SUPPORTFILES)
lib557_SOURCES = lib557.c $(SUPPORTFILES)
lib558_SOURCES = lib558.c $(SUPPORTFILES)
lib558_CFLAGS = -DLIB558
lib559_SOURCES = lib558.c $(SUPPORTFILES)
lib559_CFLAGS = -DLIB559
lib560_SOURCES = lib560.c $(SUPPORTFILES)

View File

@ -12,6 +12,17 @@
#include "memdebug.h"
/* For Windows, mainly (may be moved in a config file?) */
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif
int test(char *URL)
{
CURLcode res;
@ -53,7 +64,6 @@ int test(char *URL)
if(iolen)
/* send received stuff to stdout */
write(STDOUT_FILENO, buf, iolen);
total += iolen;
} while(((res == CURLE_OK) || (res == CURLE_AGAIN)) && (total < 129));

View File

@ -27,19 +27,26 @@ MACRO(SETUP_EXECUTABLE TEST_NAME) # ARGN are the files in the test
ENDMACRO()
TRANSFORM_MAKEFILE_INC("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
SET(useful
getpart.c getpart.h
${CURL_SOURCE_DIR}/lib/strequal.c
${CURL_SOURCE_DIR}/lib/base64.c
${CURL_SOURCE_DIR}/lib/mprintf.c
${CURL_SOURCE_DIR}/lib/memdebug.c
${CURL_SOURCE_DIR}/lib/timeval.c
)
FOREACH(EXECUTABLE_NAME ${noinst_PROGRAMS})
SETUP_EXECUTABLE(${EXECUTABLE_NAME} ${${EXECUTABLE_NAME}_SOURCES})
ENDFOREACH()
SETUP_EXECUTABLE(sws sws.c util.c util.h ${useful})
SETUP_EXECUTABLE(resolve resolve.c util.c util.h ${useful})
SETUP_EXECUTABLE(sockfilt sockfilt.c util.c util.h ${useful} ${CURL_SOURCE_DIR}/lib/inet_pton.c)
SETUP_EXECUTABLE(getpart testpart.c ${useful})
SETUP_EXECUTABLE(tftpd tftpd.c util.c util.h ${useful} tftp.h)
# SET(useful
# getpart.c getpart.h
# ${CURL_SOURCE_DIR}/lib/strequal.c
# ${CURL_SOURCE_DIR}/lib/base64.c
# ${CURL_SOURCE_DIR}/lib/mprintf.c
# ${CURL_SOURCE_DIR}/lib/memdebug.c
# ${CURL_SOURCE_DIR}/lib/timeval.c
# )
# SETUP_EXECUTABLE(sws sws.c util.c util.h ${useful})
# SETUP_EXECUTABLE(resolve resolve.c util.c util.h ${useful})
# SETUP_EXECUTABLE(sockfilt sockfilt.c util.c util.h ${useful} ${CURL_SOURCE_DIR}/lib/inet_pton.c)
# SETUP_EXECUTABLE(getpart testpart.c ${useful})
# SETUP_EXECUTABLE(tftpd tftpd.c util.c util.h ${useful} tftp.h)

View File

@ -37,28 +37,7 @@ INCLUDES = -I$(top_builddir)/include \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib
noinst_PROGRAMS = sws getpart sockfilt resolve tftpd
useful = getpart.c getpart.h $(top_srcdir)/lib/strequal.c \
$(top_srcdir)/lib/base64.c $(top_srcdir)/lib/mprintf.c \
$(top_srcdir)/lib/memdebug.c $(top_srcdir)/lib/timeval.c
resolve_SOURCES= resolve.c util.c util.h $(useful)
resolve_LDADD = @TEST_SERVER_LIBS@
sws_SOURCES= sws.c util.c util.h $(useful)
sws_LDADD = @TEST_SERVER_LIBS@
sockfilt_SOURCES = sockfilt.c util.c util.h $(useful) \
$(top_srcdir)/lib/inet_pton.c
sockfilt_LDADD = @TEST_SERVER_LIBS@
getpart_SOURCES= testpart.c $(useful)
# This is needed because of (unused) network debugging functions in memdebug.c
getpart_LDADD = @TEST_SERVER_LIBS@
tftpd_SOURCES = tftpd.c util.c util.h $(useful) tftp.h
tftpd_LDADD = @TEST_SERVER_LIBS@
# Makefile.inc provides the source defines (noinst_PROGRAMS, useful, *_SOURCES, and *_LDADD)
include Makefile.inc
extra_DIST = base64.pl

22
tests/server/Makefile.inc Normal file
View File

@ -0,0 +1,22 @@
noinst_PROGRAMS = sws getpart sockfilt resolve tftpd
useful = getpart.c getpart.h $(top_srcdir)/lib/strequal.c \
$(top_srcdir)/lib/base64.c $(top_srcdir)/lib/mprintf.c \
$(top_srcdir)/lib/memdebug.c $(top_srcdir)/lib/timeval.c
resolve_SOURCES= resolve.c util.c util.h $(useful)
resolve_LDADD = @TEST_SERVER_LIBS@
sws_SOURCES= sws.c util.c util.h $(useful)
sws_LDADD = @TEST_SERVER_LIBS@
sockfilt_SOURCES = sockfilt.c util.c util.h $(useful) \
$(top_srcdir)/lib/inet_pton.c
sockfilt_LDADD = @TEST_SERVER_LIBS@
getpart_SOURCES= testpart.c $(useful)
# This is needed because of (unused) network debugging functions in memdebug.c
getpart_LDADD = @TEST_SERVER_LIBS@
tftpd_SOURCES = tftpd.c util.c util.h $(useful) tftp.h
tftpd_LDADD = @TEST_SERVER_LIBS@