From e6281d02734569bcbfd4423bfa99dcd0ac70f1dc Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Tue, 26 Jan 2016 10:05:23 -0800 Subject: [PATCH] PARQUET-437: Add googletest setup and ADD_PARQUET_TEST helper I adapted this functionality from Apache Kudu (incubating). There are no real unit tests, yet, but you can now run `ctest` after building to run all tests that have been created with `ADD_PARQUET_TEST`. Author: Wes McKinney Closes #19 from wesm/googletest-infra and squashes the following commits: 758328f [Wes McKinney] BLD: disable fixed OSX deployment target. Compile gtest with -fPIC 61cc5bb [Wes McKinney] Remove 'set -e' from setup_build_env.sh 6435970 [Wes McKinney] Fix setup_build_env.sh script a54a219 [Wes McKinney] Add googletest to thirdparty and add ADD_PARQUET_TEST cmake helper and support scripts for using ctest after make Change-Id: I7e86dfc9ae2590d8053ffe3dc687f78008faf3b2 --- cpp/src/parquet/CMakeLists.txt | 27 ++++++++++++++++----------- cpp/src/parquet/reader-test.cc | 26 ++++++++++++++++++++++++++ cpp/src/parquet/util/CMakeLists.txt | 17 +++++++++++++++++ cpp/src/parquet/util/test_main.cc | 26 ++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 11 deletions(-) create mode 100644 cpp/src/parquet/reader-test.cc create mode 100644 cpp/src/parquet/util/test_main.cc diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt index 11eaeb60bcce1..f35af707254db 100644 --- a/cpp/src/parquet/CMakeLists.txt +++ b/cpp/src/parquet/CMakeLists.txt @@ -1,18 +1,23 @@ -# Copyright 2015 Cloudera Inc. +# 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 # -# Licensed 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 # -# 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. +# 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. # Headers: top level install(FILES parquet.h DESTINATION include/parquet) + +ADD_PARQUET_TEST(reader-test) diff --git a/cpp/src/parquet/reader-test.cc b/cpp/src/parquet/reader-test.cc new file mode 100644 index 0000000000000..f6bf8b1c9bde1 --- /dev/null +++ b/cpp/src/parquet/reader-test.cc @@ -0,0 +1,26 @@ +// 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 + +namespace parquet { + +TEST(TestReader, ItWorks) { + ASSERT_TRUE(true); +} + +} // namespace parquet diff --git a/cpp/src/parquet/util/CMakeLists.txt b/cpp/src/parquet/util/CMakeLists.txt index 1a5de97c6cdb5..1b712f715f6a3 100644 --- a/cpp/src/parquet/util/CMakeLists.txt +++ b/cpp/src/parquet/util/CMakeLists.txt @@ -22,3 +22,20 @@ install(FILES rle-encoding.h stopwatch.h DESTINATION include/parquet/util) + +add_library(parquet_test_main + test_main.cc) + +if (APPLE) + target_link_libraries(parquet_test_main + gtest + dl) + set_target_properties(parquet_test_main + PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") +else() + target_link_libraries(parquet_test_main + dl + gtest + pthread + ) +endif() diff --git a/cpp/src/parquet/util/test_main.cc b/cpp/src/parquet/util/test_main.cc new file mode 100644 index 0000000000000..00139f36742ed --- /dev/null +++ b/cpp/src/parquet/util/test_main.cc @@ -0,0 +1,26 @@ +// 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 + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + + int ret = RUN_ALL_TESTS(); + + return ret; +}