Browse Source

HDFS-9253. Refactor tests of libhdfs into a directory. Contributed by Haohui Mai.

Haohui Mai 9 years ago
parent
commit
79b8d60d08
38 changed files with 111 additions and 115 deletions
  1. 4 4
      hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml
  2. 18 0
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt
  3. 1 0
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/CMakeLists.txt
  4. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/hdfs_http_client.h
  5. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/hdfs_json_parser.c
  6. 2 2
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/hdfs_web.c
  7. 2 2
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/test_libwebhdfs_ops.c
  8. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/test_libwebhdfs_read.c
  9. 3 3
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/test_libwebhdfs_threaded.c
  10. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/test_libwebhdfs_write.c
  11. 2 0
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/CMakeLists.txt
  12. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_connect.c
  13. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_context_handle.h
  14. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_file_handle.h
  15. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_stat_struct.h
  16. 0 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_trash.c
  17. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_trash.h
  18. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/test/fuse_workload.c
  19. 3 3
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/test/test_fuse_dfs.c
  20. 41 0
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/CMakeLists.txt
  21. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/expect.c
  22. 0 0
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/expect.h
  23. 0 0
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/hdfs_test.h
  24. 0 0
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/native_mini_dfs.c
  25. 0 0
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/native_mini_dfs.h
  26. 0 0
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_htable.c
  27. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_ops.c
  28. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_read.c
  29. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_threaded.c
  30. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_write.c
  31. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_zerocopy.c
  32. 0 0
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_native_mini_dfs.c
  33. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/vecsum.c
  34. 14 81
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt
  35. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/exception.c
  36. 1 1
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/hdfs.c
  37. 0 0
      hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/include/hdfs/hdfs.h
  38. 2 0
      hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

+ 4 - 4
hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml

@@ -176,7 +176,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
                         <echo message="Finished @{test}"/>
                       </sequential>
                     </macrodef>
-                    <run-test test="test_libhdfs_threaded"/>
+                    <run-test test="test_libhdfs_threaded_hdfs_static"/>
                     <echo message="Skipping test_libhdfs_zerocopy"/>
                     <run-test test="test_native_mini_dfs"/>
                   </target>
@@ -237,9 +237,9 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
                         <echo message="Finished @{test}"/>
                       </sequential>
                     </macrodef>
-                    <run-test test="test_libhdfs_threaded"/>
-                    <run-test test="test_libhdfs_zerocopy"/>
-                    <run-test test="test_native_mini_dfs"/>
+                    <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>

+ 18 - 0
hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt

@@ -66,7 +66,25 @@ endif()
 # Configure JNI.
 include(HadoopJNI)
 
+function(add_libhdfs_test NAME LIBRARY)
+    set(FILES)
+    foreach(FIL ${ARGN})
+        if (IS_ABSOLUTE ${FIL})
+            list(APPEND FILES ${FIL})
+        else()
+            list(APPEND FILES ${CMAKE_SOURCE_DIR}/main/native/libhdfs-tests/${FIL})
+        endif()
+    endforeach()
+    add_executable("${NAME}_${LIBRARY}" ${FILES})
+endfunction()
+
+function(link_libhdfs_test NAME LIBRARY)
+target_link_libraries("${NAME}_${LIBRARY}" ${LIBRARY} ${ARGN})
+endfunction()
+
 add_subdirectory(main/native/libhdfs)
+add_subdirectory(main/native/libhdfs-tests)
+
 
 if(REQUIRE_LIBWEBHDFS)
     add_subdirectory(contrib/libwebhdfs)

+ 1 - 0
hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/CMakeLists.txt

@@ -27,6 +27,7 @@ include_directories(
     ${CMAKE_BINARY_DIR}
     ${CMAKE_SOURCE_DIR}/main/native
     ${CMAKE_SOURCE_DIR}/main/native/libhdfs
+    ${CMAKE_SOURCE_DIR}/main/native/libhdfs/include
     ${OS_DIR}
     ${JANSSON_INCLUDE_DIR}
 )

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/hdfs_http_client.h

@@ -21,7 +21,7 @@
 #ifndef _HDFS_HTTP_CLIENT_H_
 #define _HDFS_HTTP_CLIENT_H_
 
