Skip to content

Commit 91a53b8

Browse files
EduPonzmergify[bot]
authored andcommitted
Build profiling tests as alternate build in Ubuntu CI (#4989)
* Refs #21219: Always build profilling tests executable if CMake option is set Signed-off-by: eduponz <eduardoponz@eprosima.com> * Refs #21219: Build profiling tests as alternate build in Ubuntu CI Signed-off-by: eduponz <eduardoponz@eprosima.com> * Refs #21219: Fix profilling tests build Signed-off-by: eduponz <eduardoponz@eprosima.com> * Refs #21219: Uncrustify Signed-off-by: eduponz <eduardoponz@eprosima.com> --------- Signed-off-by: eduponz <eduardoponz@eprosima.com> (cherry picked from commit 2d4c6ac)
1 parent 1b6c12f commit 91a53b8

5 files changed

Lines changed: 237 additions & 89 deletions

File tree

.github/workflows/reusable-ubuntu-ci.yml

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -683,18 +683,19 @@ jobs:
683683
show_skipped: 'False'
684684

685685
fastdds_alternative_builds:
686+
needs: fastdds_build
686687
runs-on: ${{ inputs.os-image }}
687688
strategy:
688689
fail-fast: false
689690
matrix:
690691
cmake-build-type:
691692
- 'RelWithDebInfo'
692693
steps:
693-
- name: Sync eProsima/Fast-DDS repository
694-
uses: eProsima/eProsima-CI/external/checkout@v0
694+
- name: Download build artifacts
695+
uses: eProsima/eProsima-CI/external/download-artifact@v0
695696
with:
696-
path: src/fastrtps
697-
ref: ${{ inputs.fastdds-branch }}
697+
name: fastdds_build_${{ inputs.label }}
698+
path: ${{ github.workspace }}
698699

699700
- name: Install Fix Python version
700701
uses: eProsima/eProsima-CI/external/setup-python@v0
@@ -719,7 +720,7 @@ jobs:
719720
- name: Install Python dependencies
720721
uses: eProsima/eProsima-CI/multiplatform/install_python_packages@v0
721722
with:
722-
packages: vcstool xmlschema
723+
packages: vcstool xmlschema msparser
723724
upgrade: false
724725

725726
- name: Setup CCache
@@ -728,12 +729,38 @@ jobs:
728729
with:
729730
api_token: ${{ secrets.GITHUB_TOKEN }}
730731

731-
- name: Fetch Fast DDS dependencies
732-
uses: eProsima/eProsima-CI/multiplatform/vcs_import@v0
732+
- name: Sync osrf/osrf_testing_tools_cpp repository
733+
uses: eProsima/eProsima-CI/external/checkout@v0
733734
with:
734-
vcs_repos_file: ${{ github.workspace }}/src/fastrtps/fastrtps.repos
735-
destination_workspace: src
736-
skip_existing: 'true'
735+
repository: osrf/osrf_testing_tools_cpp
736+
path: src/osrf_testing_tools_cpp
737+
ref: 1.4.0
738+
739+
- name: OSRF testing tools build
740+
uses: eProsima/eProsima-CI/multiplatform/colcon_build@v0
741+
with:
742+
colcon_meta_file: ''
743+
colcon_build_args: ${{ inputs.colcon-args }} --packages-select osrf_testing_tools_cpp
744+
cmake_args: '-DBUILD_TESTING=OFF'
745+
cmake_args_default: ''
746+
cmake_build_type: ${{ matrix.cmake-build-type }}
747+
workspace: ${{ github.workspace }}
748+
749+
- name: Profilling tests build
750+
uses: eProsima/eProsima-CI/multiplatform/colcon_build@v0
751+
with:
752+
colcon_meta_file: ${{ github.workspace }}/src/fastrtps/.github/workflows/config/fastdds_build.meta
753+
colcon_build_args: ${{ inputs.colcon-args }} --packages-up-to fastrtps
754+
cmake_args: '-DPROFILING_TESTS=ON ${{ inputs.cmake-args }}'
755+
cmake_args_default: ${{ env.colcon-build-default-cmake-args }}
756+
cmake_build_type: ${{ matrix.cmake-build-type }}
757+
workspace: ${{ github.workspace }}
758+
workspace_dependencies: ${{ github.workspace }}/install
759+
760+
- name: Clean workspace - Profiling tests
761+
run: |
762+
cd ${{ github.workspace }}
763+
rm -rf build install log src/osrf_testing_tools_cpp
737764
738765
- name: No security colcon build
739766
continue-on-error: true

test/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ endif()
6565
# Profiling tests using valgrind
6666
###############################################################################
6767
if(NOT ((MSVC OR MSVC_IDE)) AND PROFILING_TESTS)
68-
find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
69-
if(CTEST_MEMORYCHECK_COMMAND)
70-
add_subdirectory(profiling)
71-
endif()
68+
add_subdirectory(profiling)
7269
endif()
7370

7471
###############################################################################

test/profiling/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ if(Python3_Interpreter_FOUND)
5454
###############################################################################
5555
# MemoryTest
5656
###############################################################################
57+
find_program(VALGRIND_PROGRAM NAMES valgrind)
58+
59+
# If valgrind is not found, set it to "valgrind" so that the test can be run with
60+
# the appropriate environment set at runtime.
61+
if (${VALGRIND_PROGRAM} STREQUAL "valgrind-NOTFOUND")
62+
set(VALGRIND_PROGRAM "valgrind")
63+
endif()
64+
5765
add_test(NAME MemoryTest
5866
COMMAND ${Python3_EXECUTABLE} memory_tests.py)
5967

@@ -67,7 +75,7 @@ if(Python3_Interpreter_FOUND)
6775
set_property(TEST MemoryTest APPEND PROPERTY ENVIRONMENT
6876
"PROFILING_BINS=$<TARGET_FILE:MemoryTest>")
6977
set_property(TEST MemoryTest APPEND PROPERTY ENVIRONMENT
70-
"VALGRIND_BIN=${CTEST_MEMORYCHECK_COMMAND}")
78+
"VALGRIND_BIN=${VALGRIND_PROGRAM}")
7179
if(SECURITY)
7280
set_property(TEST MemoryTest APPEND PROPERTY ENVIRONMENT
7381
"CERTS_PATH=${PROJECT_SOURCE_DIR}/test/certs")
@@ -89,7 +97,7 @@ if(Python3_Interpreter_FOUND)
8997
set_property(TEST CyclesTest APPEND PROPERTY ENVIRONMENT
9098
"PROFILING_BINS=$<TARGET_FILE:MemoryTest>")
9199
set_property(TEST CyclesTest APPEND PROPERTY ENVIRONMENT
92-
"VALGRIND_BIN=valgrind")
100+
"VALGRIND_BIN=${VALGRIND_PROGRAM}")
93101
if(SECURITY)
94102
set_property(TEST CyclesTest APPEND PROPERTY ENVIRONMENT
95103
"CERTS_PATH=${PROJECT_SOURCE_DIR}/test/certs")

