CMakeLists.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. # Delegate some functionality to libhdfs, until libhdfspp is complete.
  19. set (LIBHDFS_SRC_DIR ../../libhdfs)
  20. set (LIBHDFS_TESTS_DIR ../../libhdfs-tests)
  21. set (LIBHDFSPP_SRC_DIR ..)
  22. set (LIBHDFSPP_LIB_DIR ${LIBHDFSPP_SRC_DIR}/lib)
  23. set (LIBHDFSPP_BINDING_C ${LIBHDFSPP_LIB_DIR}/bindings/c)
  24. include_directories(
  25. ${GENERATED_JAVAH}
  26. ${CMAKE_CURRENT_SOURCE_DIR}
  27. ${CMAKE_BINARY_DIR}
  28. ${JNI_INCLUDE_DIRS}
  29. ${LIBHDFS_SRC_DIR}/include
  30. ${LIBHDFS_SRC_DIR}/..
  31. ${LIBHDFS_SRC_DIR}
  32. ${OS_DIR}
  33. )
  34. add_library(hdfspp_test_shim_static STATIC hdfs_shim.c libhdfs_wrapper.c libhdfspp_wrapper.cc ${LIBHDFSPP_BINDING_C}/hdfs_cpp.cc)
  35. add_library(test_common OBJECT mock_connection.cc)
  36. set(PROTOBUF_IMPORT_DIRS ${PROTO_HADOOP_TEST_DIR})
  37. protobuf_generate_cpp(PROTO_TEST_SRCS PROTO_TEST_HDRS
  38. ${PROTO_HADOOP_TEST_DIR}/test.proto
  39. ${PROTO_HADOOP_TEST_DIR}/test_rpc_service.proto
  40. )
  41. # Shamelessly stolen from
  42. # http://stackoverflow.com/questions/9303711/how-do-i-make-ctest-run-a-program-with-valgrind-without-dart
  43. function(add_memcheck_test name binary)
  44. set(memcheck_command "${MEMORYCHECK_COMMAND} ${MEMORYCHECK_COMMAND_OPTIONS}")
  45. separate_arguments(memcheck_command)
  46. add_test(${name} ${binary} ${ARGN})
  47. add_test(memcheck_${name} ${memcheck_command} ./${binary} ${ARGN})
  48. endfunction(add_memcheck_test)
  49. add_executable(remote_block_reader_test remote_block_reader_test.cc $<TARGET_OBJECTS:test_common>)
  50. target_link_libraries(remote_block_reader_test reader proto common ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
  51. add_memcheck_test(remote_block_reader remote_block_reader_test)
  52. add_executable(sasl_digest_md5_test sasl_digest_md5_test.cc)
  53. target_link_libraries(sasl_digest_md5_test common ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
  54. add_memcheck_test(sasl_digest_md5 sasl_digest_md5_test)
  55. add_executable(inputstream_test inputstream_test.cc)
  56. target_link_libraries(inputstream_test fs rpc reader proto common ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
  57. add_memcheck_test(inputstream inputstream_test)
  58. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  59. add_executable(rpc_engine_test rpc_engine_test.cc ${PROTO_TEST_SRCS} ${PROTO_TEST_HDRS} $<TARGET_OBJECTS:test_common>)
  60. target_link_libraries(rpc_engine_test rpc proto common ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
  61. add_memcheck_test(rpc_engine rpc_engine_test)
  62. add_executable(bad_datanode_test bad_datanode_test.cc)
  63. target_link_libraries(bad_datanode_test rpc reader proto fs bindings_c rpc proto common reader ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
  64. add_memcheck_test(bad_datanode bad_datanode_test)
  65. add_executable(node_exclusion_test node_exclusion_test.cc)
  66. target_link_libraries(node_exclusion_test fs gmock_main common ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
  67. add_memcheck_test(node_exclusion node_exclusion_test)
  68. add_executable(configuration_test configuration_test.cc)
  69. target_link_libraries(configuration_test common gmock_main ${CMAKE_THREAD_LIBS_INIT})
  70. add_memcheck_test(configuration configuration_test)
  71. build_libhdfs_test(libhdfs_threaded hdfspp_test_shim_static expect.c test_libhdfs_threaded.c ${OS_DIR}/thread.c)
  72. link_libhdfs_test(libhdfs_threaded hdfspp_test_shim_static fs reader rpc proto common ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} native_mini_dfs ${JAVA_JVM_LIBRARY})
  73. add_libhdfs_test(libhdfs_threaded hdfspp_test_shim_static)