Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rmw_logging tests #442

Merged
merged 3 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rmw_fastrtps_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ if(BUILD_TESTING)
osrf_testing_tools_cpp rcutils rmw test_msgs
)
target_link_libraries(test_get_native_entities rmw_fastrtps_cpp)

ament_add_gtest(test_logging test/test_logging.cpp)
ament_target_dependencies(test_logging rmw)
target_link_libraries(test_logging rmw_fastrtps_cpp)
endif()

ament_package(
Expand Down
33 changes: 33 additions & 0 deletions rmw_fastrtps_cpp/test/test_logging.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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"
#include "rmw/error_handling.h"

TEST(TestLogging, rmw_logging)
{
rmw_ret_t ret;
ret = rmw_set_log_severity(RMW_LOG_SEVERITY_DEBUG);
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahcorde nit: collapse the last two lines. Same elsewhere.

EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_set_log_severity(RMW_LOG_SEVERITY_INFO);
EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_set_log_severity(RMW_LOG_SEVERITY_WARN);
EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_set_log_severity(RMW_LOG_SEVERITY_ERROR);
EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_set_log_severity(RMW_LOG_SEVERITY_FATAL);
EXPECT_EQ(ret, RMW_RET_OK);
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 4 additions & 0 deletions rmw_fastrtps_dynamic_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ if(BUILD_TESTING)
osrf_testing_tools_cpp rcutils rmw test_msgs
)
target_link_libraries(test_get_native_entities rmw_fastrtps_dynamic_cpp)

ament_add_gtest(test_logging test/test_logging.cpp)
ament_target_dependencies(test_logging rmw)
target_link_libraries(test_logging rmw_fastrtps_dynamic_cpp)
endif()

ament_package(
Expand Down
33 changes: 33 additions & 0 deletions rmw_fastrtps_dynamic_cpp/test/test_logging.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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"
#include "rmw/error_handling.h"

TEST(TestLogging, rmw_logging)
{
rmw_ret_t ret;
ret = rmw_set_log_severity(RMW_LOG_SEVERITY_DEBUG);
EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_set_log_severity(RMW_LOG_SEVERITY_INFO);
EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_set_log_severity(RMW_LOG_SEVERITY_WARN);
EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_set_log_severity(RMW_LOG_SEVERITY_ERROR);
EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_set_log_severity(RMW_LOG_SEVERITY_FATAL);
EXPECT_EQ(ret, RMW_RET_OK);
}
7 changes: 7 additions & 0 deletions rmw_fastrtps_shared_cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ if(TARGET test_names)
ament_target_dependencies(test_names rmw)
target_link_libraries(test_names ${PROJECT_NAME})
endif()

ament_add_gtest(test_logging test_logging.cpp)
if(TARGET test_logging)
ament_target_dependencies(test_logging
osrf_testing_tools_cpp rcutils rmw)
target_link_libraries(test_logging rmw_fastrtps_shared_cpp)
endif()
35 changes: 35 additions & 0 deletions rmw_fastrtps_shared_cpp/test/test_logging.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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"
#include "rmw/error_handling.h"

#include "rmw_fastrtps_shared_cpp/rmw_common.hpp"

TEST(TestLogging, rmw_logging)
{
rmw_ret_t ret;
ret = rmw_fastrtps_shared_cpp::__rmw_set_log_severity(RMW_LOG_SEVERITY_DEBUG);
EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_fastrtps_shared_cpp::__rmw_set_log_severity(RMW_LOG_SEVERITY_INFO);
EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_fastrtps_shared_cpp::__rmw_set_log_severity(RMW_LOG_SEVERITY_WARN);
EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_fastrtps_shared_cpp::__rmw_set_log_severity(RMW_LOG_SEVERITY_ERROR);
EXPECT_EQ(ret, RMW_RET_OK);
ret = rmw_fastrtps_shared_cpp::__rmw_set_log_severity(RMW_LOG_SEVERITY_FATAL);
EXPECT_EQ(ret, RMW_RET_OK);
}