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

[21219] Build profiling tests as alternate build in Ubuntu CI #4989

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
47 changes: 37 additions & 10 deletions .github/workflows/reusable-ubuntu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -683,18 +683,19 @@ jobs:
show_skipped: 'False'

fastdds_alternative_builds:
needs: fastdds_build
runs-on: ${{ inputs.os-image }}
strategy:
fail-fast: false
matrix:
cmake-build-type:
- 'RelWithDebInfo'
steps:
- name: Sync eProsima/Fast-DDS repository
uses: eProsima/eProsima-CI/external/checkout@v0
- name: Download build artifacts
uses: eProsima/eProsima-CI/external/download-artifact@v0
with:
path: src/fastrtps
ref: ${{ inputs.fastdds-branch }}
name: fastdds_build_${{ inputs.label }}
path: ${{ github.workspace }}

- name: Install Fix Python version
uses: eProsima/eProsima-CI/external/setup-python@v0
Expand All @@ -719,7 +720,7 @@ jobs:
- name: Install Python dependencies
uses: eProsima/eProsima-CI/multiplatform/install_python_packages@v0
with:
packages: vcstool xmlschema
packages: vcstool xmlschema msparser
upgrade: false

- name: Setup CCache
Expand All @@ -728,12 +729,38 @@ jobs:
with:
api_token: ${{ secrets.GITHUB_TOKEN }}

- name: Fetch Fast DDS dependencies
uses: eProsima/eProsima-CI/multiplatform/vcs_import@v0
- name: Sync osrf/osrf_testing_tools_cpp repository
uses: eProsima/eProsima-CI/external/checkout@v0
with:
vcs_repos_file: ${{ github.workspace }}/src/fastrtps/fastrtps.repos
destination_workspace: src
skip_existing: 'true'
repository: osrf/osrf_testing_tools_cpp
path: src/osrf_testing_tools_cpp
ref: 1.4.0

- name: OSRF testing tools build
uses: eProsima/eProsima-CI/multiplatform/colcon_build@v0
with:
colcon_meta_file: ''
colcon_build_args: ${{ inputs.colcon-args }} --packages-select osrf_testing_tools_cpp
cmake_args: '-DBUILD_TESTING=OFF'
cmake_args_default: ''
cmake_build_type: ${{ matrix.cmake-build-type }}
workspace: ${{ github.workspace }}

- name: Profilling tests build
uses: eProsima/eProsima-CI/multiplatform/colcon_build@v0
with:
colcon_meta_file: ${{ github.workspace }}/src/fastrtps/.github/workflows/config/fastdds_build.meta
colcon_build_args: ${{ inputs.colcon-args }} --packages-up-to fastrtps
cmake_args: '-DPROFILING_TESTS=ON ${{ inputs.cmake-args }}'
cmake_args_default: ${{ env.colcon-build-default-cmake-args }}
cmake_build_type: ${{ matrix.cmake-build-type }}
workspace: ${{ github.workspace }}
workspace_dependencies: ${{ github.workspace }}/install

- name: Clean workspace - Profiling tests
run: |
cd ${{ github.workspace }}
rm -rf build install log src/osrf_testing_tools_cpp

- name: No security colcon build
continue-on-error: true
Expand Down
5 changes: 1 addition & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ endif()
# Profiling tests using valgrind
###############################################################################
if(NOT ((MSVC OR MSVC_IDE)) AND PROFILING_TESTS)
find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
if(CTEST_MEMORYCHECK_COMMAND)
add_subdirectory(profiling)
endif()
add_subdirectory(profiling)
endif()

###############################################################################
Expand Down
12 changes: 10 additions & 2 deletions test/profiling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ if(Python3_Interpreter_FOUND)
###############################################################################
# MemoryTest
###############################################################################
find_program(VALGRIND_PROGRAM NAMES valgrind)

# If valgrind is not found, set it to "valgrind" so that the test can be run with
# the appropriate environment set at runtime.
if (${VALGRIND_PROGRAM} STREQUAL "valgrind-NOTFOUND")
set(VALGRIND_PROGRAM "valgrind")
endif()

add_test(NAME MemoryTest
COMMAND ${Python3_EXECUTABLE} memory_tests.py)

Expand All @@ -67,7 +75,7 @@ if(Python3_Interpreter_FOUND)
set_property(TEST MemoryTest APPEND PROPERTY ENVIRONMENT
"PROFILING_BINS=$<TARGET_FILE:MemoryTest>")
set_property(TEST MemoryTest APPEND PROPERTY ENVIRONMENT
"VALGRIND_BIN=${CTEST_MEMORYCHECK_COMMAND}")
"VALGRIND_BIN=${VALGRIND_PROGRAM}")
if(SECURITY)
set_property(TEST MemoryTest APPEND PROPERTY ENVIRONMENT
"CERTS_PATH=${PROJECT_SOURCE_DIR}/test/certs")
Expand All @@ -89,7 +97,7 @@ if(Python3_Interpreter_FOUND)
set_property(TEST CyclesTest APPEND PROPERTY ENVIRONMENT
"PROFILING_BINS=$<TARGET_FILE:MemoryTest>")
set_property(TEST CyclesTest APPEND PROPERTY ENVIRONMENT
"VALGRIND_BIN=valgrind")
"VALGRIND_BIN=${VALGRIND_PROGRAM}")
if(SECURITY)
set_property(TEST CyclesTest APPEND PROPERTY ENVIRONMENT
"CERTS_PATH=${PROJECT_SOURCE_DIR}/test/certs")
Expand Down
92 changes: 68 additions & 24 deletions test/profiling/MemoryTestTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,62 +22,96 @@
using namespace eprosima::fastrtps;
using namespace eprosima::fastrtps::rtps;

