HDFS-9369. Use ctest to run tests for hadoop-hdfs-native-client. Contributed by Haohui Mai.

This commit is contained in:
Haohui Mai 2015-11-03 13:19:24 -08:00
parent c99925d6dd
commit a06e6b81e0
5 changed files with 35 additions and 39 deletions

View File

@ -162,23 +162,15 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<target> <target>
<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"/>
<macrodef name="run-test"> <target>
<attribute name="test"/> <property name="compile_classpath" refid="maven.compile.classpath"/>
<sequential> <property name="test_classpath" refid="maven.test.classpath"/>
<echo message="Running @{test}"/> <exec executable="ctest" failonerror="true" dir="${project.build.directory}/">
<exec executable="${project.build.directory}/native/RelWithDebInfo/@{test}" failonerror="true" dir="${project.build.directory}/native/"> <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. -->
<!-- HADOOP_HOME required to find winutils. --> <env key="LD_LIBRARY_PATH" value="${env.LD_LIBRARY_PATH}:${project.build.directory}/target/usr/local/lib:${hadoop.common.build.dir}/native/target/usr/local/lib"/>
<env key="HADOOP_HOME" value="${hadoop.common.build.dir}"/> </exec>
<!-- Make sure hadoop.dll and jvm.dll are on PATH. --> </target>
<env key="PATH" value="${env.PATH};${hadoop.common.build.dir}/bin;${java.home}/jre/bin/server;${java.home}/bin/server"/>
</exec>
<echo message="Finished @{test}"/>
</sequential>
</macrodef>
<run-test test="test_libhdfs_threaded_hdfs_static"/>
<echo message="Skipping test_libhdfs_zerocopy"/>
<run-test test="test_native_mini_dfs"/>
</target> </target>
</configuration> </configuration>
</execution> </execution>
@ -225,21 +217,11 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<target> <target>
<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"/>
<macrodef name="run-test"> <exec executable="ctest" failonerror="true" dir="${project.build.directory}/">
<attribute name="test"/> <env key="CLASSPATH" value="${test_classpath}:${compile_classpath}"/>
<sequential> <!-- Make sure libhadoop.so is on LD_LIBRARY_PATH. -->
<echo message="Running @{test} ${compile_classpath} ${test_classpath}"/> <env key="LD_LIBRARY_PATH" value="${env.LD_LIBRARY_PATH}:${project.build.directory}/target/usr/local/lib:${hadoop.common.build.dir}/native/target/usr/local/lib"/>
<exec executable="${project.build.directory}/main/native/libhdfs/@{test}" failonerror="true" dir="${project.build.directory}/"> </exec>
<env key="CLASSPATH" value="${test_classpath}:${compile_classpath}"/>
<!-- Make sure libhadoop.so is on LD_LIBRARY_PATH. -->
<env key="LD_LIBRARY_PATH" value="${env.LD_LIBRARY_PATH}:${project.build.directory}/target/usr/local/lib:${hadoop.common.build.dir}/native/target/usr/local/lib"/>
</exec>
<echo message="Finished @{test}"/>
</sequential>
</macrodef>
<run-test test="test_libhdfs_threaded_hdfs_static"/>
<run-test test="test_libhdfs_zerocopy_hdfs_static"/>
<run-test test="../libhdfs-tests/test_native_mini_dfs"/>
</target> </target>
</configuration> </configuration>
</execution> </execution>

View File

@ -18,6 +18,8 @@
cmake_minimum_required(VERSION 2.6 FATAL_ERROR) cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
enable_testing()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../../../hadoop-common-project/hadoop-common) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../../../hadoop-common-project/hadoop-common)
include(HadoopCommon) include(HadoopCommon)
@ -66,7 +68,7 @@ endif()
# Configure JNI. # Configure JNI.
include(HadoopJNI) include(HadoopJNI)
function(add_libhdfs_test NAME LIBRARY) function(build_libhdfs_test NAME LIBRARY)
set(FILES) set(FILES)
foreach(FIL ${ARGN}) foreach(FIL ${ARGN})
if (IS_ABSOLUTE ${FIL}) if (IS_ABSOLUTE ${FIL})
@ -78,6 +80,10 @@ function(add_libhdfs_test NAME LIBRARY)
add_executable("${NAME}_${LIBRARY}" ${FILES}) add_executable("${NAME}_${LIBRARY}" ${FILES})
endfunction() endfunction()
function(add_libhdfs_test NAME LIBRARY)
add_test("test_${NAME}_${LIBRARY}" "${NAME}_${LIBRARY}")
endfunction()
function(link_libhdfs_test NAME LIBRARY) function(link_libhdfs_test NAME LIBRARY)
target_link_libraries("${NAME}_${LIBRARY}" ${LIBRARY} ${ARGN}) target_link_libraries("${NAME}_${LIBRARY}" ${LIBRARY} ${ARGN})
endfunction() endfunction()

