Skip to content

Commit

Permalink
Merge pull request #602 from OSVR/update-tests
Browse files Browse the repository at this point in the history
Update tests: port all to Catch2 2.8.0, removing old gtest
  • Loading branch information
rpavlik committed Jun 6, 2019
2 parents 297fa11 + 59cf1d0 commit 495648e
Show file tree
Hide file tree
Showing 241 changed files with 16,912 additions and 153,206 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Expand Up @@ -178,8 +178,6 @@ use_folders()
include(PlatformDefinitions)
define_platform_macros(OSVR)

include(osvrGtest)

# Modules that get shipped with an installed SDK
include(osvrAddPlugin)
include(osvrConvertJson)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -25,12 +25,12 @@ This project: Licensed under the Apache License, Version 2.0.
Some directories under `/vendor` are in fact not external libraries vendored-in, but "internally-vendored" - developed as a part of OSVR-Core, and likewise licensed under the Apache License 2.0, but are logically distinct from the Core in their functionality and are thus kept separate in anticipation of potential splitting off into a separate project at some future point. These include `/vendor/comutils` and `/vendor/dummy-sal`.

- `/cmake` - Git subtree from <https://github.com/rpavlik/cmake-modules> used at compile-time only. Primarily BSL 1.0, some items under the license used by CMake (BSD-style)
- `/vendor/catch-single-header-2.8.0` - Header downloaded from <https://github.com/catchorg/Catch2/releases/download/v2.8.0/catch.hpp> - BSL 1.0 license. Used only for building/running tests.
- `/vendor/com_smart_pointer` - Header (for integrating `boost::intrusive_ptr` with MS COM) extracted from the following project and file: <https://github.com/rengeln/nyx/blob/master/src/Prefix.h>, modified as needed for compatibility. MIT license.
- `/vendor/discount-windows-bins` - Submodule containing source, build script, and Windows binaries for the "Discount" Markdown processor, used only during the build process on Windows. Upstream at <https://github.com/Orc/discount>. 3-clause BSD license.
- `/vendor/eigen` - Unpacked release from <http://eigen.tuxfamily.org/> - header-only library under the MPL2 (a file-level copyleft, compatible with proprietary software), define `EIGEN_MPL2_ONLY` to exclude modules with other license from the build (done in OSVR-Core build system).
- `/vendor/FloatExceptions` - Modified code ([original author: Bruce Dawson](http://randomascii.wordpress.com/2012/04/21/exceptional-floating-point/) for development use only, usage should not be committed or merged into master. MIT licensed.
- `/vendor/folly` - Submodule of [C++11 components originally developed and widely used at Facebook](https://github.com/facebook/folly). Apache License, Version 2.0.
- `/vendor/gtest-1.7.0` - Unpacked source from <https://code.google.com/p/googletest/> - 3-clause BSD license. Used only for building/running tests.
- `/vendor/jenkins-ctest-plugin` - Git submodule from <https://github.com/rpavlik/jenkins-ctest-plugin>, used only for building/running tests and CI. MIT license.
- `/vendor/libcxx-backports` - C++11/14 standard library functionality backported into headers using the implementations from the libc++ project at <http://libcxx.llvm.org/>. Dual licensed under [the MIT and the "BSD-like" UIUC license](http://llvm.org/docs/DeveloperPolicy.html#license).
- `/vendor/UIforETWbins` - Distributed binary releases of UIforETW <https://github.com/google/UIforETW> extracted to a Git repo (submodule) unmodified. Apache License, Version 2.0.
Expand Down
15 changes: 0 additions & 15 deletions cmake-local/osvrGtest.cmake

This file was deleted.

3 changes: 2 additions & 1 deletion plugins/unifiedvideoinertialtracker/CMakeLists.txt
Expand Up @@ -123,9 +123,10 @@ if(BUILD_TESTING)
TestIMU_Common.h
TestIMU_EKF.cpp
TestIMU_UKF.cpp)
target_link_libraries(uvbi-test-imu PRIVATE uvbi-core vendored-catch)
target_link_libraries(uvbi-test-imu PRIVATE uvbi-core osvr-catch2-interface)
set_target_properties(uvbi-test-imu PROPERTIES
FOLDER "${PROJ_FOLDER}")
add_test(NAME TestIMU COMMAND uvbi-test-imu)
endif()

# "object library" for the HDK data files.
Expand Down
9 changes: 1 addition & 8 deletions plugins/unifiedvideoinertialtracker/TestIMU.h
Expand Up @@ -29,13 +29,6 @@
/// messages.
#define CATCH_CONFIG_CONSOLE_WIDTH 120

// Internal Includes
#include "catch_typelist.h" // internally-developed extension to Catch.

// Library/third-party includes
#include <catch.hpp>

// Standard includes
// - none
#include <catch2/catch.hpp>

#endif // INCLUDED_TestIMU_h_GUID_955733BE_EFEE_4C8E_6D9B_F1A8FDBC8F6C
17 changes: 2 additions & 15 deletions plugins/unifiedvideoinertialtracker/TestIMU_Common.h
Expand Up @@ -9,6 +9,7 @@
*/

// Copyright 2016 Sensics, Inc.
// Copyright 2019 Collabora, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -30,7 +31,6 @@

#include "ConfigParams.h"
#include "IMUStateMeasurements.h"
#include "IMUStateMeasurements.h"

// Library/third-party includes
#include <osvr/Util/Angles.h>
Expand Down Expand Up @@ -94,18 +94,6 @@ inline std::ostream &operator<<(std::ostream &os, Quaterniond const &q) {
}
} // namespace Eigen

namespace Catch {
template <> struct TypelistTypeNameTrait<kalman::QFirst> {
static const char *get() { return "kalman::QFirst"; }
};
template <> struct TypelistTypeNameTrait<kalman::QLast> {
static const char *get() { return "kalman::QLast"; }
};
template <> struct TypelistTypeNameTrait<kalman::SplitQ> {
static const char *get() { return "kalman::SplitQ"; }
};
} // namespace Catch

static const double SMALL_VALUE = 0.1;

template <typename MeasurementType, typename InProgressType>
Expand Down Expand Up @@ -152,8 +140,7 @@ inline void commonSmallPositiveYChecks(TestData *data,
AND_THEN("state correction should not contain any translational/linear "
"velocity components") {
REQUIRE(inProgress.stateCorrection.template head<3>().isZero());
REQUIRE(
inProgress.stateCorrection.template segment<3>(6).isZero());
REQUIRE(inProgress.stateCorrection.template segment<3>(6).isZero());
}
AND_WHEN("the correction is applied") {
auto errorCovarianceCorrectionWasFinite = inProgress.finishCorrection();
Expand Down
10 changes: 5 additions & 5 deletions plugins/unifiedvideoinertialtracker/TestIMU_EKF.cpp
Expand Up @@ -9,6 +9,7 @@
*/

// Copyright 2016 Sensics, Inc.
// Copyright 2019 Collabora, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -33,13 +34,12 @@

#if 0
/// Turns out that QFirst and QLast are likely wrong.
CATCH_TYPELIST_DESCRIBED_TESTCASE("identity calibration output", "[.][ekf]", kalman::QFirst,
TEMPLATE_TEST_CASE("identity calibration output", "[.][ekf]", kalman::QFirst,
kalman::QLast, kalman::SplitQ) {
#endif
CATCH_TYPELIST_DESCRIBED_TESTCASE("identity calibration output", "[.][ekf]",
kalman::SplitQ,
kalman::QLastWithSplitInnovation) {
using MeasurementType = OrientationMeasurementUsingPolicy<TypeParam>;
TEMPLATE_TEST_CASE("identity calibration output", "[.][ekf]", kalman::SplitQ,
kalman::QLastWithSplitInnovation) {
using MeasurementType = OrientationMeasurementUsingPolicy<TestType>;
using JacobianType = typename MeasurementType::JacobianType;
unique_ptr<TestData> data(new TestData);
GIVEN("an identity state") {
Expand Down
1 change: 1 addition & 0 deletions plugins/unifiedvideoinertialtracker/TestIMU_UKF.cpp
Expand Up @@ -9,6 +9,7 @@
*/

// Copyright 2016 Sensics, Inc.
// Copyright 2019 Collabora, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
92 changes: 0 additions & 92 deletions plugins/unifiedvideoinertialtracker/catch_typelist.h

This file was deleted.

1 change: 0 additions & 1 deletion plugins/videobasedtracker/CMakeLists.txt
Expand Up @@ -168,7 +168,6 @@ if(BUILD_TESTING)
vbtracker-core)
set_target_properties(vbtracker-cam PROPERTIES
FOLDER "OSVR Plugins/Video-Based Tracker")
#osvr_setup_gtest(vbtracker-cam)

if(WIN32)
target_link_libraries(vbtracker-cam PRIVATE directshow-camera)
Expand Down
5 changes: 5 additions & 0 deletions tests/cplusplus/CMakeLists.txt
@@ -1,3 +1,8 @@

add_library(osvr-catch-main STATIC CatchMain.cpp)
target_link_libraries(osvr-catch-main PUBLIC osvr-catch2-interface osvr_cxx11_flags)
target_compile_definitions(osvr-catch-main PUBLIC CATCH_CONFIG_CONSOLE_WIDTH=120)

if(TARGET osvrTypePack)
add_subdirectory(TypePack)
endif()
Expand Down
26 changes: 26 additions & 0 deletions tests/cplusplus/CatchMain.cpp
@@ -0,0 +1,26 @@
/** @file
@brief Main file for Catch2-based tests
@date 2019
@author Ryan Pavlik <ryan.pavlik@collabora.com>
*/

// Copyright 2019 Collabora, Ltd.
//
// 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
//
// 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.

#define CATCH_CONFIG_MAIN

#include <catch2/catch.hpp>
19 changes: 14 additions & 5 deletions tests/cplusplus/ClientKit/CMakeLists.txt
@@ -1,7 +1,16 @@

foreach(test SimultaneousContexts SequentialContexts OverlappedContexts)
add_executable(Test${test}
${test}.cpp)
target_link_libraries(Test${test} osvrClientKitCpp)
osvr_setup_gtest(Test${test})
get_filename_component(LIB_TO_TEST ${CMAKE_CURRENT_SOURCE_DIR} NAME)
set(TEST_EXE Test${LIB_TO_TEST})
add_executable(${TEST_EXE}
SimultaneousContexts.cpp
SequentialContexts.cpp
OverlappedContexts.cpp
)
target_link_libraries(${TEST_EXE} osvr-catch-main)

target_link_libraries(${TEST_EXE} osvrClientKitCpp)

foreach(TEST SimultaneousClient-TwoContexts SequentialClient-TwoContexts OverlappedContexts-TwoContexts)
add_test(NAME ${LIB_TO_TEST}-${TEST}
COMMAND ${TEST_EXE} ${TEST})
endforeach()
8 changes: 4 additions & 4 deletions tests/cplusplus/ClientKit/OverlappedContexts.cpp
Expand Up @@ -30,14 +30,14 @@
// - none

// Standard includes
#include "gtest/gtest.h"
#include <catch2/catch.hpp>

TEST(OverlappedContexts, TwoContexts) {
TEST_CASE("OverlappedContexts-TwoContexts") {
OSVR_ClientContext firstContext =
osvrClientInit("com.osvr.test.firstContext");
OSVR_ClientContext secondContext =
osvrClientInit("com.osvr.test.secondContext");
ASSERT_EQ(OSVR_RETURN_SUCCESS, osvrClientShutdown(firstContext));
REQUIRE(OSVR_RETURN_SUCCESS == osvrClientShutdown(firstContext));
osvrClientUpdate(secondContext);
ASSERT_EQ(OSVR_RETURN_SUCCESS, osvrClientShutdown(secondContext));
REQUIRE(OSVR_RETURN_SUCCESS == osvrClientShutdown(secondContext));
}
4 changes: 2 additions & 2 deletions tests/cplusplus/ClientKit/SequentialContexts.cpp
Expand Up @@ -30,9 +30,9 @@
// - none

// Standard includes
#include "gtest/gtest.h"
#include <catch2/catch.hpp>

TEST(SequentialClient, TwoContexts) {
TEST_CASE("SequentialClient-TwoContexts") {
{
osvr::clientkit::ClientContext firstContext(
"com.osvr.test.firstContext");
Expand Down
4 changes: 2 additions & 2 deletions tests/cplusplus/ClientKit/SimultaneousContexts.cpp
Expand Up @@ -30,9 +30,9 @@
// - none

// Standard includes
#include "gtest/gtest.h"
#include <catch2/catch.hpp>

TEST(SimultaneousClient, TwoContexts) {
TEST_CASE("SimultaneousClient-TwoContexts") {
osvr::clientkit::ClientContext outerContext("com.osvr.test.outerContext");
{
osvr::clientkit::ClientContext innerContext("com.osvr.test.innerContext");
Expand Down
11 changes: 7 additions & 4 deletions tests/cplusplus/Common/CMakeLists.txt
Expand Up @@ -11,8 +11,9 @@ if(HAVE_OSVR_JSON_TO_C)
PathTreeJSON.cpp
"${CMAKE_CURRENT_BINARY_DIR}/test_path_tree_json.h")
endif()

add_executable(TestCommon
get_filename_component(LIB_TO_TEST ${CMAKE_CURRENT_SOURCE_DIR} NAME)
set(TEST_EXE Test${LIB_TO_TEST})
add_executable(${TEST_EXE}
DummyTree.h
CommonComponent.cpp
PathTreeResolution.cpp
Expand All @@ -22,6 +23,8 @@ add_executable(TestCommon
"${PROJECT_SOURCE_DIR}/examples/internals/SerializationTraitExample_Simple.h"
"${PROJECT_SOURCE_DIR}/examples/internals/SerializationTraitExample_Complicated.h"
${PATHTREEJSON_SOURCES})
target_link_libraries(${TEST_EXE} osvr-catch-main osvr${LIB_TO_TEST})
target_link_libraries(${TEST_EXE} osvrCommon JsonCpp::JsonCpp vendored-vrpn)

target_link_libraries(TestCommon osvrCommon JsonCpp::JsonCpp vendored-vrpn)
osvr_setup_gtest(TestCommon)
add_test(NAME ${LIB_TO_TEST}
COMMAND ${TEST_EXE})

0 comments on commit 495648e

Please sign in to comment.