-#include "hdfs.h" /* for tSize */
+#include "hdfs/hdfs.h" /* for tSize */
 
 #include <pthread.h> /* for pthread_t */
 #include <unistd.h> /* for size_t */

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/hdfs_json_parser.c

@@ -17,7 +17,7 @@
  */
 
 #include "exception.h"
-#include "hdfs.h" /* for hdfsFileInfo */
+#include "hdfs/hdfs.h" /* for hdfsFileInfo */
 #include "hdfs_json_parser.h"
 
 #include <stdlib.h>

+ 2 - 2
hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/hdfs_web.c

@@ -20,8 +20,8 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "exception.h"
-#include "hdfs.h"
+#include "libhdfs/exception.h"
+#include "hdfs/hdfs.h"
 #include "hdfs_http_client.h"
 #include "hdfs_http_query.h"
 #include "hdfs_json_parser.h"

+ 2 - 2
hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/test_libwebhdfs_ops.c

@@ -16,8 +16,8 @@
  * limitations under the License.
  */
 
-#include "hdfs.h"
-#include "native_mini_dfs.h"
+#include "hdfs/hdfs.h"
+#include "libhdfs-tests/native_mini_dfs.h"
 
 #include <inttypes.h>
 #include <jni.h>

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/test_libwebhdfs_read.c

@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "hdfs.h"
+#include "hdfs/hdfs.h"
 
 #include <stdio.h>
 #include <stdlib.h>

+ 3 - 3
hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/test_libwebhdfs_threaded.c

@@ -16,9 +16,9 @@
  * limitations under the License.
  */
 
-#include "expect.h"
-#include "hdfs.h"
-#include "native_mini_dfs.h"
+#include "libhdfs-tests/expect.h"
+#include "hdfs/hdfs.h"
+#include "libhdfs-tests/native_mini_dfs.h"
 
 #include <errno.h>
 #include <semaphore.h>

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/contrib/libwebhdfs/src/test_libwebhdfs_write.c

@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "hdfs.h"
+#include "hdfs/hdfs.h"
 
 #include <limits.h>
 #include <stdio.h>

+ 2 - 0
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/CMakeLists.txt

@@ -36,6 +36,7 @@ include_directories(
     ${JNI_INCLUDE_DIRS}
     ${CMAKE_SOURCE_DIR}/main/native
     ${CMAKE_SOURCE_DIR}/main/native/libhdfs
+    ${CMAKE_SOURCE_DIR}/main/native/libhdfs/include
     ${OS_DIR}
     ${FUSE_INCLUDE_DIRS})
 
