HDFS-9369. Use ctest to run tests for hadoop-hdfs-native-client. Contributed by Haohui Mai.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/a06e6b81 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/a06e6b81 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/a06e6b81 Branch: refs/heads/HDFS-8707 Commit: a06e6b81e08d6a6df62334cf51232e141861025f Parents: c99925d Author: Haohui Mai <whe...@apache.org> Authored: Tue Nov 3 13:19:24 2015 -0800 Committer: Haohui Mai <whe...@apache.org> Committed: Tue Nov 10 14:53:05 2015 -0800 ---------------------------------------------------------------------- .../hadoop-hdfs-native-client/pom.xml | 46 ++++++-------------- .../src/CMakeLists.txt | 8 +++- .../main/native/libhdfs-tests/CMakeLists.txt | 1 + .../src/main/native/libhdfs/CMakeLists.txt | 17 +++++--- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 + 5 files changed, 35 insertions(+), 39 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/a06e6b81/hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml b/hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml index b8d9664..a966a28 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml @@ -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/"> - <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"/> - </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> + <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}"/> + <!-- 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> + </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}/"> - <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"/> + <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> </target> </configuration> </execution> http://git-wip-us.apache.org/repos/asf/hadoop/blob/a06e6b81/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt index e3e6152..0a6f383 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt @@ -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() http://git-wip-us.apache.org/repos/asf/hadoop/blob/a06e6b81/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/CMakeLists.txt index 473e762..08c9f8b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/CMakeLists.txt @@ -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}) http://git-wip-us.apache.org/repos/asf/hadoop/blob/a06e6b81/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt index 2535cdd..a0cd042 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt @@ -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() http://git-wip-us.apache.org/repos/asf/hadoop/blob/a06e6b81/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 336db03..e55bcd6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1649,6 +1649,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