Skip to content

Commit af4c697

Browse files
committed
Start assembling a cmake setup with a mix of Kudu and dynd-python snippets and cmake modules
1 parent 5802b08 commit af4c697

15 files changed

+8025
-0
lines changed

CMakeLists.txt

Lines changed: 586 additions & 0 deletions
Large diffs are not rendered by default.

build-support/cpplint.py

Lines changed: 6323 additions & 0 deletions
Large diffs are not rendered by default.

build-support/run-test.sh

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
#!/bin/bash
2+
# Copyright 2014 Cloudera, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Script which wraps running a test and redirects its output to a
17+
# test log directory.
18+
19+
ROOT=$(cd $(dirname $BASH_SOURCE)/..; pwd)
20+
21+
TEST_LOGDIR=$ROOT/build/test-logs
22+
mkdir -p $TEST_LOGDIR
23+
24+
TEST_DEBUGDIR=$ROOT/build/test-debug
25+
mkdir -p $TEST_DEBUGDIR
26+
27+
TEST_DIRNAME=$(cd $(dirname $1); pwd)
28+
TEST_FILENAME=$(basename $1)
29+
shift
30+
TEST_EXECUTABLE="$TEST_DIRNAME/$TEST_FILENAME"
31+
TEST_NAME=$(echo $TEST_FILENAME | perl -pe 's/\..+?$//') # Remove path and extension (if any).
32+
33+
# We run each test in its own subdir to avoid core file related races.
34+
TEST_WORKDIR=$ROOT/build/test-work/$TEST_NAME
35+
mkdir -p $TEST_WORKDIR
36+
pushd $TEST_WORKDIR >/dev/null || exit 1
37+
rm -f *
38+
39+
set -o pipefail
40+
41+
LOGFILE=$TEST_LOGDIR/$TEST_NAME.txt
42+
XMLFILE=$TEST_LOGDIR/$TEST_NAME.xml
43+
44+
TEST_EXECUTION_ATTEMPTS=1
45+
46+
# Remove both the uncompressed output, so the developer doesn't accidentally get confused
47+
# and read output from a prior test run.
48+
rm -f $LOGFILE $LOGFILE.gz
49+
50+
pipe_cmd=cat
51+
52+
# Configure TSAN (ignored if this isn't a TSAN build).
53+
#
54+
# Deadlock detection (new in clang 3.5) is disabled because:
55+
# 1. The clang 3.5 deadlock detector crashes in some unit tests. It
56+
# needs compiler-rt commits c4c3dfd, 9a8efe3, and possibly others.
57+
# 2. Many unit tests report lock-order-inversion warnings; they should be
58+
# fixed before reenabling the detector.
59+
TSAN_OPTIONS="$TSAN_OPTIONS detect_deadlocks=0"
60+
TSAN_OPTIONS="$TSAN_OPTIONS suppressions=$ROOT/build-support/tsan-suppressions.txt"
61+
TSAN_OPTIONS="$TSAN_OPTIONS history_size=7"
62+
export TSAN_OPTIONS
63+
64+
# Enable leak detection even under LLVM 3.4, where it was disabled by default.
65+
# This flag only takes effect when running an ASAN build.
66+
ASAN_OPTIONS="$ASAN_OPTIONS detect_leaks=1"
67+
export ASAN_OPTIONS
68+
69+
# Set up suppressions for LeakSanitizer
70+
LSAN_OPTIONS="$LSAN_OPTIONS suppressions=$ROOT/build-support/lsan-suppressions.txt"
71+
export LSAN_OPTIONS
72+
73+
# Suppressions require symbolization. We'll default to using the symbolizer in
74+
# thirdparty.
75+
if [ -z "$ASAN_SYMBOLIZER_PATH" ]; then
76+
export ASAN_SYMBOLIZER_PATH=$(find $NATIVE_TOOLCHAIN/llvm-3.7.0/bin -name llvm-symbolizer)
77+
fi
78+
79+
# Allow for collecting core dumps.
80+
PANDAS_TEST_ULIMIT_CORE=${PANDAS_TEST_ULIMIT_CORE:-0}
81+
ulimit -c $PANDAS_TEST_ULIMIT_CORE
82+
83+
# Run the actual test.
84+
for ATTEMPT_NUMBER in $(seq 1 $TEST_EXECUTION_ATTEMPTS) ; do
85+
if [ $ATTEMPT_NUMBER -lt $TEST_EXECUTION_ATTEMPTS ]; then
86+
# If the test fails, the test output may or may not be left behind,
87+
# depending on whether the test cleaned up or exited immediately. Either
88+
# way we need to clean it up. We do this by comparing the data directory
89+
# contents before and after the test runs, and deleting anything new.
90+
#
91+
# The comm program requires that its two inputs be sorted.
92+
TEST_TMPDIR_BEFORE=$(find $TEST_TMPDIR -maxdepth 1 -type d | sort)
93+
fi
94+
95+
# gtest won't overwrite old junit test files, resulting in a build failure
96+
# even when retries are successful.
97+
rm -f $XMLFILE
98+
99+
echo "Running $TEST_NAME, redirecting output into $LOGFILE" \
100+
"(attempt ${ATTEMPT_NUMBER}/$TEST_EXECUTION_ATTEMPTS)"
101+
$TEST_EXECUTABLE "$@" 2>&1 \
102+
| $ROOT/build-support/asan_symbolize.py \
103+
| c++filt \
104+
| $ROOT/build-support/stacktrace_addr2line.pl $TEST_EXECUTABLE \
105+
| $pipe_cmd > $LOGFILE
106+
STATUS=$?
107+
108+
# TSAN doesn't always exit with a non-zero exit code due to a bug:
109+
# mutex errors don't get reported through the normal error reporting infrastructure.
110+
# So we make sure to detect this and exit 1.
111+
#
112+
# Additionally, certain types of failures won't show up in the standard JUnit
113+
# XML output from gtest. We assume that gtest knows better than us and our
114+
# regexes in most cases, but for certain errors we delete the resulting xml
115+
# file and let our own post-processing step regenerate it.
116+
export GREP=$(which egrep)
117+
if zgrep --silent "ThreadSanitizer|Leak check.*detected leaks" $LOGFILE ; then
118+
echo ThreadSanitizer or leak check failures in $LOGFILE
119+
STATUS=1
120+
rm -f $XMLFILE
121+
fi
122+
123+
if [ $ATTEMPT_NUMBER -lt $TEST_EXECUTION_ATTEMPTS ]; then
124+
# Now delete any new test output.
125+
TEST_TMPDIR_AFTER=$(find $TEST_TMPDIR -maxdepth 1 -type d | sort)
126+
DIFF=$(comm -13 <(echo "$TEST_TMPDIR_BEFORE") \
127+
<(echo "$TEST_TMPDIR_AFTER"))
128+
for DIR in $DIFF; do
129+
# Multiple tests may be running concurrently. To avoid deleting the
130+
# wrong directories, constrain to only directories beginning with the
131+
# test name.
132+
#
133+
# This may delete old test directories belonging to this test, but
134+
# that's not typically a concern when rerunning flaky tests.
135+
if [[ $DIR =~ ^$TEST_TMPDIR/$TEST_NAME ]]; then
136+
echo Deleting leftover flaky test directory "$DIR"
137+
rm -Rf "$DIR"
138+
fi
139+
done
140+
fi
141+
142+
if [ "$STATUS" -eq "0" ]; then
143+
break
144+
elif [ "$ATTEMPT_NUMBER" -lt "$TEST_EXECUTION_ATTEMPTS" ]; then
145+
echo Test failed attempt number $ATTEMPT_NUMBER
146+
echo Will retry...
147+
fi
148+
done
149+
150+
# If we have a LeakSanitizer report, and XML reporting is configured, add a new test
151+
# case result to the XML file for the leak report. Otherwise Jenkins won't show
152+
# us which tests had LSAN errors.
153+
if zgrep --silent "ERROR: LeakSanitizer: detected memory leaks" $LOGFILE ; then
154+
echo Test had memory leaks. Editing XML
155+
perl -p -i -e '
156+
if (m#</testsuite>#) {
157+
print "<testcase name=\"LeakSanitizer\" status=\"run\" classname=\"LSAN\">\n";
158+
print " <failure message=\"LeakSanitizer failed\" type=\"\">\n";
159+
print " See txt log file for details\n";
160+
print " </failure>\n";
161+
print "</testcase>\n";
162+
}' $XMLFILE
163+
fi
164+
165+
# Capture and compress core file and binary.
166+
COREFILES=$(ls | grep ^core)
167+
if [ -n "$COREFILES" ]; then
168+
echo Found core dump. Saving executable and core files.
169+
gzip < $TEST_EXECUTABLE > "$TEST_DEBUGDIR/$TEST_NAME.gz" || exit $?
170+
for COREFILE in $COREFILES; do
171+
gzip < $COREFILE > "$TEST_DEBUGDIR/$TEST_NAME.$COREFILE.gz" || exit $?
172+
done
173+
# Pull in any .so files as well.
174+
for LIB in $(ldd $TEST_EXECUTABLE | grep $ROOT | awk '{print $3}'); do
175+
LIB_NAME=$(basename $LIB)
176+
gzip < $LIB > "$TEST_DEBUGDIR/$LIB_NAME.gz" || exit $?
177+
done
178+
fi
179+
180+
popd
181+
rm -Rf $TEST_WORKDIR
182+
183+
exit $STATUS