test/profiling/MemoryTestTypes.cpp

Lines changed: 68 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,62 +22,96 @@
2222
using namespace eprosima::fastrtps;
2323
using namespace eprosima::fastrtps::rtps;
2424

25-
bool MemoryDataType::serialize(void*data,SerializedPayload_t* payload)
25+
bool MemoryDataType::serialize(
26+
void* data,
27+
SerializedPayload_t* payload)
2628
{
2729
MemoryType* lt = (MemoryType*)data;
2830

2931

3032
*(uint32_t*)payload->data = lt->seqnum;
31-
*(uint32_t*)(payload->data+4) = (uint32_t)lt->data.size();
33+
*(uint32_t*)(payload->data + 4) = (uint32_t)lt->data.size();
3234

3335
//std::copy(lt->data.begin(),lt->data.end(),payload->data+8);
3436
memcpy(payload->data + 8, lt->data.data(), lt->data.size());
35-
payload->length = (uint32_t)(8+lt->data.size());
37+
payload->length = (uint32_t)(8 + lt->data.size());
3638
return true;
3739
}
3840

39-
bool MemoryDataType::deserialize(SerializedPayload_t* payload,void * data)
41+
bool MemoryDataType::serialize(
42+
void* data,
43+
eprosima::fastrtps::rtps::SerializedPayload_t* payload,
44+
eprosima::fastdds::dds::DataRepresentationId_t)
45+
{
46+
return serialize(data, payload);
47+
}
48+
49+
bool MemoryDataType::deserialize(
50+
SerializedPayload_t* payload,
51+
void* data)
4052
{
4153
MemoryType* lt = (MemoryType*)data;
4254
lt->seqnum = *(uint32_t*)payload->data;
43-
uint32_t siz = *(uint32_t*)(payload->data+4);
44-
std::copy(payload->data+8,payload->data+8+siz,lt->data.begin());
55+
uint32_t siz = *(uint32_t*)(payload->data + 4);
56+
std::copy(payload->data + 8, payload->data + 8 + siz, lt->data.begin());
4557
return true;
4658
}
4759