@@ -84,5 +85,6 @@ add_executable(test_fuse_dfs
 target_link_libraries(test_fuse_dfs
     ${FUSE_LIBRARIES}
     native_mini_dfs
+    ${JAVA_JVM_LIBRARY}
     pthread
 )

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_connect.c

@@ -19,7 +19,7 @@
 #include "fuse_connect.h"
 #include "fuse_dfs.h"
 #include "fuse_users.h" 
-#include "libhdfs/hdfs.h"
+#include "hdfs/hdfs.h"
 #include "util/tree.h"
 
 #include <inttypes.h>

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_context_handle.h

@@ -19,7 +19,7 @@
 #ifndef __FUSE_CONTEXT_HANDLE_H__
 #define __FUSE_CONTEXT_HANDLE_H__
 
-#include <hdfs.h>
+#include <hdfs/hdfs.h>
 #include <stddef.h>
 #include <sys/types.h>
 

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_file_handle.h

@@ -19,7 +19,7 @@
 #ifndef __FUSE_FILE_HANDLE_H__
 #define __FUSE_FILE_HANDLE_H__
 
-#include <hdfs.h>
+#include <hdfs/hdfs.h>
 #include <pthread.h>
 
 struct hdfsConn;

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_stat_struct.h

@@ -23,7 +23,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include "hdfs.h"
+#include "hdfs/hdfs.h"
 
 /**
  * Converts from a hdfs hdfsFileInfo to a POSIX stat struct

+ 0 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_trash.c

@@ -16,7 +16,6 @@
  * limitations under the License.
  */
 
-#include <hdfs.h>
 #include <inttypes.h>
 #include <stdarg.h>
 #include <stdio.h>

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/fuse_trash.h

@@ -19,7 +19,7 @@
 #ifndef __FUSE_TRASH_H__
 #define __FUSE_TRASH_H__
 
-#include <hdfs.h>
+#include <hdfs/hdfs.h>
 
 int hdfsDeleteWithTrash(hdfsFS userFS, const char *path, int useTrash);
 

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/test/fuse_workload.c

@@ -19,7 +19,7 @@
 #define FUSE_USE_VERSION 26
 
 #include "fuse-dfs/test/fuse_workload.h"
-#include "libhdfs/expect.h"
+#include "libhdfs-tests/expect.h"
 #include "util/posix_util.h"
 
 #include <dirent.h>

+ 3 - 3
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/fuse-dfs/test/test_fuse_dfs.c

@@ -17,9 +17,9 @@
  */
 
 #include "fuse-dfs/test/fuse_workload.h"
-#include "libhdfs/expect.h"
-#include "libhdfs/hdfs.h"
-#include "libhdfs/native_mini_dfs.h"
+#include "hdfs/hdfs.h"
+#include "libhdfs-tests/expect.h"
+#include "libhdfs-tests/native_mini_dfs.h"
 #include "util/posix_util.h"
 
 #include <ctype.h>

+ 41 - 0
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/CMakeLists.txt

@@ -0,0 +1,41 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include_directories(
+    ${CMAKE_CURRENT_SOURCE_DIR}/../libhdfs/include
+    ${GENERATED_JAVAH}
+    ${CMAKE_BINARY_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}/../libhdfs
+    ${JNI_INCLUDE_DIRS}
+    ${OS_DIR}
+)
+
+add_library(native_mini_dfs
+    native_mini_dfs.c
+    ../libhdfs/common/htable.c
+    ../libhdfs/exception.c
+    ../libhdfs/jni_helper.c
+    ${OS_DIR}/mutexes.c
+    ${OS_DIR}/thread_local_storage.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})
+
+add_executable(test_htable ../libhdfs/common/htable.c test_htable.c)
+target_link_libraries(test_htable ${OS_LINK_LIBRARIES})

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/expect.c → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/expect.c

@@ -17,7 +17,7 @@
  */
 
 #include "expect.h"
-#include "hdfs.h"
+#include "hdfs/hdfs.h"
 
 #include <inttypes.h>
 #include <stdio.h>

+ 0 - 0
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/expect.h → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/expect.h


+ 0 - 0
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/hdfs_test.h → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/hdfs_test.h


+ 0 - 0
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/native_mini_dfs.c → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/native_mini_dfs.c


+ 0 - 0
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/native_mini_dfs.h → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/native_mini_dfs.h


+ 0 - 0
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/test/test_htable.c → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_htable.c


+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/test/test_libhdfs_ops.c → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_ops.c

@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "hdfs.h" 
+#include "hdfs/hdfs.h" 
 #include "hdfs_test.h" 
 #include "platform.h"
 

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/test/test_libhdfs_read.c → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_read.c

@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "hdfs.h" 
+#include "hdfs/hdfs.h" 
 
 #include <stdio.h>
 #include <stdlib.h>

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/test_libhdfs_threaded.c → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_threaded.c

@@ -17,7 +17,7 @@
  */
 
 #include "expect.h"
-#include "hdfs.h"
+#include "hdfs/hdfs.h"
 #include "native_mini_dfs.h"
 #include "os/thread.h"
 

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/test/test_libhdfs_write.c → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_write.c

@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-#include "hdfs.h" 
+#include "hdfs/hdfs.h" 
 
 #include <limits.h>
 #include <stdio.h>

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/test/test_libhdfs_zerocopy.c → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_zerocopy.c

@@ -17,7 +17,7 @@
  */
 
 #include "expect.h"
-#include "hdfs.h"
+#include "hdfs/hdfs.h"
 #include "native_mini_dfs.h"
 #include "platform.h"
 

+ 0 - 0
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/test_native_mini_dfs.c → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_native_mini_dfs.c


+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/test/vecsum.c → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/vecsum.c

@@ -36,7 +36,7 @@
 #endif
 
 #include "config.h"
-#include "hdfs.h"
+#include "hdfs/hdfs.h"
 
 #define VECSUM_CHUNK_SIZE (8 * 1024 * 1024)
 #define ZCR_READ_CHUNK_SIZE (1024 * 1024 * 8)

+ 14 - 81
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt

