Skip to content

Commit

Permalink
Refs #20165. Fixes on windows
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González <[email protected]>
  • Loading branch information
richiware committed Sep 11, 2024
1 parent 8479516 commit 6cbd197
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
11 changes: 10 additions & 1 deletion test/dds/xtypes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ set(DDS_XTYPES_SOURCE ${COMMON_SOURCE}
TypeLookupServiceSubscriber.cpp
)

if(WIN32)
set_source_files_properties(${PROJECT_SOURCE_DIR}/test/dds-types-test/mapsPubSubTypes.cxx PROPERTIES COMPILE_OPTIONS /bigobj)
set_source_files_properties(TypeLookupServicePublisher.cpp PROPERTIES COMPILE_OPTIONS /bigobj)
set_source_files_properties(TypeLookupServiceSubscriber.cpp PROPERTIES COMPILE_OPTIONS /bigobj)
endif()

add_executable(DDSXtypesCommunication ${DDS_XTYPES_SOURCE})
target_compile_definitions(DDSXtypesCommunication PRIVATE
$<$<AND:$<NOT:$<BOOL:${WIN32}>>,$<STREQUAL:"${CMAKE_BUILD_TYPE}","Debug">>:__DEBUG>
Expand Down Expand Up @@ -116,7 +122,10 @@ if(PYTHONINTERP_FOUND)
set(TEST_NAME DDSXtypesCommunication_${TEST_DEFINITION})
add_test(
NAME ${TEST_NAME}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_BUILDER}
COMMAND
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_BINARY_DIR}/${TEST_BUILDER}
--app $<TARGET_FILE:DDSXtypesCommunication>
${TEST_DEFINITION}
)

Expand Down
37 changes: 15 additions & 22 deletions test/dds/xtypes/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,18 @@ def parse_options():
)

parser.add_argument(
'file',
nargs=1,
help='JSON file.'
)
'-a',
'--app',
type=str,
required=True,
help='Path to the executable test.'
)

parser.add_argument(
'file',
nargs=1,
help='JSON file.'
)

parser.add_argument(
'-d',
Expand Down Expand Up @@ -90,24 +98,8 @@ def define_args(participant):
return args


def find_executable(executable_name):
"""Find the full path of an executable file by name."""
executable_path = shutil.which(executable_name)
if not executable_path or not os.path.isfile(executable_path) or not os.access(executable_path, os.X_OK):
# Try looking in the current working directory
executable_path = os.path.join(os.getcwd(), executable_name)
if not os.path.isfile(executable_path) or not os.access(executable_path, os.X_OK):
return None
return executable_path


def define_commands(test_cases):
def define_commands(executable_path, test_cases):
"""Create commands for each participant adding executable to args."""
executable_path = find_executable('DDSXtypesCommunication')
if not executable_path:
print("ERROR: Executable 'DDSXtypesCommunication' not found in the system PATH or is not executable.")
sys.exit(1)

all_commands = []
for test_case in test_cases:
# For each test case, create commands for all participants
Expand Down Expand Up @@ -193,6 +185,7 @@ async def execute_commands(test_case, commands):
async with asyncio.TaskGroup() as tg:
for command in commands:
tasks.append(tg.create_task(run_command(test_case, command, MAX_TIME)))
await asyncio.sleep(0.3) # Avoid errors with SharedMemory starting all commands at same time

return sum([proc.result() for proc in tasks])

Expand Down Expand Up @@ -227,7 +220,7 @@ async def execute_commands(test_case, commands):

for test_case in test_cases:
# Define commands for each test case
commands = define_commands([test_case])
commands = define_commands(args.app, [test_case])
# Execute the commands and get the return value
test_value = asyncio.run(execute_commands(test_case['TestCase'], commands))
total_test_value += test_value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(TYPELOOKUPSERVICETESTS_SOURCE TypeLookupServiceTests.cpp

if(WIN32)
add_definitions(-D_WIN32_WINNT=0x0601)
set_source_files_properties(TypeLookupServiceTests.cpp PROPERTIES COMPILE_OPTIONS /bigobj)
endif()

add_executable(TypeLookupServiceTests ${TYPELOOKUPSERVICETESTS_SOURCE})
Expand Down

0 comments on commit 6cbd197

Please sign in to comment.