Skip to content

Commit

Permalink
feat(autoware_utils_testing): create test utils
Browse files Browse the repository at this point in the history
Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp>
  • Loading branch information
isamu-takagi committed Mar 6, 2025
1 parent 009d98c commit 5a6defe
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 0 deletions.
16 changes: 16 additions & 0 deletions autoware_utils_testing/CMakeLists.txt
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()
11 changes: 11 additions & 0 deletions autoware_utils_testing/README.md
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.
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_
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 autoware_utils_testing/include/autoware_utils_testing/runner.hpp
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_
22 changes: 22 additions & 0 deletions autoware_utils_testing/package.xml
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>
39 changes: 39 additions & 0 deletions autoware_utils_testing/src/gtest/ros_env.cpp
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
21 changes: 21 additions & 0 deletions autoware_utils_testing/test/main.cpp
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();
}

0 comments on commit 5a6defe

Please sign in to comment.