bool MemoryDataType::serialize(void*data,SerializedPayload_t* payload)
bool MemoryDataType::serialize(
void* data,
SerializedPayload_t* payload)
{
MemoryType* lt = (MemoryType*)data;


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

//std::copy(lt->data.begin(),lt->data.end(),payload->data+8);
memcpy(payload->data + 8, lt->data.data(), lt->data.size());
payload->length = (uint32_t)(8+lt->data.size());
payload->length = (uint32_t)(8 + lt->data.size());
return true;
}

bool MemoryDataType::deserialize(SerializedPayload_t* payload,void * data)
bool MemoryDataType::serialize(
void* data,
eprosima::fastrtps::rtps::SerializedPayload_t* payload,
eprosima::fastdds::dds::DataRepresentationId_t)
{
return serialize(data, payload);
}

bool MemoryDataType::deserialize(
SerializedPayload_t* payload,
void* data)
{
MemoryType* lt = (MemoryType*)data;
lt->seqnum = *(uint32_t*)payload->data;
uint32_t siz = *(uint32_t*)(payload->data+4);
std::copy(payload->data+8,payload->data+8+siz,lt->data.begin());
uint32_t siz = *(uint32_t*)(payload->data + 4);
std::copy(payload->data + 8, payload->data + 8 + siz, lt->data.begin());
return true;
}

std::function<uint32_t()> MemoryDataType::getSerializedSizeProvider(void* data)
std::function<uint32_t()> MemoryDataType::getSerializedSizeProvider(
void* data)
{
return [data]() -> uint32_t
{
MemoryType *tdata = static_cast<MemoryType*>(data);
uint32_t size = 0;
{
MemoryType* tdata = static_cast<MemoryType*>(data);
uint32_t size = 0;

size = (uint32_t)(sizeof(uint32_t) + sizeof(uint32_t) + tdata->data.size());

size = (uint32_t)(sizeof(uint32_t) + sizeof(uint32_t) + tdata->data.size());
return size;
};
}

return size;
};
std::function<uint32_t()> MemoryDataType::getSerializedSizeProvider(
void* data,
eprosima::fastdds::dds::DataRepresentationId_t)
{
return getSerializedSizeProvider(data);
}

void* MemoryDataType::createData()
{

return (void*)new MemoryType();
}
void MemoryDataType::deleteData(void* data)

void MemoryDataType::deleteData(
void* data)
{

delete((MemoryType*)data);
}


bool TestCommandDataType::serialize(void*data,SerializedPayload_t* payload)
bool TestCommandDataType::serialize(
void* data,
SerializedPayload_t* payload)
{
TestCommandType* t = (TestCommandType*)data;
*(TESTCOMMAND*)payload->data = t->m_command;
payload->length = 4;
return true;
}
bool TestCommandDataType::deserialize(SerializedPayload_t* payload,void * data)

bool TestCommandDataType::serialize(
void* data,
eprosima::fastrtps::rtps::SerializedPayload_t* payload,
eprosima::fastdds::dds::DataRepresentationId_t)
{
return serialize(data, payload);
}

bool TestCommandDataType::deserialize(
SerializedPayload_t* payload,
void* data)
{
TestCommandType* t = (TestCommandType*)data;
// cout << "PAYLOAD LENGTH: "<<payload->length << endl;
Expand All @@ -87,24 +121,34 @@ bool TestCommandDataType::deserialize(SerializedPayload_t* payload,void * data)
return true;
}

std::function<uint32_t()> TestCommandDataType::getSerializedSizeProvider(void*)
std::function<uint32_t()> TestCommandDataType::getSerializedSizeProvider(
void*)
{
return []() -> uint32_t
{
uint32_t size = 0;
{
uint32_t size = 0;

size = (uint32_t)sizeof(uint32_t);
size = (uint32_t)sizeof(uint32_t);

return size;
};
return size;
};
}

std::function<uint32_t()> TestCommandDataType::getSerializedSizeProvider(
void* data,
eprosima::fastdds::dds::DataRepresentationId_t)
{
return getSerializedSizeProvider(data);
}

void* TestCommandDataType::createData()
{

return (void*)new TestCommandType();
}
void TestCommandDataType::deleteData(void* data)

void TestCommandDataType::deleteData(
void* data)
{

delete((TestCommandType*)data);
Expand Down
Loading
Loading