-
Notifications
You must be signed in to change notification settings - Fork 222
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
WIP: os/posix: port of the posix implementation to macOS #352
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
build/inc/ | ||
posix-macos-addons | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
|
||
test: test.unit test.integration | ||
|
||
test.unit: build.cmake | ||
cd build.commandline.dir && ./unit-tests/oscore-test/osal_core_UT | ||
cd build.commandline.dir && ./unit-tests/osfile-test/osal_file_UT | ||
cd build.commandline.dir && ./unit-tests/osfilesys-test/osal_filesys_UT | ||
# There are module files that the binary expects in the output folder. | ||
# Therefore cd'ing to the test binary's dir. | ||
cd build.commandline.dir/unit-tests/osloader-test && ./osal_loader_UT | ||
cd build.commandline.dir && ./unit-tests/ostimer-test/osal_timer_UT | ||
cd build.commandline.dir && ./unit-tests/osnetwork-test/osal_network_UT | ||
|
||
test.integration: build.cmake | ||
cd build.commandline.dir && ./tests/bin-sem-flush-test | ||
cd build.commandline.dir && ./tests/bin-sem-test | ||
cd build.commandline.dir && ./tests/bin-sem-timeout-test | ||
cd build.commandline.dir && ./tests/count-sem-test | ||
cd build.commandline.dir && ./tests/file-api-test | ||
cd build.commandline.dir && ./tests/mutex-test | ||
cd build.commandline.dir && ./tests/osal-core-test | ||
cd build.commandline.dir && ./tests/queue-timeout-test | ||
cd build.commandline.dir && ./tests/sem-speed-test | ||
cd build.commandline.dir && ./tests/symbol-api-test | ||
cd build.commandline.dir && ./tests/timer-test | ||
|
||
build.cmake: | ||
mkdir -p build.commandline.dir | ||
cd build.commandline.dir && cmake -G Ninja \ | ||
-DCMAKE_C_FLAGS="-Werror" \ | ||
-DENABLE_UNIT_TESTS=1 \ | ||
-DOSAL_SYSTEM_OSTYPE=posix \ | ||
-DOSAL_SYSTEM_BSPTYPE=pc-linux \ | ||
-DOSAL_INCLUDEDIR=src/bsp/pc-linux/config \ | ||
.. | ||
cd build.commandline.dir && ninja |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ target_link_libraries(osal_bsp | |
# Note - although GCC understands the same flags for compile and link here, this may | ||
# not be true on all platforms so the compile and link flags are specified separately. | ||
if (NOT CMAKE_CROSSCOMPILING) | ||
set(UT_COVERAGE_COMPILE_FLAGS -pg --coverage) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened here: #420. |
||
set(UT_COVERAGE_LINK_FLAGS -pg --coverage) | ||
set(UT_COVERAGE_COMPILE_FLAGS --coverage) | ||
set(UT_COVERAGE_LINK_FLAGS --coverage) | ||
endif() | ||
|
||
# This indicates where to stage target binaries created during the build | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ | |
* dlsym() | ||
*/ | ||
|
||
#include <dlfcn.h> | ||
|
||
/**************************************************************************************** | ||
DEFINES | ||
***************************************************************************************/ | ||
|
@@ -72,6 +74,26 @@ OS_impl_module_internal_record_t OS_impl_module_table[OS_MAX_MODULES]; | |
DEFINES | ||
***************************************************************************************/ | ||
|
||
/* | ||
* Determine what to pass in for the first parameter of dlsym() | ||
* | ||
* If the "os-impl-loader.h" header already defined this, then use that. | ||
* | ||
* Otherwise, check if the C library provides an "RTLD_DEFAULT" symbol - | ||
* This symbol is not POSIX standard but many implementations do provide it. | ||
* | ||
* Lastly, if nothing else works, use NULL. This is technically undefined | ||
* behavior per POSIX, but most implementations do seem to interpret this | ||
* as referring to the complete process (base executable + all loaded modules). | ||
*/ | ||
#ifndef OSAL_DLSYM_DEFAULT_HANDLE | ||
#ifdef RTLD_DEFAULT | ||
#define OSAL_DLSYM_DEFAULT_HANDLE RTLD_DEFAULT | ||
#else | ||
#define OSAL_DLSYM_DEFAULT_HANDLE NULL | ||
#endif | ||
#endif | ||
|
||
/**************************************************************************************** | ||
FUNCTION PROTOTYPES | ||
***************************************************************************************/ | ||
|
@@ -123,7 +145,16 @@ int32 OS_SymbolLookup_Impl( cpuaddr *SymbolAddress, const char *SymbolName ) | |
* call dlerror() to clear any prior error that might have occured. | ||
*/ | ||
dlerror(); | ||
Function = dlsym((void *)0, SymbolName); | ||
|
||
/// TODO-MAC: | ||
/// [BEGIN] 04 OS_SymbolLookup | ||
/// [ PASS] 04.001 ut_osloader_symtable_test.c:149 - #1 Invalid-pointer-arg-1 | ||
/// [ PASS] 04.002 ut_osloader_symtable_test.c:158 - #2 Invalid-pointer-arg-2 | ||
/// [ PASS] 04.003 ut_osloader_symtable_test.c:167 - #3 Symbol-not-found | ||
/// Current working dir: /sandbox/cFS/osal/build.commandline.dir | ||
/// [ FAIL] 04.004 ut_osloader_symtable_test.c:186 - #4 Nominal | ||
/// [ END] 04 OS_SymbolLookup TOTAL::4 PASS::3 FAIL::1 MIR::0 TSF::0 N/A::0 | ||
Function = dlsym((void *)OSAL_DLSYM_DEFAULT_HANDLE, SymbolName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #214. |
||
dlError = dlerror(); | ||
if( dlError == NULL ) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,7 +134,8 @@ void TestTasks(void) | |
status = OS_TaskDelete( TaskData[tasknum].task_id ); | ||
|
||
UtDebug("Delete Status = %d, Id = %d\n",(int)status,(int)TaskData[tasknum].task_id); | ||
|
||
/// TODO-MAC: 1 of 5 full runs of make this line fails: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reported here: #424. |
||
/// [ FAIL] 01.205 osal-core-test.c:138 - OS_TaskDelete, self exiting task | ||
UtAssert_True(status != OS_SUCCESS, "OS_TaskDelete, self exiting task"); | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ set(TEST_MODULE_FILES | |
ut_osloader_module_test.c | ||
ut_osloader_symtable_test.c | ||
ut_osloader_test.c) | ||
|
||
|
||
add_osal_ut_exe(osal_loader_UT ${TEST_MODULE_FILES}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened as a separate one here: #431. |
||
|
||
# build many copies of the test module | ||
# we need to have unique modules to load up to OS_MAX_MODULES | ||
# This will cover up to 32 -- extras are ignored. If needed this can be increased. | ||
|
@@ -16,7 +18,5 @@ while(MOD GREATER 0) | |
COMPILE_DEFINITIONS "MODULE_NAME=module${MOD}" | ||
PREFIX "" | ||
LIBRARY_OUTPUT_DIRECTORY eeprom1) | ||
add_dependencies(osal_loader_UT MODULE${MOD}) | ||
endwhile(MOD GREATER 0) | ||
|
||
add_osal_ut_exe(osal_loader_UT ${TEST_MODULE_FILES}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the first obvious candidate for removal or extraction. I have not found a single place in the osal from where I can run ALL unit and integration tests. I suspect that there is some private branch of
nasa/osal
where such script exists.Having such a "one-click" solution for running all of the tests is essential for making sure that the osal is not broken when making changes and testing them on both Linux and macOS.
Please advise if I should remove this custom
Makefile
and rather use some existing test scripts.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this will satisfy it: #403.