HDFS-9448. Enable valgrind for libhdfspp unit tests. Contributed by Bob Hansen.
This commit is contained in:
parent
6c80d02a03
commit
dba377bfcc
@ -63,6 +63,7 @@ RUN apt-get -q update && apt-get -q install -y \
|
|||||||
pkg-config \
|
pkg-config \
|
||||||
python \
|
python \
|
||||||
python2.7 \
|
python2.7 \
|
||||||
|
pylint \
|
||||||
python-pip \
|
python-pip \
|
||||||
python-pkg-resources \
|
python-pkg-resources \
|
||||||
python-setuptools \
|
python-setuptools \
|
||||||
@ -71,7 +72,8 @@ RUN apt-get -q update && apt-get -q install -y \
|
|||||||
software-properties-common \
|
software-properties-common \
|
||||||
snappy \
|
snappy \
|
||||||
sudo \
|
sudo \
|
||||||
zlib1g-dev
|
zlib1g-dev \
|
||||||
|
valgrind
|
||||||
|
|
||||||
#######
|
#######
|
||||||
# OpenJDK 8
|
# OpenJDK 8
|
||||||
|
@ -33,6 +33,10 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|||||||
<require.fuse>false</require.fuse>
|
<require.fuse>false</require.fuse>
|
||||||
<hadoop.component>hdfs</hadoop.component>
|
<hadoop.component>hdfs</hadoop.component>
|
||||||
<require.libwebhdfs>false</require.libwebhdfs>
|
<require.libwebhdfs>false</require.libwebhdfs>
|
||||||
|
<require.valgrind>false</require.valgrind>
|
||||||
|
<native_ctest_args></native_ctest_args>
|
||||||
|
<native_cmake_args></native_cmake_args>
|
||||||
|
<native_make_args></native_make_args>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -143,11 +147,13 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|||||||
<mkdir dir="${project.build.directory}/native"/>
|
<mkdir dir="${project.build.directory}/native"/>
|
||||||
<exec executable="cmake" dir="${project.build.directory}/native"
|
<exec executable="cmake" dir="${project.build.directory}/native"
|
||||||
failonerror="true">
|
failonerror="true">
|
||||||
<arg line="${basedir}/src/ -DGENERATED_JAVAH=${project.build.directory}/native/javah -DJVM_ARCH_DATA_MODEL=${sun.arch.data.model} -DREQUIRE_FUSE=${require.fuse} -A '${env.PLATFORM}'"/>
|
<arg line="${basedir}/src/ -DGENERATED_JAVAH=${project.build.directory}/native/javah -DJVM_ARCH_DATA_MODEL=${sun.arch.data.model} -DREQUIRE_FUSE=${require.fuse} -DREQUIRE_VALGRIND=${require.valgrind} -A '${env.PLATFORM}'"/>
|
||||||
|
<arg line="${native_cmake_args}"/>
|
||||||
</exec>
|
</exec>
|
||||||
<exec executable="msbuild" dir="${project.build.directory}/native"
|
<exec executable="msbuild" dir="${project.build.directory}/native"
|
||||||
failonerror="true">
|
failonerror="true">
|
||||||
<arg line="ALL_BUILD.vcxproj /nologo /p:Configuration=RelWithDebInfo /p:LinkIncremental=false"/>
|
<arg line="ALL_BUILD.vcxproj /nologo /p:Configuration=RelWithDebInfo /p:LinkIncremental=false"/>
|
||||||
|
<arg line="${native_make_args}"/>
|
||||||
</exec>
|
</exec>
|
||||||
<!-- Copy for inclusion in distribution. -->
|
<!-- Copy for inclusion in distribution. -->
|
||||||
<copy todir="${project.build.directory}/bin">
|
<copy todir="${project.build.directory}/bin">
|
||||||
@ -202,13 +208,16 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|||||||
<phase>compile</phase>
|
<phase>compile</phase>
|
||||||
<goals><goal>cmake-compile</goal></goals>
|
<goals><goal>cmake-compile</goal></goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${basedir}/src</source>
|
<target>
|
||||||
<vars>
|
<mkdir dir="${project.build.directory}"/>
|
||||||
<GENERATED_JAVAH>${project.build.directory}/native/javah</GENERATED_JAVAH>
|
<exec executable="cmake" dir="${project.build.directory}" failonerror="true">
|
||||||
<JVM_ARCH_DATA_MODEL>${sun.arch.data.model}</JVM_ARCH_DATA_MODEL>
|
<arg line="${basedir}/src/ -DGENERATED_JAVAH=${project.build.directory}/native/javah -DJVM_ARCH_DATA_MODEL=${sun.arch.data.model} -DREQUIRE_LIBWEBHDFS=${require.libwebhdfs} -DREQUIRE_FUSE=${require.fuse} -DREQUIRE_VALGRIND=${require.valgrind} "/>
|
||||||
<REQUIRE_FUSE>${require.fuse}</REQUIRE_FUSE>
|
<arg line="${native_cmake_args}"/>
|
||||||
</vars>
|
</exec>
|
||||||
<output>${project.build.directory}</output>
|
<exec executable="make" dir="${project.build.directory}" failonerror="true">
|
||||||
|
<arg line="${native_make_args}"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@ -227,6 +236,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|||||||
<property name="compile_classpath" refid="maven.compile.classpath"/>
|
<property name="compile_classpath" refid="maven.compile.classpath"/>
|
||||||
<property name="test_classpath" refid="maven.test.classpath"/>
|
<property name="test_classpath" refid="maven.test.classpath"/>
|
||||||
<exec executable="ctest" failonerror="true" dir="${project.build.directory}/">
|
<exec executable="ctest" failonerror="true" dir="${project.build.directory}/">
|
||||||
|
<arg line="${native_ctest_args}"/>
|
||||||
<env key="CLASSPATH" value="${test_classpath}:${compile_classpath}"/>
|
<env key="CLASSPATH" value="${test_classpath}:${compile_classpath}"/>
|
||||||
<!-- Make sure libhadoop.so is on LD_LIBRARY_PATH. -->
|
<!-- Make sure libhadoop.so is on LD_LIBRARY_PATH. -->
|
||||||
<env key="LD_LIBRARY_PATH" value="${env.LD_LIBRARY_PATH}:${project.build.directory}/native/target/usr/local/lib:${hadoop.common.build.dir}/native/target/usr/local/lib"/>
|
<env key="LD_LIBRARY_PATH" value="${env.LD_LIBRARY_PATH}:${project.build.directory}/native/target/usr/local/lib:${hadoop.common.build.dir}/native/target/usr/local/lib"/>
|
||||||
|
@ -19,14 +19,26 @@
|
|||||||
project (libhdfspp)
|
project (libhdfspp)
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
include (CTest)
|
||||||
|
|
||||||
find_package(Doxygen)
|
find_package(Doxygen)
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
find_package(Protobuf REQUIRED)
|
find_package(Protobuf REQUIRED)
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
|
|
||||||
|
find_program(MEMORYCHECK_COMMAND valgrind HINTS ${VALGRIND_DIR} )
|
||||||
|
set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full --error-exitcode=1")
|
||||||
|
message(STATUS "valgrind location: ${MEMORYCHECK_COMMAND}")
|
||||||
|
|
||||||
|
if (REQUIRE_VALGRIND AND MEMORYCHECK_COMMAND MATCHES "MEMORYCHECK_COMMAND-NOTFOUND" )
|
||||||
|
message(FATAL_ERROR "valgrind was required but not found. "
|
||||||
|
"The path can be included via a -DVALGRIND_DIR=... flag passed to CMake.")
|
||||||
|
endif (REQUIRE_VALGRIND AND MEMORYCHECK_COMMAND MATCHES "MEMORYCHECK_COMMAND-NOTFOUND" )
|
||||||
|
|
||||||
|
|
||||||
add_definitions(-DASIO_STANDALONE -DASIO_CPP11_DATE_TIME)
|
add_definitions(-DASIO_STANDALONE -DASIO_CPP11_DATE_TIME)
|
||||||
|
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -std=c++11 -g -fPIC -fno-strict-aliasing")
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -std=c++11 -g -fPIC -fno-strict-aliasing")
|
||||||
endif()
|
endif()
|
||||||
|
@ -43,34 +43,47 @@ protobuf_generate_cpp(PROTO_TEST_SRCS PROTO_TEST_HDRS
|
|||||||
${PROTO_HADOOP_TEST_DIR}/test_rpc_service.proto
|
${PROTO_HADOOP_TEST_DIR}/test_rpc_service.proto
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Shamelessly stolen from
|
||||||
|
# http://stackoverflow.com/questions/9303711/how-do-i-make-ctest-run-a-program-with-valgrind-without-dart
|
||||||
|
function(add_memcheck_test name binary)
|
||||||
|
add_test(${name} ${binary} ${ARGN})
|
||||||
|
|
||||||
|
if(NOT MEMORYCHECK_COMMAND MATCHES "MEMORYCHECK_COMMAND-NOTFOUND" AND NOT SKIP_VALGRIND)
|
||||||
|
set(memcheck_command "${MEMORYCHECK_COMMAND} ${MEMORYCHECK_COMMAND_OPTIONS}")
|
||||||
|
separate_arguments(memcheck_command)
|
||||||
|
add_test(memcheck_${name} ${memcheck_command} ./${binary} ${ARGN})
|
||||||
|
endif()
|
||||||
|
endfunction(add_memcheck_test)
|
||||||
|
|
||||||
|
|
||||||
add_executable(remote_block_reader_test remote_block_reader_test.cc $<TARGET_OBJECTS:test_common>)
|
add_executable(remote_block_reader_test remote_block_reader_test.cc $<TARGET_OBJECTS:test_common>)
|
||||||
target_link_libraries(remote_block_reader_test reader proto common connection ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(remote_block_reader_test reader proto common connection ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
||||||
add_test(remote_block_reader remote_block_reader_test)
|
add_memcheck_test(remote_block_reader remote_block_reader_test)
|
||||||
|
|
||||||
add_executable(sasl_digest_md5_test sasl_digest_md5_test.cc)
|
add_executable(sasl_digest_md5_test sasl_digest_md5_test.cc)
|
||||||
target_link_libraries(sasl_digest_md5_test common ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(sasl_digest_md5_test common ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
||||||
add_test(sasl_digest_md5 sasl_digest_md5_test)
|
add_memcheck_test(sasl_digest_md5 sasl_digest_md5_test)
|
||||||
|
|
||||||
add_executable(retry_policy_test retry_policy_test.cc)
|
add_executable(retry_policy_test retry_policy_test.cc)
|
||||||
target_link_libraries(retry_policy_test common gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(retry_policy_test common gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
||||||
add_test(retry_policy retry_policy_test)
|
add_memcheck_test(retry_policy retry_policy_test)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
add_executable(rpc_engine_test rpc_engine_test.cc ${PROTO_TEST_SRCS} ${PROTO_TEST_HDRS} $<TARGET_OBJECTS:test_common>)
|
add_executable(rpc_engine_test rpc_engine_test.cc ${PROTO_TEST_SRCS} ${PROTO_TEST_HDRS} $<TARGET_OBJECTS:test_common>)
|
||||||
target_link_libraries(rpc_engine_test rpc proto common ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(rpc_engine_test rpc proto common ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
||||||
add_test(rpc_engine rpc_engine_test)
|
add_memcheck_test(rpc_engine rpc_engine_test)
|
||||||
|
|
||||||
add_executable(bad_datanode_test bad_datanode_test.cc)
|
add_executable(bad_datanode_test bad_datanode_test.cc)
|
||||||
target_link_libraries(bad_datanode_test rpc reader proto fs bindings_c rpc proto common reader connection ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(bad_datanode_test rpc reader proto fs bindings_c rpc proto common reader connection ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
||||||
add_test(bad_datanode bad_datanode_test)
|
add_memcheck_test(bad_datanode bad_datanode_test)
|
||||||
|
|
||||||
add_executable(node_exclusion_test node_exclusion_test.cc)
|
add_executable(node_exclusion_test node_exclusion_test.cc)
|
||||||
target_link_libraries(node_exclusion_test fs gmock_main common ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(node_exclusion_test fs gmock_main common ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
add_test(node_exclusion node_exclusion_test)
|
add_memcheck_test(node_exclusion node_exclusion_test)
|
||||||
|
|
||||||
add_executable(configuration_test configuration_test.cc)
|
add_executable(configuration_test configuration_test.cc)
|
||||||
target_link_libraries(configuration_test common gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(configuration_test common gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
||||||
add_test(configuration configuration_test)
|
add_memcheck_test(configuration configuration_test)
|
||||||
|
|
||||||
add_executable(hdfs_configuration_test hdfs_configuration_test.cc)
|
add_executable(hdfs_configuration_test hdfs_configuration_test.cc)
|
||||||
target_link_libraries(hdfs_configuration_test common gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(hdfs_configuration_test common gmock_main ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
@ -242,5 +242,9 @@ int main(int argc, char *argv[]) {
|
|||||||
// The following line must be executed to initialize Google Mock
|
// The following line must be executed to initialize Google Mock
|
||||||
// (and Google Test) before running the tests.
|
// (and Google Test) before running the tests.
|
||||||
::testing::InitGoogleMock(&argc, argv);
|
::testing::InitGoogleMock(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
int exit_code = RUN_ALL_TESTS();
|
||||||
|
|
||||||
|
// Clean up static data and prevent valgrind memory leaks
|
||||||
|
google::protobuf::ShutdownProtobufLibrary();
|
||||||
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
@ -410,5 +410,9 @@ int main(int argc, char *argv[]) {
|
|||||||
// The following line must be executed to initialize Google Mock
|
// The following line must be executed to initialize Google Mock
|
||||||
// (and Google Test) before running the tests.
|
// (and Google Test) before running the tests.
|
||||||
::testing::InitGoogleMock(&argc, argv);
|
::testing::InitGoogleMock(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
int exit_code = RUN_ALL_TESTS();
|
||||||
|
|
||||||
|
// Clean up static data and prevent valgrind memory leaks
|
||||||
|
google::protobuf::ShutdownProtobufLibrary();
|
||||||
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
@ -395,5 +395,9 @@ int main(int argc, char *argv[]) {
|
|||||||
// The following line must be executed to initialize Google Mock
|
// The following line must be executed to initialize Google Mock
|
||||||
// (and Google Test) before running the tests.
|
// (and Google Test) before running the tests.
|
||||||
::testing::InitGoogleMock(&argc, argv);
|
::testing::InitGoogleMock(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
int exit_code = RUN_ALL_TESTS();
|
||||||
|
|
||||||
|
// Clean up static data and prevent valgrind memory leaks
|
||||||
|
google::protobuf::ShutdownProtobufLibrary();
|
||||||
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user