Skip to content

Commit fcf0529

Browse files
cyn-liupre-commit-ci[bot]mitsudome-r
authored andcommitted
feat(global_parameter_loader): add gtest to global parameter loader (autowarefoundation#5021)
* add remote * feat(global_parameter_loader): add gtest of global-parameter-loader Signed-off-by: Cynthia Liu <cynthia.liu@autocore.ai> * style(pre-commit): autofix --------- Signed-off-by: Cynthia Liu <cynthia.liu@autocore.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ryohsuke Mitsudome <43976834+mitsudome-r@users.noreply.github.com>
1 parent 0d0069d commit fcf0529

File tree

4 files changed

+57
-1
lines changed

4 files changed

+57
-1
lines changed

build_depends.repos

+5
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ repositories:
4141
type: git
4242
url: https://github.com/MORAI-Autonomous/MORAI-ROS2_morai_msgs.git
4343
version: main
44+
#vehicle
45+
vehicle/sample_vehicle_launch:
46+
type: git
47+
url: https://github.com/autowarefoundation/sample_vehicle_launch.git
48+
version: main

common/global_parameter_loader/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ project(global_parameter_loader)
44
find_package(autoware_cmake REQUIRED)
55
autoware_package()
66

7+
if(BUILD_TESTING)
8+
file(GLOB_RECURSE test_files test/*.cpp)
9+
ament_add_ros_isolated_gtest(test_global_params_launch ${test_files})
10+
endif()
11+
712
ament_auto_package(
813
INSTALL_TO_SHARE
914
launch

common/global_parameter_loader/package.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
<buildtool_depend>ament_cmake_auto</buildtool_depend>
1111
<buildtool_depend>autoware_cmake</buildtool_depend>
1212

13-
<exec_depend>vehicle_info_util</exec_depend>
13+
<depend>sample_vehicle_description</depend>
14+
<depend>vehicle_info_util</depend>
1415

16+
<test_depend>ament_cmake_ros</test_depend>
1517
<test_depend>ament_lint_auto</test_depend>
1618
<test_depend>autoware_lint_common</test_depend>
1719

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2023 The Autoware Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <gtest/gtest.h>
16+
17+
#include <cstdlib>
18+
#include <iostream>
19+
#include <string>
20+
21+
TEST(TestLaunchFile, test_launch_file)
22+
{
23+
// Define the path of Python launch file
24+
std::string global_params_launch_path = "global_params.launch.py";
25+
26+
// Define the parameters you want to pass to the launch file
27+
std::string use_sim_time_param = "false";
28+
std::string vehicle_model_param = "sample_vehicle";
29+
// Construct the command to run the Python launch script with parameters
30+
std::string command = "ros2 launch global_parameter_loader " + global_params_launch_path +
31+
" use_sim_time:=" + use_sim_time_param +
32+
" vehicle_model:=" + vehicle_model_param;
33+
34+
// Use the system() function to execute the command
35+
int result = std::system(command.c_str());
36+
// Check the result of running the launch file
37+
EXPECT_EQ(result, 0);
38+
}
39+
40+
int main(int argc, char * argv[])
41+
{
42+
testing::InitGoogleTest(&argc, argv);
43+
return RUN_ALL_TESTS();
44+
}

0 commit comments

Comments
 (0)