Home | History | Annotate | Download | only in libtest
      1 set(TARGET_LABEL_PREFIX "Test ")
      2 
      3 function(SETUP_TEST TEST_NAME)          # ARGN are the files in the test
      4   add_executable( ${TEST_NAME} ${ARGN} )
      5   string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME)
      6 
      7   include_directories(
      8     ${CURL_SOURCE_DIR}/lib          # To be able to reach "curl_setup_once.h"
      9     ${CURL_BINARY_DIR}/lib          # To be able to reach "curl_config.h"
     10     ${CURL_BINARY_DIR}/include      # To be able to reach "curl/curlbuild.h"
     11     )
     12   if(USE_ARES)
     13     include_directories(${CARES_INCLUDE_DIR})
     14   endif()
     15 
     16   target_link_libraries( ${TEST_NAME} libcurl ${CURL_LIBS})
     17 
     18   set_target_properties(${TEST_NAME}
     19     PROPERTIES COMPILE_DEFINITIONS ${UPPER_TEST_NAME})
     20   set_target_properties(${TEST_NAME}
     21     PROPERTIES PROJECT_LABEL "${TARGET_LABEL_PREFIX}${TEST_NAME}")
     22 
     23   # Add the postfix to the executable since it is
     24   # not added automatically as for modules and shared libraries
     25   set_target_properties(${TEST_NAME}
     26     PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
     27 
     28 endfunction()
     29 
     30 
     31 transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
     32 include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
     33 
     34 foreach(TEST_NAME ${noinst_PROGRAMS})
     35   setup_test(${TEST_NAME} ${${TEST_NAME}_SOURCES})
     36 endforeach()
     37 
     38 # Allows for hostname override to make tests machine independent.
     39 # TODO this cmake build assumes a shared build, detect static linking here!
     40 if(NOT WIN32)
     41   add_library(hostname MODULE sethostname.c sethostname.h)
     42   # Output to .libs for compatibility with autotools, the test data expects a
     43   # library at (tests)/libtest/.libs/libhostname.so
     44   set_target_properties(hostname PROPERTIES
     45       LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.libs)
     46 endif()
     47 
     48 # # files used only in some libcurl test programs
     49 # SET(TESTUTIL testutil.c testutil.h)
     50 
     51 # # these files are used in every single test program below
     52 # SET(SUPPORTFILES first.c test.h)
     53 
     54 # # These are all libcurl test programs
     55 # SET(noinst_PROGRAMS
     56 # lib500 lib501 lib502 lib503 lib504 lib505 lib506
     57 # lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516
     58 # lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526
     59 # #lib527
     60 # #lib529
     61 # lib530
     62 # #lib532
     63 # lib533 lib536 lib537 lib540 lib541 lib542 lib543
     64 # lib544
     65 # #lib545
     66 # lib547
     67 # #lib548
     68 # lib549 lib552 lib553 lib554 lib555 lib556
     69 # lib539 lib557
     70 # lib560
     71 # )
     72 
     73 # SET(noinst_PROGRAMS_USE_TESTUTIL
     74 # lib502 lib503 lib504
     75 # lib507
     76 # lib525 lib526 lib527
     77 # lib529
     78 # lib530
     79 # lib532
     80 # lib533 lib536
     81 # lib555
     82 # )
     83 
     84 # MACRO(ADD_TESTUTIL_IF_NECESSARY TEST_NAME)
     85 # LIST(FIND noinst_PROGRAMS_USE_TESTUTIL ${TEST_NAME} USES_TESTUTIL)
     86 # IF(NOT ${USES_TESTUTIL} EQUAL -1)
     87 # LIST(APPEND SOURCE ${TESTUTIL})               # Need TestUtil
     88 # ENDIF()
     89 # ENDMACRO()
     90 
     91 # # General case
     92 # FOREACH(TEST_NAME ${noinst_PROGRAMS})
     93 # SET(SOURCE "${TEST_NAME}.c" ${SUPPORTFILES})
     94 # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
     95 # SETUP_TEST(${TEST_NAME} ${SOURCE})
     96 # ENDFOREACH()
     97 
     98 # # Special cases
     99 # SET(TEST_NAME lib527)
    100 # SET(SOURCE "lib526.c" ${SUPPORTFILES})
    101 # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
    102 # SETUP_TEST(${TEST_NAME} ${SOURCE})
    103 
    104 # SET(TEST_NAME lib529)
    105 # SET(SOURCE "lib525.c" ${SUPPORTFILES})
    106 # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
    107 # SETUP_TEST(${TEST_NAME} ${SOURCE})
    108 
    109 # SET(TEST_NAME lib532)
    110 # SET(SOURCE "lib526.c" ${SUPPORTFILES})
    111 # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
    112 # SETUP_TEST(${TEST_NAME} ${SOURCE})
    113 
    114 # SET(TEST_NAME lib545)
    115 # SET(SOURCE "lib544.c" ${SUPPORTFILES})
    116 # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
    117 # SETUP_TEST(${TEST_NAME} ${SOURCE})
    118 
    119 # SET(TEST_NAME lib548)
    120 # SET(SOURCE "lib547.c" ${SUPPORTFILES})
    121 # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
    122 # SETUP_TEST(${TEST_NAME} ${SOURCE})
    123