cmake_modules/CompilerInfo.cmake

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2013 Cloudera, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# Sets COMPILER_FAMILY to 'clang' or 'gcc'
16+
# Sets COMPILER_VERSION to the version
17+
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" -v
18+
ERROR_VARIABLE COMPILER_VERSION_FULL)
19+
message(INFO " ${COMPILER_VERSION_FULL}")
20+
21+
# clang on Linux and Mac OS X before 10.9
22+
if("${COMPILER_VERSION_FULL}" MATCHES ".*clang version.*")
23+
set(COMPILER_FAMILY "clang")
24+
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1"
25+
COMPILER_VERSION "${COMPILER_VERSION_FULL}")
26+
# clang on Mac OS X 10.9 and later
27+
elseif("${COMPILER_VERSION_FULL}" MATCHES ".*based on LLVM.*")
28+
set(COMPILER_FAMILY "clang")
29+
string(REGEX REPLACE ".*based on LLVM ([0-9]+\\.[0.9]+).*" "\\1"
30+
COMPILER_VERSION "${COMPILER_VERSION_FULL}")
31+
32+
# clang on Mac OS X, XCode 7. No version replacement is done
33+
# because Apple no longer advertises the upstream LLVM version.
34+
elseif("${COMPILER_VERSION_FULL}" MATCHES "clang-700\\..*")
35+
set(COMPILER_FAMILY "clang")
36+
37+
# gcc
38+
elseif("${COMPILER_VERSION_FULL}" MATCHES ".*gcc version.*")
39+
set(COMPILER_FAMILY "gcc")
40+
string(REGEX REPLACE ".*gcc version ([0-9\\.]+).*" "\\1"
41+
COMPILER_VERSION "${COMPILER_VERSION_FULL}")
42+
else()
43+
message(FATAL_ERROR "Unknown compiler. Version info:\n${COMPILER_VERSION_FULL}")
44+
endif()
45+
message("Selected compiler ${COMPILER_FAMILY} ${COMPILER_VERSION}")

