Skip to content

Commit f082b17

Browse files
committed
ARROW-383: [C++] Integration testing CLI tool
Modeled after Java version in ARROW-367 Author: Wes McKinney <wes.mckinney@twosigma.com> Closes #209 from wesm/ARROW-383 and squashes the following commits: 7b29b24 [Wes McKinney] Use git master gflags to avoid valgrind error f563d3a [Wes McKinney] Build integration test as a normal unit test executable, opt-in to integration testing bdf1f7a [Wes McKinney] Call the RunCommand method instead dbc6aab [Wes McKinney] Add unit tests for the integration validator ca1eade [Wes McKinney] Clean up includes 1752249 [Wes McKinney] Draft integration testing CLI tool, untested b773d0d [Wes McKinney] Add gflags external project and json-integration-test executable stub
1 parent 997f502 commit f082b17

File tree

6 files changed

+517
-4
lines changed

6 files changed

+517
-4
lines changed

cpp/CMakeLists.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ include(ExternalProject)
2626
set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/build-support")
2727
set(THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/thirdparty")
2828

29+
set(GFLAGS_VERSION "2.1.2")
2930
set(GTEST_VERSION "1.7.0")
3031
set(GBENCHMARK_VERSION "1.0.0")
3132
set(FLATBUFFERS_VERSION "1.3.0")
@@ -506,6 +507,49 @@ if(ARROW_BUILD_TESTS)
506507
if(GTEST_VENDORED)
507508
add_dependencies(gtest googletest_ep)
508509
endif()
510+
511+
# gflags (formerly Googleflags) command line parsing
512+
if("$ENV{GFLAGS_HOME}" STREQUAL "")
513+
if(APPLE)
514+
set(GFLAGS_CMAKE_CXX_FLAGS "-fPIC -std=c++11 -stdlib=libc++")
515+
else()
516+
set(GFLAGS_CMAKE_CXX_FLAGS "-fPIC")
517+
endif()
518+
519+
set(GFLAGS_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gflags_ep-prefix/src/gflags_ep")
520+
ExternalProject_Add(gflags_ep
521+
GIT_REPOSITORY https://github.com/gflags/gflags.git
522+
GIT_TAG cce68f0c9c5d054017425e6e6fd54f696d36e8ee
523+
# URL "https://github.com/gflags/gflags/archive/v${GFLAGS_VERSION}.tar.gz"
524+
BUILD_IN_SOURCE 1
525+
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
526+
-DCMAKE_INSTALL_PREFIX=${GFLAGS_PREFIX}
527+
-DBUILD_SHARED_LIBS=OFF
528+
-DBUILD_STATIC_LIBS=ON
529+
-DBUILD_PACKAGING=OFF
530+
-DBUILD_TESTING=OFF
531+
-BUILD_CONFIG_TESTS=OFF
532+
-DINSTALL_HEADERS=ON
533+
-DCMAKE_CXX_FLAGS=${GFLAGS_CMAKE_CXX_FLAGS})
534+
535+
set(GFLAGS_HOME "${GFLAGS_PREFIX}")
536+
set(GFLAGS_INCLUDE_DIR "${GFLAGS_PREFIX}/include")
537+
set(GFLAGS_STATIC_LIB "${GFLAGS_PREFIX}/lib/libgflags.a")
538+
set(GFLAGS_VENDORED 1)
539+
else()
540+
set(GFLAGS_VENDORED 0)
541+
find_package(GFlags REQUIRED)
542+
endif()
543+
544+
message(STATUS "GFlags include dir: ${GFLAGS_INCLUDE_DIR}")
545+
message(STATUS "GFlags static library: ${GFLAGS_STATIC_LIB}")
546+
include_directories(SYSTEM ${GFLAGS_INCLUDE_DIR})
547+
ADD_THIRDPARTY_LIB(gflags
548+
STATIC_LIB ${GFLAGS_STATIC_LIB})
549+
550+
if(GFLAGS_VENDORED)
551+
add_dependencies(gflags gflags_ep)
552+
endif()
509553
endif()
510554

511555
if(ARROW_BUILD_BENCHMARKS)

cpp/cmake_modules/FindGFlags.cmake

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# - Find GFLAGS (gflags.h, libgflags.a, libgflags.so, and libgflags.so.0)
19+
# This module defines
20+
# GFLAGS_INCLUDE_DIR, directory containing headers
21+
# GFLAGS_SHARED_LIB, path to libgflags shared library
22+
# GFLAGS_STATIC_LIB, path to libgflags static library
23+
# GFLAGS_FOUND, whether gflags has been found
24+
25+
if( NOT "$ENV{GFLAGS_HOME}" STREQUAL "")
26+
file( TO_CMAKE_PATH "$ENV{GFLAGS_HOME}" _native_path )
27+
list( APPEND _gflags_roots ${_native_path} )
28+
elseif ( GFlags_HOME )
29+
list( APPEND _gflags_roots ${GFlags_HOME} )
30+
endif()
31+
32+
if ( _gflags_roots )
33+
find_path(GFLAGS_INCLUDE_DIR NAMES gflags/gflags.h
34+
PATHS ${_gflags_roots}
35+
NO_DEFAULT_PATH
36+
PATH_SUFFIXES "include" )
37+
find_library(GFLAGS_SHARED_LIB NAMES gflags
38+
PATHS ${_gflags_roots}
39+
NO_DEFAULT_PATH
40+
PATH_SUFFIXES "lib" )
41+
find_library(GFLAGS_SHARED_LIB NAMES libgflags.a
42+
PATHS ${_gflags_roots}
43+
NO_DEFAULT_PATH
44+
PATH_SUFFIXES "lib" )
45+
else()
46+
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
47+
# make sure we don't accidentally pick up a different version
48+
NO_CMAKE_SYSTEM_PATH
49+
NO_SYSTEM_ENVIRONMENT_PATH)
50+
find_library(GFLAGS_SHARED_LIB gflags
51+
NO_CMAKE_SYSTEM_PATH
52+
NO_SYSTEM_ENVIRONMENT_PATH)
53+
find_library(GFLAGS_STATIC_LIB libgflags.a
54+
NO_CMAKE_SYSTEM_PATH
55+
NO_SYSTEM_ENVIRONMENT_PATH)
56+
endif()
57+
58+
include(FindPackageHandleStandardArgs)
59+
find_package_handle_standard_args(GFLAGS REQUIRED_VARS
60+
GFLAGS_SHARED_LIB GFLAGS_STATIC_LIB GFLAGS_INCLUDE_DIR)

cpp/src/arrow/io/file.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,13 @@ static inline Status FileOpenWriteable(const std::string& filename, int* fd) {
186186
memcpy(wpath.data(), filename.data(), filename.size());
187187
memcpy(wpath.data() + nwchars, L"\0", sizeof(wchar_t));
188188

189-
errno_actual = _wsopen_s(
190-
fd, wpath.data(), _O_WRONLY | _O_CREAT | _O_BINARY, _SH_DENYNO, _S_IWRITE);
189+
errno_actual = _wsopen_s(fd, wpath.data(), _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC,
190+
_SH_DENYNO, _S_IWRITE);
191191
ret = *fd;
192192

193193
#else
194-
ret = *fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_BINARY, ARROW_WRITE_SHMODE);
194+
ret = *fd =
195+
open(filename.c_str(), O_WRONLY | O_CREAT | O_BINARY | O_TRUNC, ARROW_WRITE_SHMODE);
195196
#endif
196197
return CheckOpenResult(ret, errno_actual, filename.c_str(), filename.size());
197198
}

