Skip to content

Commit 8c1b8ff

Browse files
committed
unit-tests/osloader-test: make modules always built for the test
1 parent 0b90d43 commit 8c1b8ff

File tree

9 files changed

+33
-38
lines changed

9 files changed

+33
-38
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
build/inc/
2-
posix-mac-addons
2+
posix-macos-addons
33

CMakeLists.txt

+2-9
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@
4848
cmake_minimum_required(VERSION 2.8.12)
4949
project(OSAL C)
5050

51-
# TODO-MAC:
52-
# This enforces the cwd() to be in the ${CMAKE_BINARY_DIR}. This needed for
53-
# deterministic calculation of full path to MODULE*.dylib libraries when running
54-
# from CLion.
55-
# https://stackoverflow.com/a/38166227/598057
56-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
57-
5851
# OSAL_SYSTEM_OSTYPE and OSAL_SYSTEM_BSPTYPE indicate which of the OS packages
5952
# to build. These are required and must be defined. Confirm that this exists
6053
# and error out now if it does not.
@@ -167,7 +160,6 @@ target_include_directories(osal_${OSAL_SYSTEM_OSTYPE}_impl PRIVATE
167160
# Define the external "osal" static library target
168161
# This is a combination of the generic parts with the low level
169162
# system-specific parts
170-
add_subdirectory(posix-mac-addons)
171163

172164
add_library(osal STATIC
173165
src/os/shared/osapi-binsem.c
@@ -199,7 +191,8 @@ target_include_directories(osal INTERFACE
199191
${OSAL_API_INCLUDE_DIRECTORIES}
200192
)
201193

202-
target_link_libraries(osal posix-mac-addons)
194+
add_subdirectory(posix-macos-addons)
195+
target_link_libraries(osal posix-macos-addons)
203196

204197
# Link the OSAL with the BSP
205198
target_link_libraries(osal osal_bsp)

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ test.unit: build.cmake
66
cd build.commandline.dir && ./unit-tests/oscore-test/osal_core_UT
77
cd build.commandline.dir && ./unit-tests/osfile-test/osal_file_UT
88
cd build.commandline.dir && ./unit-tests/osfilesys-test/osal_filesys_UT
9-
cd build.commandline.dir && ./unit-tests/osloader-test/osal_loader_UT
9+
# There are module files that the binary expects in the output folder.
10+
# Therefore cd'ing to the test binary's dir.
11+
cd build.commandline.dir/unit-tests/osloader-test && ./osal_loader_UT
1012
cd build.commandline.dir && ./unit-tests/ostimer-test/osal_timer_UT
1113
cd build.commandline.dir && ./unit-tests/osnetwork-test/osal_network_UT
1214

@@ -26,6 +28,7 @@ test.integration: build.cmake
2628
build.cmake:
2729
mkdir -p build.commandline.dir
2830
cd build.commandline.dir && cmake -G Ninja \
31+
-DCMAKE_C_FLAGS="-Werror" \
2932
-DENABLE_UNIT_TESTS=1 \
3033
-DOSAL_SYSTEM_OSTYPE=posix \
3134
-DOSAL_SYSTEM_BSPTYPE=pc-linux \

src/os/posix/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ add_library(osal_posix_impl OBJECT
1717
ostimer.c
1818
)
1919

20-
target_link_libraries(osal_posix_impl posix-mac-addons)
20+
target_link_libraries(osal_posix_impl posix-macos-addons)
2121

2222
# TODO-MAC: Defining this globally but can be made more focused.
2323
# 1) In file included from /sandbox/cFS/osal/src/os/posix/osloader.c:32:

src/os/posix/osapi.c

+17-18
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@
2727
#include "os-posix.h"
2828
#include "bsp-impl.h"
2929

30-
#include <posix-mac-time.h>
31-
#include <posix-mac-semaphore2-debug.h>
32-
#include <posix-mac-stubs.h>
33-
#include <posix-mac-pthread.h>
34-
35-
#include <assert.h>
3630
#include <sched.h>
3731

32+
#include <posix-macos-time.h>
33+
#include <posix-macos-semaphore2-debug.h>
34+
#include <posix-macos-stubs.h>
35+
#include <posix-macos-pthread.h>
36+
3837
/*
3938
* Defines
4039
*/
@@ -95,7 +94,7 @@ typedef struct
9594

9695
typedef struct
9796
{
98-
mac_sem2_t id;
97+
sem_t id;
9998
}OS_impl_countsem_internal_record_t;
10099

101100
/* Mutexes */
@@ -108,7 +107,7 @@ typedef struct
108107
typedef struct
109108
{
110109
bool is_async;
111-
mac_sem2_t data_sem;
110+
sem_t data_sem;
112111
int out_fd;
113112
}OS_impl_console_internal_record_t;
114113

@@ -1821,7 +1820,7 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op
18211820
return OS_INVALID_SEM_VALUE;
18221821
}
18231822

1824-
if (mac_sem2_debug_init(&OS_impl_count_sem_table[sem_id].id, 0, sem_initial_value) < 0)
1823+
if (sem_init(&OS_impl_count_sem_table[sem_id].id, 0, sem_initial_value) < 0)
18251824
{
18261825
return OS_SEM_FAILURE;
18271826
}
@@ -1841,7 +1840,7 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op
18411840
*-----------------------------------------------------------------*/
18421841
int32 OS_CountSemDelete_Impl (uint32 sem_id)
18431842
{
1844-
if (mac_sem2_debug_destroy(&OS_impl_count_sem_table[sem_id].id) < 0)
1843+
if (sem_destroy(&OS_impl_count_sem_table[sem_id].id) < 0)
18451844
{
18461845
return OS_SEM_FAILURE;
18471846
}
@@ -1861,7 +1860,7 @@ int32 OS_CountSemDelete_Impl (uint32 sem_id)
18611860
*-----------------------------------------------------------------*/
18621861
int32 OS_CountSemGive_Impl ( uint32 sem_id )
18631862
{
1864-
if (mac_sem2_debug_post(&OS_impl_count_sem_table[sem_id].id) < 0)
1863+
if (sem_post(&OS_impl_count_sem_table[sem_id].id) < 0)
18651864
{
18661865
return OS_SEM_FAILURE;
18671866
}
@@ -1881,7 +1880,7 @@ int32 OS_CountSemGive_Impl ( uint32 sem_id )
18811880
*-----------------------------------------------------------------*/
18821881
int32 OS_CountSemTake_Impl ( uint32 sem_id )
18831882
{
1884-
if (mac_sem2_debug_wait(&OS_impl_count_sem_table[sem_id].id) < 0)
1883+
if (sem_wait(&OS_impl_count_sem_table[sem_id].id) < 0)
18851884
{
18861885
return OS_SEM_FAILURE;
18871886
}
@@ -1908,7 +1907,7 @@ int32 OS_CountSemTimedWait_Impl ( uint32 sem_id, uint32 msecs )
19081907
*/
19091908
OS_CompAbsDelayTime(msecs, &ts);
19101909

1911-
if (mac_sem2_debug_timedwait(&OS_impl_count_sem_table[sem_id].id, &ts) == 0)
1910+
if (sem_timedwait(&OS_impl_count_sem_table[sem_id].id, &ts) == 0)
19121911
{
19131912
result = OS_SUCCESS;
19141913
}
@@ -1938,7 +1937,7 @@ int32 OS_CountSemGetInfo_Impl (uint32 sem_id, OS_count_sem_prop_t *count_prop)
19381937
{
19391938
int sval;
19401939

1941-
if (mac_sem2_debug_getvalue(&OS_impl_count_sem_table[sem_id].id, &sval) < 0)
1940+
if (sem_getvalue(&OS_impl_count_sem_table[sem_id].id, &sval) < 0)
19421941
{
19431942
return OS_SEM_FAILURE;
19441943
}
@@ -2414,7 +2413,7 @@ void OS_ConsoleWakeup_Impl(uint32 local_id)
24142413
if (local->is_async)
24152414
{
24162415
/* post the sem for the utility task to run */
2417-
mac_sem2_debug_post(&local->data_sem);
2416+
sem_post(&local->data_sem);
24182417
}
24192418
else
24202419
{
@@ -2441,7 +2440,7 @@ static void* OS_ConsoleTask_Entry(void* arg)
24412440
while (true)
24422441
{
24432442
OS_ConsoleOutput_Impl(local_arg.value);
2444-
mac_sem2_debug_wait(&local->data_sem);
2443+
sem_wait(&local->data_sem);
24452444
}
24462445
return NULL;
24472446
} /* end OS_ConsoleTask_Entry */
@@ -2469,7 +2468,7 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id)
24692468

24702469
if (local->is_async)
24712470
{
2472-
if (mac_sem2_debug_init(&OS_impl_console_table[local_id].data_sem, 0, 0) < 0)
2471+
if (sem_init(&OS_impl_console_table[local_id].data_sem, 0, 0) < 0)
24732472
{
24742473
return_code = OS_SEM_FAILURE;
24752474
}
@@ -2481,7 +2480,7 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id)
24812480

24822481
if (return_code != OS_SUCCESS)
24832482
{
2484-
mac_sem2_debug_destroy(&OS_impl_console_table[local_id].data_sem);
2483+
sem_destroy(&OS_impl_console_table[local_id].data_sem);
24852484
}
24862485
}
24872486
}

src/os/posix/ostimer.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
#include "os-posix.h"
2727

28-
#include <posix-mac-stubs.h>
29-
#include <posix-mac-timer.h>
28+
#include <posix-macos-stubs.h>
29+
#include <posix-macos-timer.h>
3030

3131
/****************************************************************************************
3232
EXTERNAL FUNCTION PROTOTYPES

src/unit-test-coverage/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function (add_coverage_tests SETNAME)
9090
${UT_COVERAGE_LINK_FLAGS}
9191
${OSALCOVERAGE_STUB_LIB_LIST}
9292
ut_assert
93-
posix-mac-addons
93+
posix-macos-addons
9494
)
9595
add_test(${TESTNAME} ${TESTNAME}-testrunner)
9696

src/unit-test-coverage/posix/modules/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ foreach(MODULE ${MODULE_LIST})
3535
target_compile_options(ut_${SETNAME}_${MODULE} PRIVATE
3636
${UT_COVERAGE_COMPILE_FLAGS}
3737
)
38-
target_link_libraries(ut_${SETNAME}_${MODULE} PUBLIC posix-mac-addons)
38+
target_link_libraries(ut_${SETNAME}_${MODULE} PUBLIC posix-macos-addons)
3939
endif ()
4040
endforeach()
4141

src/unit-tests/osloader-test/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ set(TEST_MODULE_FILES
44
ut_osloader_module_test.c
55
ut_osloader_symtable_test.c
66
ut_osloader_test.c)
7-
7+
8+
add_osal_ut_exe(osal_loader_UT ${TEST_MODULE_FILES})
9+
810
# build many copies of the test module
911
# we need to have unique modules to load up to OS_MAX_MODULES
1012
# This will cover up to 32 -- extras are ignored. If needed this can be increased.
@@ -16,7 +18,5 @@ while(MOD GREATER 0)
1618
COMPILE_DEFINITIONS "MODULE_NAME=module${MOD}"
1719
PREFIX ""
1820
LIBRARY_OUTPUT_DIRECTORY eeprom1)
21+
add_dependencies(osal_loader_UT MODULE${MOD})
1922
endwhile(MOD GREATER 0)
20-
21-
add_osal_ut_exe(osal_loader_UT ${TEST_MODULE_FILES})
22-

0 commit comments

Comments
 (0)