Skip to content

Commit

Permalink
Added rmw_publisher_allocation and rmw_subscription_allocation relate…
Browse files Browse the repository at this point in the history
…d tests (#137)

* Added rmw_publisher_allocation and rmw_subscription_allocation related tests

Signed-off-by: ahcorde <ahcorde@gmail.com>

* Remove loaned message tests

Signed-off-by: ahcorde <ahcorde@gmail.com>

* Fix class name

Signed-off-by: ahcorde <ahcorde@gmail.com>

* Added feedback

Signed-off-by: ahcorde <ahcorde@gmail.com>

* make linters happy

Signed-off-by: ahcorde <ahcorde@gmail.com>
  • Loading branch information
ahcorde committed Oct 8, 2020
1 parent 61bde8c commit ce5e840
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test_rmw_implementation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ if(BUILD_TESTING)
rcutils rmw rmw_implementation test_msgs
)

ament_add_gtest(test_publisher_allocator${target_suffix}
test/test_publisher_allocator.cpp
ENV ${rmw_implementation_env_var}
)
target_compile_definitions(test_publisher_allocator${target_suffix}
PUBLIC "RMW_IMPLEMENTATION=${rmw_implementation}")
ament_target_dependencies(test_publisher_allocator${target_suffix}
rmw rmw_implementation
)
ament_add_gtest(test_subscription_allocator${target_suffix}
test/test_subscription_allocator.cpp
ENV ${rmw_implementation_env_var}
)
target_compile_definitions(test_subscription_allocator${target_suffix}
PUBLIC "RMW_IMPLEMENTATION=${rmw_implementation}")
ament_target_dependencies(test_subscription_allocator${target_suffix}
rmw rmw_implementation
)

ament_add_gtest(test_graph_api${target_suffix}
test/test_graph_api.cpp
ENV ${rmw_implementation_env_var}
Expand Down
36 changes: 36 additions & 0 deletions test_rmw_implementation/test/test_publisher_allocator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2020 Open Source Robotics Foundation, Inc.
//
// 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.
#include <gtest/gtest.h>

#include "rmw/rmw.h"

#ifdef RMW_IMPLEMENTATION
# define CLASSNAME_(NAME, SUFFIX) NAME ## __ ## SUFFIX
# define CLASSNAME(NAME, SUFFIX) CLASSNAME_(NAME, SUFFIX)
#else
# define CLASSNAME(NAME, SUFFIX) NAME
#endif

class CLASSNAME (TestPublisherAllocator, RMW_IMPLEMENTATION) : public ::testing::Test {};

TEST_F(CLASSNAME(TestPublisherAllocator, RMW_IMPLEMENTATION), init_fini_publisher_allocation)
{
if (rmw_init_publisher_allocation(nullptr, nullptr, nullptr) != RMW_RET_UNSUPPORTED) {
// Add tests here when the implementation it's supported
GTEST_SKIP();
} else {
rmw_ret_t ret = rmw_fini_publisher_allocation(nullptr);
EXPECT_EQ(ret, RMW_RET_UNSUPPORTED);
}
}
36 changes: 36 additions & 0 deletions test_rmw_implementation/test/test_subscription_allocator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2020 Open Source Robotics Foundation, Inc.
//
// 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.
#include <gtest/gtest.h>

#include "rmw/rmw.h"

#ifdef RMW_IMPLEMENTATION
# define CLASSNAME_(NAME, SUFFIX) NAME ## __ ## SUFFIX
# define CLASSNAME(NAME, SUFFIX) CLASSNAME_(NAME, SUFFIX)
#else
# define CLASSNAME(NAME, SUFFIX) NAME
#endif

class CLASSNAME (TestSubscriptionAllocator, RMW_IMPLEMENTATION) : public ::testing::Test {};

TEST_F(CLASSNAME(TestSubscriptionAllocator, RMW_IMPLEMENTATION), init_fini_subscription_allocation)
{
if (rmw_init_subscription_allocation(nullptr, nullptr, nullptr) != RMW_RET_UNSUPPORTED) {
// Add tests here when the implementation it's supported
GTEST_SKIP();
} else {
rmw_ret_t ret = rmw_fini_subscription_allocation(nullptr);
EXPECT_EQ(ret, RMW_RET_UNSUPPORTED);
}
}

0 comments on commit ce5e840

Please sign in to comment.