Skip to content

Commit 8a62e45

Browse files
celskeggsthomas-bcCopilot
committed
Fix FileWorker compatibility with 32-bit baremetal platforms (#5046)
* Fix FileWorker compatibility with 32-bit baremetal platforms * Improve non-Posix registration of FileTester Co-authored-by: Copilot <copilot@github.com> * use STATUS instead of INFO --------- Co-authored-by: thomas-bc <thomas.boyerchammard@gmail.com> Co-authored-by: Copilot <copilot@github.com>
1 parent f2de7ce commit 8a62e45

2 files changed

Lines changed: 30 additions & 18 deletions

File tree

Svc/FileWorker/CMakeLists.txt

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
#
1111
####
1212

13-
if (BUILD_TESTING AND NOT __FPRIME_NO_UT_GEN__)
14-
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/test/FileTester")
15-
endif()
1613

1714
register_fprime_module(
1815
AUTOCODER_INPUTS
@@ -39,18 +36,31 @@ register_fprime_ut(
3936
"${CMAKE_CURRENT_LIST_DIR}"
4037
)
4138

42-
register_fprime_ut(
43-
FileWorkerTestError
44-
AUTOCODER_INPUTS
45-
"${CMAKE_CURRENT_LIST_DIR}/FileWorker.fpp"
46-
SOURCES
47-
"${CMAKE_CURRENT_LIST_DIR}/test/ut/FileWorkerErrTestMain.cpp"
48-
"${CMAKE_CURRENT_LIST_DIR}/test/ut/FileWorkerErrTester.cpp"
49-
CHOOSES_IMPLEMENTATIONS
50-
Svc_FileWorker_test_FileTester
51-
DEPENDS
52-
STest
53-
UT_AUTO_HELPERS
54-
WORKING_DIRECTORY
55-
"${CMAKE_CURRENT_LIST_DIR}"
56-
)
39+
# FileTester is a test dependency and only supported on Posix platforms, therefore:
40+
# - only attempt to add the FileTester module in BUILD_TESTING
41+
# - only add the FileWorkerTestError test if the FileTester module was successfully added
42+
if (BUILD_TESTING AND NOT __FPRIME_NO_UT_GEN__)
43+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/test/FileTester")
44+
45+
# Target will not exist on non-Posix platforms, so guard against its existence
46+
if (TARGET Svc_FileWorker_test_FileTester)
47+
register_fprime_ut(
48+
FileWorkerTestError
49+
AUTOCODER_INPUTS
50+
"${CMAKE_CURRENT_LIST_DIR}/FileWorker.fpp"
51+
SOURCES
52+
"${CMAKE_CURRENT_LIST_DIR}/test/ut/FileWorkerErrTestMain.cpp"
53+
"${CMAKE_CURRENT_LIST_DIR}/test/ut/FileWorkerErrTester.cpp"
54+
CHOOSES_IMPLEMENTATIONS
55+
Svc_FileWorker_test_FileTester
56+
DEPENDS
57+
STest
58+
UT_AUTO_HELPERS
59+
WORKING_DIRECTORY
60+
"${CMAKE_CURRENT_LIST_DIR}"
61+
)
62+
else()
63+
# Only print message if we're in BUILD_TESTING *and* FileTester isn't available
64+
message(STATUS "Svc/FileWorker: FileTester test dependency is only supported on Posix, skipping FileWorkerTestError")
65+
endif()
66+
endif()

Svc/FileWorker/test/FileTester/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
restrict_platforms(Posix)
2+
13
register_fprime_implementation(
24
Svc_FileWorker_test_FileTester
35
IMPLEMENTS

0 commit comments

Comments
 (0)