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

View File

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

View File

@ -36,6 +36,7 @@ add_library(native_mini_dfs
add_executable(test_native_mini_dfs test_native_mini_dfs.c)
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)
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
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})
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})
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})
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)
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})
add_libhdfs_test(test_libhdfs_zerocopy hdfs_static)
endif()
# Skip vecsum on Windows. This could be made to work in the future by
# introducing an abstraction layer over the sys/mman.h functions.
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")
link_libhdfs_test(test_libhdfs_vecsum hdfs pthread)
else()

View File

@ -793,6 +793,8 @@ Release 2.8.0 - UNRELEASED
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
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than