48-
std::function<uint32_t()> MemoryDataType::getSerializedSizeProvider(void* data)
60+
std::function<uint32_t()> MemoryDataType::getSerializedSizeProvider(
61+
void* data)
4962
{
5063
return [data]() -> uint32_t
51-
{
52-
MemoryType *tdata = static_cast<MemoryType*>(data);
53-
uint32_t size = 0;
64+
{
65+
MemoryType* tdata = static_cast<MemoryType*>(data);
66+
uint32_t size = 0;
67+
68+
size = (uint32_t)(sizeof(uint32_t) + sizeof(uint32_t) + tdata->data.size());
5469

55-
size = (uint32_t)(sizeof(uint32_t) + sizeof(uint32_t) + tdata->data.size());
70+
return size;
71+
};
72+
}
5673

57-
return size;
58-
};
74+
std::function<uint32_t()> MemoryDataType::getSerializedSizeProvider(
75+
void* data,
76+
eprosima::fastdds::dds::DataRepresentationId_t)
77+
{
78+
return getSerializedSizeProvider(data);
5979
}
6080

6181
void* MemoryDataType::createData()
6282
{
6383

6484
return (void*)new MemoryType();
6585
}
66-
void MemoryDataType::deleteData(void* data)
86+
87+
void MemoryDataType::deleteData(
88+
void* data)
6789
{
6890

6991
delete((MemoryType*)data);
7092
}
7193

72-
73-
bool TestCommandDataType::serialize(void*data,SerializedPayload_t* payload)
94+
bool TestCommandDataType::serialize(
95+
void* data,
96+
SerializedPayload_t* payload)
7497
{
7598
TestCommandType* t = (TestCommandType*)data;
7699
*(TESTCOMMAND*)payload->data = t->m_command;
77100
payload->length = 4;
78101
return true;
79102
}
80-
bool TestCommandDataType::deserialize(SerializedPayload_t* payload,void * data)
103+
104+
bool TestCommandDataType::serialize(
105+
void* data,
106+
eprosima::fastrtps::rtps::SerializedPayload_t* payload,
107+
eprosima::fastdds::dds::DataRepresentationId_t)
108+
{
109+
return serialize(data, payload);
110+
}
111+
112+
bool TestCommandDataType::deserialize(
113+
SerializedPayload_t* payload,
114+
void* data)
81115
{
82116
TestCommandType* t = (TestCommandType*)data;
83117
// cout << "PAYLOAD LENGTH: "<<payload->length << endl;
@@ -87,24 +121,34 @@ bool TestCommandDataType::deserialize(SerializedPayload_t* payload,void * data)
87121
return true;
88122
}
89123

90-
std::function<uint32_t()> TestCommandDataType::getSerializedSizeProvider(void*)
124+
std::function<uint32_t()> TestCommandDataType::getSerializedSizeProvider(
125+
void*)
91126
{
92127
return []() -> uint32_t
93-
{
94-
uint32_t size = 0;
128+
{
129+
uint32_t size = 0;
95130

96-
size = (uint32_t)sizeof(uint32_t);
131+
size = (uint32_t)sizeof(uint32_t);
97132

98-
return size;
99-
};
133+
return size;
134+
};
135+
}
136+
137+
std::function<uint32_t()> TestCommandDataType::getSerializedSizeProvider(
138+
void* data,
139+
eprosima::fastdds::dds::DataRepresentationId_t)
140+
{
141+
return getSerializedSizeProvider(data);
100142
}
101143

102144
void* TestCommandDataType::createData()
103145
{
104146

105147
return (void*)new TestCommandType();
106148
}
107-
void TestCommandDataType::deleteData(void* data)
149+
150+
void TestCommandDataType::deleteData(
151+
void* data)
108152
{
109153

110154
delete((TestCommandType*)data);

0 commit comments

Comments
 (0)