@@ -18,6 +18,7 @@
 add_definitions(-DLIBHDFS_DLL_EXPORT)
 
 include_directories(
+    include
     ${GENERATED_JAVAH}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_BINARY_DIR}
@@ -50,92 +51,24 @@ set(LIBHDFS_VERSION "0.0.0")
 set_target_properties(hdfs PROPERTIES
     SOVERSION ${LIBHDFS_VERSION})
 
-add_executable(test_libhdfs_ops
-    test/test_libhdfs_ops.c
-)
-target_link_libraries(test_libhdfs_ops
-    hdfs_static
-    ${JAVA_JVM_LIBRARY}
-)
-
-add_executable(test_libhdfs_read
-    test/test_libhdfs_read.c
-)
-target_link_libraries(test_libhdfs_read
-    hdfs_static
-    ${JAVA_JVM_LIBRARY}
-)
-
-add_executable(test_libhdfs_write
-    test/test_libhdfs_write.c
-)
-target_link_libraries(test_libhdfs_write
-    hdfs_static
-    ${JAVA_JVM_LIBRARY}
-)
-
-add_library(native_mini_dfs
-    native_mini_dfs.c
-    common/htable.c
-    exception.c
-    jni_helper.c
-    ${OS_DIR}/mutexes.c
-    ${OS_DIR}/thread_local_storage.c
-)
-target_link_libraries(native_mini_dfs
-    ${JAVA_JVM_LIBRARY}
-    ${LIB_DL}
-    ${OS_LINK_LIBRARIES}
-)
-
-add_executable(test_native_mini_dfs
-    test_native_mini_dfs.c
-)
-target_link_libraries(test_native_mini_dfs
-    native_mini_dfs
-)
-
-add_executable(test_libhdfs_threaded
-    expect.c
-    test_libhdfs_threaded.c
-    ${OS_DIR}/thread.c
-)
-target_link_libraries(test_libhdfs_threaded
-    hdfs_static
-    native_mini_dfs
-    ${OS_LINK_LIBRARIES}
-)
-
-add_executable(test_libhdfs_zerocopy
-    expect.c
-    test/test_libhdfs_zerocopy.c
-)
-target_link_libraries(test_libhdfs_zerocopy
-    hdfs_static
-    native_mini_dfs
-    ${OS_LINK_LIBRARIES}
-)
-
-add_executable(test_htable
-    common/htable.c
-    test/test_htable.c
-)
-target_link_libraries(test_htable
-    ${OS_LINK_LIBRARIES}
-)
+add_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)
+link_libhdfs_test(test_libhdfs_reads hdfs_static ${JAVA_JVM_LIBRARY})
+add_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)
+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)
+link_libhdfs_test(test_libhdfs_zerocopy hdfs_static native_mini_dfs ${OS_LINK_LIBRARIES})
 
 # 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_executable(test_libhdfs_vecsum test/vecsum.c)
+    add_libhdfs_test(test_libhdfs_vecsum hdfs vecsum.c)
     if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
-        target_link_libraries(test_libhdfs_vecsum
-            hdfs
-            pthread)
+        link_libhdfs_test(test_libhdfs_vecsum hdfs pthread)
     else()
-        target_link_libraries(test_libhdfs_vecsum
-            hdfs
-            pthread
-            rt)
+        link_libhdfs_test(test_libhdfs_vecsum hdfs pthread rt)
     endif()
 endif()

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/exception.c

@@ -17,7 +17,7 @@
  */
 
 #include "exception.h"
-#include "hdfs.h"
+#include "hdfs/hdfs.h"
 #include "jni_helper.h"
 #include "platform.h"
 

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/hdfs.c

@@ -17,7 +17,7 @@
  */
 
 #include "exception.h"
-#include "hdfs.h"
+#include "hdfs/hdfs.h"
 #include "jni_helper.h"
 #include "platform.h"
 

+ 0 - 0
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/hdfs.h → hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/include/hdfs/hdfs.h


+ 2 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -1568,6 +1568,8 @@ Release 2.8.0 - UNRELEASED
     HDFS-9167. Update pom.xml in other modules to depend on hdfs-client instead
     of hdfs. (Mingliang Liu via wheat9)
 
+    HDFS-9253. Refactor tests of libhdfs into a directory. (wheat9)
+
   BUG FIXES
 
     HDFS-7501. TransactionsSinceLastCheckpoint can be negative on SBNs.