-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(autoware_utils_testing): create test utils
Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp>
- Loading branch information
1 parent
009d98c
commit 5a6defe
Showing
8 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
project(autoware_utils_testing) | ||
|
||
find_package(autoware_cmake REQUIRED) | ||
autoware_package() | ||
|
||
ament_auto_add_library(${PROJECT_NAME} SHARED | ||
"src/gtest/ros_env.cpp" | ||
) | ||
|
||
if(BUILD_TESTING) | ||
file(GLOB_RECURSE test_files test/*.cpp) | ||
ament_auto_add_gtest(test_${PROJECT_NAME} ${test_files}) | ||
endif() | ||
|
||
ament_auto_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# autoware_utils_testing | ||
|
||
## Overview | ||
|
||
The **autoware_utils** library is a comprehensive toolkit designed to facilitate the development of autonomous driving applications. | ||
This package provides essential utilities for visualization. | ||
It is extensively used in the Autoware project to handle common tasks such as creating markers for RViz. | ||
|
||
## Design | ||
|
||
- **`marker_helper.hpp`**: Helper functions for creating and manipulating visualization markers. |
29 changes: 29 additions & 0 deletions
29
autoware_utils_testing/include/autoware_utils_testing/gtest/ros_env.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2025 The Autoware Contributors | ||
// | ||
// 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. | ||
|
||
#ifndef AUTOWARE_UTILS_TESTING__GTEST__ROS_ENV_HPP_ | ||
#define AUTOWARE_UTILS_TESTING__GTEST__ROS_ENV_HPP_ | ||
|
||
#include <gtest/gtest.h> | ||
|
||
namespace autoware_utils_testing::gtest | ||
{ | ||
|
||
// Create an environment pointor that executes rclcpp init and shutdown. | ||
// Pass it to the AddGlobalTestEnvironment in your gtest main function. | ||
testing::Environment * ros_env(int argc, char ** argv); | ||
|
||
} // namespace autoware_utils_testing::gtest | ||
|
||
#endif // AUTOWARE_UTILS_TESTING__GTEST__ROS_ENV_HPP_ |
35 changes: 35 additions & 0 deletions
35
autoware_utils_testing/include/autoware_utils_testing/mock_node.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2025 The Autoware Contributors | ||
// | ||
// 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. | ||
|
||
#ifndef AUTOWARE_UTILS_TESTING__MOCK_NODE_HPP_ | ||
#define AUTOWARE_UTILS_TESTING__MOCK_NODE_HPP_ | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <string> | ||
|
||
namespace autoware_utils_testing | ||
{ | ||
|
||
class MockNode : public rclcpp::Node | ||
{ | ||
public: | ||
explicit MockNode(const std::string & name) : Node(name) {} | ||
|
||
private: | ||
}; | ||
|
||
} // namespace autoware_utils_testing | ||
|
||
#endif // AUTOWARE_UTILS_TESTING__MOCK_NODE_HPP_ |
23 changes: 23 additions & 0 deletions
23
autoware_utils_testing/include/autoware_utils_testing/runner.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2025 The Autoware Contributors | ||
// | ||
// 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. | ||
|
||
#ifndef AUTOWARE_UTILS_TESTING__RUNNER_HPP_ | ||
#define AUTOWARE_UTILS_TESTING__RUNNER_HPP_ | ||
|
||
namespace autoware_utils_testing | ||
{ | ||
|
||
} // namespace autoware_utils_testing | ||
|
||
#endif // AUTOWARE_UTILS_TESTING__RUNNER_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>autoware_utils_testing</name> | ||
<version>1.1.0</version> | ||
<description>The autoware_utils_testing package</description> | ||
<maintainer email="isamu.takagi@tier4.jp">Takagi, Isamu</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake_auto</buildtool_depend> | ||
<buildtool_depend>autoware_cmake</buildtool_depend> | ||
|
||
<depend>gtest_vendor</depend> | ||
<depend>rclcpp</depend> | ||
|
||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>autoware_lint_common</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2025 The Autoware Contributors | ||
// | ||
// 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 "autoware_utils_testing/gtest/ros_env.hpp" | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
namespace autoware_utils_testing::gtest | ||
{ | ||
|
||
class RclcppEnvironment : public testing::Environment | ||
{ | ||
public: | ||
RclcppEnvironment(int argc, char ** argv) : argc(argc), argv(argv) {} | ||
void SetUp() override { rclcpp::init(argc, argv); } | ||
void TearDown() override { rclcpp::shutdown(); } | ||
|
||
private: | ||
int argc; | ||
char ** argv; | ||
}; | ||
|
||
testing::Environment * ros_env(int argc, char ** argv) | ||
{ | ||
return new RclcppEnvironment(argc, argv); | ||
} | ||
|
||
} // namespace autoware_utils_testing::gtest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2025 The Autoware Contributors | ||
// | ||
// 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> | ||
|
||
int main(int argc, char ** argv) | ||
{ | ||
testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |