You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2013/10/11 02:15:56 UTC

svn commit: r1531155 - in /apr/apr/branches/1.5.x: ./ CMakeLists.txt README.cmake test/internal/testucs.c

Author: trawick
Date: Fri Oct 11 00:15:55 2013
New Revision: 1531155

URL: http://svn.apache.org/r1531155
Log:
Merge non-APR-Util bits of r1523521 and 1523604 from trunk:

r1523521:

fix various compile errors and warnings (in testucs.c)

r1523604:

Fix build of aprapp/libaprapp (APR_DECLARE_STATIC was misplaced).

Support building test suite against either static or dynamic libs.
  (Requiring separate builds is ugly, but so is creating a more
  complex directory structure or naming convention in the build 
  directory and possibly having to modify test program source to 
  find child programs.)

Build additional test programs.

Add running the test suite to the build system.
  (Using the "NMake Makefiles" generator, use "nmake test" to run
  silently, with output logged to some files, or "nmake check" to
  run with test output logged to the console.)

Modified:
    apr/apr/branches/1.5.x/   (props changed)
    apr/apr/branches/1.5.x/CMakeLists.txt
    apr/apr/branches/1.5.x/README.cmake
    apr/apr/branches/1.5.x/test/internal/testucs.c

Propchange: apr/apr/branches/1.5.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1523521,1523604