cmake_modules/FindCython.cmake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Find the Cython compiler.
2+
#
3+
# This code sets the following variables:
4+
#
5+
# CYTHON_EXECUTABLE
6+
#
7+
# See also UseCython.cmake
8+
9+
#=============================================================================
10+
# Copyright 2011 Kitware, Inc.
11+
#
12+
# Licensed under the Apache License, Version 2.0 (the "License");
13+
# you may not use this file except in compliance with the License.
14+
# You may obtain a copy of the License at
15+
#
16+
# http://www.apache.org/licenses/LICENSE-2.0
17+
#
18+
# Unless required by applicable law or agreed to in writing, software
19+
# distributed under the License is distributed on an "AS IS" BASIS,
20+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
# See the License for the specific language governing permissions and
22+
# limitations under the License.
23+
#=============================================================================
24+
25+
find_program( CYTHON_EXECUTABLE NAMES cython cython.bat )
26+
27+
include( FindPackageHandleStandardArgs )
28+
FIND_PACKAGE_HANDLE_STANDARD_ARGS( Cython REQUIRED_VARS CYTHON_EXECUTABLE )
29+
30+
mark_as_advanced( CYTHON_EXECUTABLE )

cmake_modules/FindGFlags.cmake

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# - Find GFLAGS (gflags.h, libgflags.a, libgflags.so, and libgflags.so.0)
2+
# This module defines
3+
# GFLAGS_INCLUDE_DIR, directory containing headers
4+
# GFLAGS_LIBS, directory containing gflag libraries
5+
# GFLAGS_STATIC_LIB, path to libgflags.a
6+
# GFLAGS_SHARED_LIB, path to libgflags' shared library
7+
# GFLAGS_FOUND, whether gflags has been found
8+
9+
set(GFLAGS_SEARCH_HEADER_PATHS
10+
$ENV{GFLAGS_PREFIX}/include
11+
)
12+
13+
set(GFLAGS_SEARCH_LIB_PATH
14+
$ENV{GFLAGS_PREFIX}/lib
15+
)
16+
17+
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h PATHS
18+
${GFLAGS_SEARCH_HEADER_PATHS}
19+
# make sure we don't accidentally pick up a different version
20+
NO_DEFAULT_PATH
21+
)
22+
23+
find_library(GFLAGS_LIB_PATH NAMES gflags PATHS ${GFLAGS_SEARCH_LIB_PATH} NO_DEFAULT_PATH)
24+
25+
if (GFLAGS_INCLUDE_DIR AND GFLAGS_LIB_PATH)
26+
set(GFLAGS_FOUND TRUE)
27+
set(GFLAGS_LIB_NAME libgflags)
28+
set(GFLAGS_LIBS ${GFLAGS_SEARCH_LIB_PATH})
29+
set(GFLAGS_STATIC_LIB ${GFLAGS_SEARCH_LIB_PATH}/${GFLAGS_LIB_NAME}.a)
30+
set(GFLAGS_SHARED_LIB ${GFLAGS_LIBS}/${GFLAGS_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
31+
else ()
32+
set(GFLAGS_FOUND FALSE)
33+
endif ()
34+
35+
if (GFLAGS_FOUND)
36+
if (NOT GFlags_FIND_QUIETLY)
37+
message(STATUS "Found the GFlags library: ${GFLAGS_LIB_PATH}")
38+
endif ()
39+
else ()
40+
if (NOT GFlags_FIND_QUIETLY)
41+
set(GFLAGS_ERR_MSG "Could not find the GFlags library. Looked for headers")
42+
set(GFLAGS_ERR_MSG "${GFLAGS_ERR_MSG} in ${GFLAGS_SEARCH_HEADER_PATHS}, and for libs")
43+
set(GFLAGS_ERR_MSG "${GFLAGS_ERR_MSG} in ${GFLAGS_SEARCH_LIB_PATH}")
44+
if (GFlags_FIND_REQUIRED)
45+
message(FATAL_ERROR "${GFLAGS_ERR_MSG}")
46+
else (GFlags_FIND_REQUIRED)
47+
message(STATUS "${GFLAGS_ERR_MSG}")
48+
endif (GFlags_FIND_REQUIRED)
49+
endif ()
50+
endif ()
51+
52+
mark_as_advanced(
53+
GFLAGS_INCLUDE_DIR
54+
GFLAGS_LIBS
55+
GFLAGS_STATIC_LIB
56+
GFLAGS_SHARED_LIB
57+
)

cmake_modules/FindGLog.cmake

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# - Find GLOG (logging.h, libglog.a, libglog.so, and libglog.so.0)
2+
# This module defines
3+
# GLOG_INCLUDE_DIR, directory containing headers
4+
# GLOG_LIBS, directory containing glog libraries
5+
# GLOG_STATIC_LIB, path to libglog.a
6+
# GLOG_SHARED_LIB, path to libglog's shared library
7+
# GLOG_FOUND, whether glog has been found
8+
9+
set(GLOG_SEARCH_HEADER_PATHS $ENV{GLOG_PREFIX}/include)
10+
set(GLOG_SEARCH_LIB_PATH $ENV{GLOG_PREFIX}/lib)
11+
12+
find_path(GLOG_INCLUDE_DIR glog/logging.h PATHS
13+
${GLOG_SEARCH_HEADER_PATHS}
14+
# make sure we don't accidentally pick up a different version
15+
NO_DEFAULT_PATH
16+
)
17+
18+
find_library(GLOG_LIB_PATH NAMES glog PATHS ${GLOG_SEARCH_LIB_PATH} NO_DEFAULT_PATH)
19+
20+
if (GLOG_INCLUDE_DIR AND GLOG_LIB_PATH)
21+
set(GLOG_FOUND TRUE)
22+
set(GLOG_LIBS ${GLOG_SEARCH_LIB_PATH})
23+
set(GLOG_LIB_NAME libglog)
24+
set(GLOG_STATIC_LIB ${GLOG_SEARCH_LIB_PATH}/${GLOG_LIB_NAME}.a)
25+
set(GLOG_SHARED_LIB ${GLOG_LIBS}/${GLOG_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
26+
else ()
27+
set(GLOG_FOUND FALSE)
28+
endif ()
29+
30+
if (GLOG_FOUND)
31+
if (NOT GLog_FIND_QUIETLY)
32+
message(STATUS "Found the GLog library: ${GLOG_LIB_PATH}")
33+
endif ()
34+
else ()
35+
if (NOT GLog_FIND_QUIETLY)
36+
set(GLOG_ERR_MSG "Could not find the GLog library. Looked for headers")
37+
set(GLOG_ERR_MSG "${GLOG_ERR_MSG} in ${GLOG_SEARCH_HEADER_PATHS}, and for libs")
38+
set(GLOG_ERR_MSG "${GLOG_ERR_MSG} in ${GLOG_SEARCH_LIB_PATH}")
39+
if (GLog_FIND_REQUIRED)
40+
message(FATAL_ERROR "${GLOG_ERR_MSG}")
41+
else (GLog_FIND_REQUIRED)
42+
message(STATUS "${GLOG_ERR_MSG}")
43+
endif (GLog_FIND_REQUIRED)
44+
endif ()
45+
endif ()
46+
47+
mark_as_advanced(
48+
GLOG_INCLUDE_DIR
49+
GLOG_LIBS
50+
GLOG_STATIC_LIB
51+
GLOG_SHARED_LIB
52+
)

0 commit comments

Comments
 (0)