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

This commit is contained in:
Haohui Mai 2015-10-16 11:20:17 -07:00
parent 52ac73f344
commit 79b8d60d08
38 changed files with 111 additions and 115 deletions

View File

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

View File

@ -66,7 +66,25 @@ endif()
# Configure JNI. # Configure JNI.
include(HadoopJNI) 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)
add_subdirectory(main/native/libhdfs-tests)
if(REQUIRE_LIBWEBHDFS) if(REQUIRE_LIBWEBHDFS)
add_subdirectory(contrib/libwebhdfs) add_subdirectory(contrib/libwebhdfs)

View File

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

View File

@ -21,7 +21,7 @@
#ifndef _HDFS_HTTP_CLIENT_H_ #ifndef _HDFS_HTTP_CLIENT_H_
#define _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 <pthread.h> /* for pthread_t */
#include <unistd.h> /* for size_t */ #include <unistd.h> /* for size_t */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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})

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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