Modified: apr/apr/branches/1.5.x/CMakeLists.txt
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/CMakeLists.txt?rev=1531155&r1=1531154&r2=1531155&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/CMakeLists.txt (original)
+++ apr/apr/branches/1.5.x/CMakeLists.txt Fri Oct 11 00:15:55 2013
@@ -23,6 +23,7 @@ OPTION(APR_INSTALL_PRIVATE_H  "Install s
 OPTION(APR_HAVE_IPV6        "IPv6 support"                 ON)
 OPTION(INSTALL_PDB          "Install .pdb files (if generated)"  ON)
 OPTION(APR_BUILD_TESTAPR    "Build the test suite"         OFF)
+OPTION(TEST_STATIC_LIBS     "Test programs use APR static libraries instead of shared libraries?" OFF)
 SET(MIN_WINDOWS_VER             "Vista" 
     CACHE STRING "Minimum Windows version")
 
@@ -85,8 +86,6 @@ INCLUDE_DIRECTORIES(${APR_INCLUDE_DIRECT
 
 SET(APR_HEADERS ${PROJECT_BINARY_DIR}/apr.h)
 
-# and misc/win32/apr_app.c
-
 SET(APR_PUBLIC_HEADERS_STATIC
   include/apr_allocator.h
   include/apr_atomic.h
@@ -278,54 +277,108 @@ SET(install_targets ${install_targets} l
 SET(install_lib_pdb ${install_bin_pdb} ${PROJECT_BINARY_DIR}/libaprapp-1.pdb)
 SET_TARGET_PROPERTIES(libaprapp-1 PROPERTIES COMPILE_DEFINITIONS APR_APP)
 
-ADD_LIBRARY(aprapp-1 STATIC ${APR_HEADERS} ${PROJECT_BINARY_DIR}/apr.h misc/win32/apr_app.c)
+ADD_LIBRARY(aprapp-1 STATIC ${APR_HEADERS} ${PROJECT_BINARY_DIR}/apr.h misc/win32/apr_app.c misc/win32/internal.c)
 SET(install_targets ${install_targets} aprapp-1)
 SET(install_lib_pdb ${install_lib_pdb} ${PROJECT_BINARY_DIR}/aprapp-1.pdb)
-SET_TARGET_PROPERTIES(libaprapp-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC;APR_APP")
+SET_TARGET_PROPERTIES(aprapp-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC;APR_APP")
 
 IF(APR_BUILD_TESTAPR)
-  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/data)
-  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/test/data/file_datafile.txt ${PROJECT_BINARY_DIR}/data/file_datafile.txt)
-  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/test/data/mmap_datafile.txt ${PROJECT_BINARY_DIR}/data/mmap_datafile.txt)
+  ENABLE_TESTING()
+  # Create a "check" target that displays test program output to the console.
+  ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
+
+  # copy data files to build directory so that we can run programs from there
+  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory 
+                  ${PROJECT_BINARY_DIR}/data)
+  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different 
+                  ${PROJECT_SOURCE_DIR}/test/data/file_datafile.txt
+                  ${PROJECT_BINARY_DIR}/data/file_datafile.txt)
+  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different
+                  ${PROJECT_SOURCE_DIR}/test/data/mmap_datafile.txt
+                  ${PROJECT_BINARY_DIR}/data/mmap_datafile.txt)
+
+  IF(TEST_STATIC_LIBS)
+    SET(whichapr    apr-1)
+    SET(whichaprapp aprapp-1)
+    SET(apiflag     -DAPR_DECLARE_STATIC)
+  ELSE()
+    SET(whichapr    libapr-1)
+    SET(whichaprapp libaprapp-1)
+    SET(apiflag)
+  ENDIF()
+
+  ADD_EXECUTABLE(testapp test/testapp.c)
+  TARGET_LINK_LIBRARIES(testapp ${whichapr} ${whichaprapp} ${APR_SYSTEM_LIBS})
+  SET_TARGET_PROPERTIES(testapp PROPERTIES LINK_FLAGS /entry:wmainCRTStartup)
+  IF(apiflag)
+    SET_TARGET_PROPERTIES(testapp PROPERTIES COMPILE_FLAGS ${apiflag})
+  ENDIF()
+  ADD_TEST(NAME testapp COMMAND testapp)
 
   ADD_EXECUTABLE(testall ${APR_TEST_SOURCES})
-  TARGET_LINK_LIBRARIES(testall apr-1 ${APR_SYSTEM_LIBS})
+  TARGET_LINK_LIBRARIES(testall ${whichapr} ${APR_SYSTEM_LIBS})
+  IF(apiflag)
+    SET_TARGET_PROPERTIES(testall PROPERTIES COMPILE_FLAGS ${apiflag})
+  ENDIF()
+  ADD_TEST(NAME testall COMMAND testall)
 
   ADD_LIBRARY(mod_test MODULE test/mod_test.c)
-  TARGET_LINK_LIBRARIES(mod_test apr-1 ${APR_SYSTEM_LIBS})
+  TARGET_LINK_LIBRARIES(mod_test ${whichapr} ${APR_SYSTEM_LIBS})
   SET_PROPERTY(TARGET mod_test APPEND PROPERTY LINK_FLAGS /export:print_hello)
   # nasty work-around for difficulties adding more than one additional flag
   # (they get joined in a bad way behind the scenes)
   GET_PROPERTY(link_flags TARGET mod_test PROPERTY LINK_FLAGS)
   SET(link_flags "${link_flags} /export:count_reps")
   SET_TARGET_PROPERTIES(mod_test PROPERTIES LINK_FLAGS ${link_flags})
+  IF(apiflag)
+    SET_TARGET_PROPERTIES(mod_test PROPERTIES COMPILE_FLAGS ${apiflag})
+  ENDIF()
+
+  # Build all the single-source executable files with no special build
+  # requirements.
+  SET(single_source_programs
+    test/echod.c
+    test/sendfile.c
+    test/sockperf.c
+    test/testlockperf.c
+    test/testmutexscope.c
+    test/globalmutexchild.c
+    test/occhild.c
+    test/proc_child.c
+    test/readchild.c
+    test/sockchild.c
+    test/testshmproducer.c
+    test/testshmconsumer.c
+    test/tryread.c
+    test/internal/testucs.c
+  )
+
+  FOREACH(sourcefile ${single_source_programs})
+    STRING(REGEX REPLACE ".*/([^\\]+)\\.c" "\\1" proggie ${sourcefile})
+    ADD_EXECUTABLE(${proggie} ${sourcefile})
+    TARGET_LINK_LIBRARIES(${proggie} ${whichapr} ${APR_SYSTEM_LIBS})
+    IF(apiflag)
+      SET_TARGET_PROPERTIES(${proggie} PROPERTIES COMPILE_FLAGS ${apiflag})
+    ENDIF()
+  ENDFOREACH()
+
+  # Add tests for programs that run by themselves with no arguments.
+  SET(simple_tests
+    testlockperf
+    testmutexscope
+    testucs
+  )
+
+  FOREACH(simple ${simple_tests})
+    ADD_TEST(NAME ${simple} COMMAND ${simple})
+  ENDFOREACH()
+
+  # sendfile runs multiple times with different parameters.
+  FOREACH(sendfile_mode blocking nonblocking timeout)
+    ADD_TEST(NAME sendfile-${sendfile_mode} COMMAND sendfile client ${sendfile_mode} startserver)
+  ENDFOREACH()
 
-  ADD_EXECUTABLE(occhild test/occhild.c)
-  TARGET_LINK_LIBRARIES(occhild apr-1 ${APR_SYSTEM_LIBS})
-
-  ADD_EXECUTABLE(globalmutexchild test/globalmutexchild.c)
-  TARGET_LINK_LIBRARIES(globalmutexchild apr-1 ${APR_SYSTEM_LIBS})
-
-  ADD_EXECUTABLE(proc_child test/proc_child.c)
-  TARGET_LINK_LIBRARIES(proc_child apr-1 ${APR_SYSTEM_LIBS})
-
-  ADD_EXECUTABLE(readchild test/readchild.c)
-  TARGET_LINK_LIBRARIES(readchild apr-1 ${APR_SYSTEM_LIBS})
-
-  ADD_EXECUTABLE(sockchild test/sockchild.c)
-  TARGET_LINK_LIBRARIES(sockchild apr-1 ${APR_SYSTEM_LIBS})
-
-  ADD_EXECUTABLE(testshmconsumer test/testshmconsumer.c)
-  TARGET_LINK_LIBRARIES(testshmconsumer apr-1 ${APR_SYSTEM_LIBS})
-
-  ADD_EXECUTABLE(testshmproducer test/testshmproducer.c)
-  TARGET_LINK_LIBRARIES(testshmproducer apr-1 ${APR_SYSTEM_LIBS})
-
-  ADD_EXECUTABLE(tryread test/tryread.c)
-  TARGET_LINK_LIBRARIES(tryread apr-1 ${APR_SYSTEM_LIBS})
-
-  # test programs are linked with static library
-  SET_TARGET_PROPERTIES(testall mod_test occhild globalmutexchild proc_child readchild sockchild testshmconsumer testshmproducer tryread PROPERTIES COMPILE_FLAGS -DAPR_DECLARE_STATIC)
+  # No test is added for echod+sockperf.  Those will have to be run manually.
 
 ENDIF (APR_BUILD_TESTAPR)
 
@@ -365,6 +418,7 @@ MESSAGE(STATUS "")
 MESSAGE(STATUS "")
 MESSAGE(STATUS "APR configuration summary:")
 MESSAGE(STATUS "")
+
 MESSAGE(STATUS "  Build type ...................... : ${CMAKE_BUILD_TYPE}")
 MESSAGE(STATUS "  Install .pdb (if available)...... : ${INSTALL_PDB}")
 MESSAGE(STATUS "  Install prefix .................. : ${CMAKE_INSTALL_PREFIX}")
@@ -372,4 +426,9 @@ MESSAGE(STATUS "  C compiler ...........
 MESSAGE(STATUS "  IPv6 ............................ : ${APR_HAVE_IPV6}")
 MESSAGE(STATUS "  Minimum Windows version ......... : ${MIN_WINDOWS_VER}")
 MESSAGE(STATUS "  Build test suite ................ : ${APR_BUILD_TESTAPR}")
+IF(TEST_STATIC_LIBS)
+MESSAGE(STATUS "    (testing static libraries)")
+ELSE()
+MESSAGE(STATUS "    (testing dynamic libraries)")
+ENDIF()
 MESSAGE(STATUS "  Install private .h for httpd .... : ${APR_INSTALL_PRIVATE_H}")

Modified: apr/apr/branches/1.5.x/README.cmake
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/README.cmake?rev=1531155&r1=1531154&r2=1531155&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/README.cmake (original)
+++ apr/apr/branches/1.5.x/README.cmake Fri Oct 11 00:15:55 2013
@@ -60,6 +60,13 @@ How to build
                               Default: ON
        APR_BUILD_TESTAPR      Build APR test suite
                               Default: OFF
+       TEST_STATIC_LIBS       Build the test suite to test the APR static
+                              library instead of the APR dynamic library.
+                              Default: OFF
+                              In order to build the test suite against both
+                              static and dynamic libraries, separate builds
+                              will be required, one with TEST_STATIC_LIBS
+                              set to ON.
        MIN_WINDOWS_VER        Minimum Windows version supported by this build
                               (This controls the setting of _WIN32_WINNT.)
                               "Vista" or "Windows7" or a numeric value like
@@ -90,11 +97,8 @@ Known Bugs and Limitations
   cause the build to fail.
 * Options should be provided for remaining features:
   + APR_POOL_DEBUG
-* No test program build to use libapr-1.dll is created.
-* No script or other mechanism is provided to run the test suite.
 * APR-CHANGES.txt, APR-LICENSE.txt, and APR-NOTICE.txt are not installed,
   though perhaps that is a job for a higher-level script.
-* test/internal/testucs is not built.
 
 Generally:
 

Modified: apr/apr/branches/1.5.x/test/internal/testucs.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/test/internal/testucs.c?rev=1531155&r1=1531154&r2=1531155&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/test/internal/testucs.c (original)
+++ apr/apr/branches/1.5.x/test/internal/testucs.c Fri Oct 11 00:15:55 2013
@@ -17,16 +17,19 @@
 #include "apr.h"
 #include "arch/win32/apr_arch_utf8.h"
 #include <wchar.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 
 struct testval {
     unsigned char n[8];
-    int nl;
+    apr_size_t nl;
     wchar_t w[4];
-    int wl;
+    apr_size_t wl;
 };
 
+#ifdef FOR_REFERENCE
 /* For reference; a table of invalid utf-8 encoded ucs-2/ucs-4 sequences.
  * The table consists of start, end pairs for all invalid ranges.
  * NO_UCS2_PAIRS will pass the reservered D800-DFFF values, halting at FFFF
@@ -71,6 +74,7 @@ struct testval malformed[] = [
     [[0xFE,], 1,],    /* 11111110  invalid "too large" value, no 7 byte seq */
     [[0xFF,], 1,],    /* 11111111  invalid "too large" value, no 8 byte seq */
 ];
+#endif /* FOR_REFERENCE */
 
 void displaynw(struct testval *f, struct testval *l)
 {
@@ -192,7 +196,7 @@ void test_wrange(struct testval *p)
     }
 
     do {
-        int wl = s.wl, nl = sizeof(s.n);
+        apr_size_t wl = s.wl, nl = sizeof(s.n);
         rc = apr_conv_ucs2_to_utf8(s.w, &wl, s.n, &nl);
         s.nl = sizeof(s.n) - s.nl;
         if (rc == APR_INCOMPLETE) {