cpp/src/arrow/ipc/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,33 @@ ADD_ARROW_TEST(ipc-json-test)
8585
ARROW_TEST_LINK_LIBRARIES(ipc-json-test
8686
${ARROW_IPC_TEST_LINK_LIBS})
8787

88+
ADD_ARROW_TEST(json-integration-test)
89+
90+
if (APPLE)
91+
target_link_libraries(json-integration-test
92+
arrow_static
93+
arrow_io
94+
arrow_ipc
95+
gflags
96+
gtest
97+
boost_filesystem_static
98+
boost_system_static
99+
dl)
100+
set_target_properties(json-integration-test
101+
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
102+
else()
103+
target_link_libraries(json-integration-test
104+
arrow_static
105+
arrow_io
106+
arrow_ipc
107+
gflags
108+
gtest
109+
pthread
110+
boost_filesystem_static
111+
boost_system_static
112+
dl)
113+
endif()
114+
88115
# make clean will delete the generated file
89116
set_source_files_properties(Metadata_generated.h PROPERTIES GENERATED TRUE)
90117

cpp/src/arrow/ipc/adapter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// under the License.
1717

1818
// Public API for writing and accessing (with zero copy, if possible) Arrow
19-
// data in shared memory
19+
// IPC binary formatted data (e.g. in shared memory, or from some other IO source)
2020

2121
#ifndef ARROW_IPC_ADAPTER_H
2222
#define ARROW_IPC_ADAPTER_H

0 commit comments

Comments
 (0)