View File

@ -36,6 +36,7 @@ add_library(native_mini_dfs
add_executable(test_native_mini_dfs test_native_mini_dfs.c) add_executable(test_native_mini_dfs test_native_mini_dfs.c)
target_link_libraries(test_native_mini_dfs native_mini_dfs ${JAVA_JVM_LIBRARY}) target_link_libraries(test_native_mini_dfs native_mini_dfs ${JAVA_JVM_LIBRARY})
add_test(test_test_native_mini_dfs test_native_mini_dfs)
add_executable(test_htable ../libhdfs/common/htable.c test_htable.c) add_executable(test_htable ../libhdfs/common/htable.c test_htable.c)
target_link_libraries(test_htable ${OS_LINK_LIBRARIES}) target_link_libraries(test_htable ${OS_LINK_LIBRARIES})

View File

@ -51,21 +51,26 @@ set(LIBHDFS_VERSION "0.0.0")
set_target_properties(hdfs PROPERTIES set_target_properties(hdfs PROPERTIES
SOVERSION ${LIBHDFS_VERSION}) SOVERSION ${LIBHDFS_VERSION})
add_libhdfs_test(test_libhdfs_ops hdfs_static test_libhdfs_ops.c) build_libhdfs_test(test_libhdfs_ops hdfs_static test_libhdfs_ops.c)
link_libhdfs_test(test_libhdfs_ops hdfs_static ${JAVA_JVM_LIBRARY}) link_libhdfs_test(test_libhdfs_ops hdfs_static ${JAVA_JVM_LIBRARY})
add_libhdfs_test(test_libhdfs_reads hdfs_static test_libhdfs_read.c) build_libhdfs_test(test_libhdfs_reads hdfs_static test_libhdfs_read.c)
link_libhdfs_test(test_libhdfs_reads hdfs_static ${JAVA_JVM_LIBRARY}) link_libhdfs_test(test_libhdfs_reads hdfs_static ${JAVA_JVM_LIBRARY})
add_libhdfs_test(test_libhdfs_write hdfs_static test_libhdfs_write.c) build_libhdfs_test(test_libhdfs_write hdfs_static test_libhdfs_write.c)
link_libhdfs_test(test_libhdfs_write hdfs_static ${JAVA_JVM_LIBRARY}) link_libhdfs_test(test_libhdfs_write hdfs_static ${JAVA_JVM_LIBRARY})
add_libhdfs_test(test_libhdfs_threaded hdfs_static expect.c test_libhdfs_threaded.c ${OS_DIR}/thread.c) build_libhdfs_test(test_libhdfs_threaded hdfs_static expect.c test_libhdfs_threaded.c ${OS_DIR}/thread.c)
link_libhdfs_test(test_libhdfs_threaded hdfs_static native_mini_dfs) link_libhdfs_test(test_libhdfs_threaded hdfs_static native_mini_dfs)
add_libhdfs_test(test_libhdfs_zerocopy hdfs_static expect.c test_libhdfs_zerocopy.c) add_libhdfs_test(test_libhdfs_threaded hdfs_static)
if (NOT WIN32)
build_libhdfs_test(test_libhdfs_zerocopy hdfs_static expect.c test_libhdfs_zerocopy.c)
link_libhdfs_test(test_libhdfs_zerocopy hdfs_static native_mini_dfs ${OS_LINK_LIBRARIES}) link_libhdfs_test(test_libhdfs_zerocopy hdfs_static native_mini_dfs ${OS_LINK_LIBRARIES})
add_libhdfs_test(test_libhdfs_zerocopy hdfs_static)
endif()
# Skip vecsum on Windows. This could be made to work in the future by # Skip vecsum on Windows. This could be made to work in the future by
# introducing an abstraction layer over the sys/mman.h functions. # introducing an abstraction layer over the sys/mman.h functions.
if(NOT WIN32) if(NOT WIN32)
add_libhdfs_test(test_libhdfs_vecsum hdfs vecsum.c) build_libhdfs_test(test_libhdfs_vecsum hdfs vecsum.c)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin") if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
link_libhdfs_test(test_libhdfs_vecsum hdfs pthread) link_libhdfs_test(test_libhdfs_vecsum hdfs pthread)
else() else()

View File

@ -1649,6 +1649,8 @@ Release 2.8.0 - UNRELEASED
HDFS-2261. AOP unit tests are not getting compiled or run. (wheat9) HDFS-2261. AOP unit tests are not getting compiled or run. (wheat9)
HDFS-9369. Use ctest to run tests for hadoop-hdfs-native-client. (wheat9)
OPTIMIZATIONS OPTIMIZATIONS
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than