Browse Source

Do a single setup of uORB/Parameters instead of once every test

sbg
Julian Kent 6 years ago
parent
commit
63140f1d61
  1. 2
      cmake/gtest/px4_add_gtest.cmake
  2. 7
      src/lib/CollisionPrevention/CollisionPreventionTest.cpp
  3. 7
      src/lib/parameters/ParameterTest.cpp
  4. 1
      src/platforms/CMakeLists.txt
  5. 39
      src/platforms/posix/gtest_runner/CMakeLists.txt
  6. 45
      src/platforms/posix/gtest_runner/gtest_functional_main.cpp

2
cmake/gtest/px4_add_gtest.cmake

@ -91,7 +91,7 @@ function(px4_add_functional_gtest) @@ -91,7 +91,7 @@ function(px4_add_functional_gtest)
add_executable(${TESTNAME} EXCLUDE_FROM_ALL ${SRC})
# link the libary to test and gtest
target_link_libraries(${TESTNAME} ${LINKLIBS} gtest_main
target_link_libraries(${TESTNAME} ${LINKLIBS} gtest_functional_main
px4_daemon
px4_platform
modules__uORB

7
src/lib/CollisionPrevention/CollisionPreventionTest.cpp

@ -39,16 +39,9 @@ @@ -39,16 +39,9 @@
class CollisionPreventionTest : public ::testing::Test
{
public:
void SetUp() override
{
uORB::Manager::initialize();
param_init();
}
void TearDown() override
{
param_reset_all();
uORB::Manager::terminate();
}
};

7
src/lib/parameters/ParameterTest.cpp

@ -41,16 +41,9 @@ @@ -41,16 +41,9 @@
class ParameterTest : public ::testing::Test
{
public:
void SetUp() override
{
uORB::Manager::initialize();
param_init();
}
void TearDown() override
{
param_reset_all();
uORB::Manager::terminate();
}
};

1
src/platforms/CMakeLists.txt

@ -35,4 +35,5 @@ add_subdirectory(common) @@ -35,4 +35,5 @@ add_subdirectory(common)
if (${PX4_PLATFORM} STREQUAL "posix" AND BUILD_TESTING)
add_subdirectory(posix/test_stubs)
add_subdirectory(posix/gtest_runner)
endif()

39
src/platforms/posix/gtest_runner/CMakeLists.txt

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
############################################################################
#
# Copyright (c) 2019 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
set(SRCS
gtest_functional_main.cpp
)
px4_add_library(gtest_functional_main ${SRCS})
target_link_libraries(gtest_functional_main PUBLIC gtest)

45
src/platforms/posix/gtest_runner/gtest_functional_main.cpp

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
/****************************************************************************
*
* Copyright (c) 2012-2019 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#include <gtest/gtest.h>
#include <uORB/Subscription.hpp>
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
uORB::Manager::initialize();
param_init();
return RUN_ALL_TESTS();
}
Loading…
Cancel
Save