Skip to content

Commit

Permalink
Fix nasa#297: Refactor OSAL C library stubs
Browse files Browse the repository at this point in the history
Rather than utilizing a separate "stub-map-to-real.h" file that would
need to be injected into the build of the unit under test, this builds
the mappings into the mapping into the override files themselves.

The stub functions are then moved into a separate header under a
unique name with an OCS_ prefix.

This introduces a number of new files, as what previously required
a single header now requires two, but it it eliminates the separate
map file.
  • Loading branch information
jphickey committed Dec 13, 2019
1 parent 155e9eb commit a2a97b7
Show file tree
Hide file tree
Showing 261 changed files with 2,167 additions and 1,103 deletions.
10 changes: 5 additions & 5 deletions src/unit-test-coverage/portable/coveragetest-posixfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

#include "ut-osfileapi.h"

#include <overrides/stdio.h>
#include <overrides/stdlib.h>
#include <overrides/unistd.h>
#include <overrides/fcntl.h>
#include <overrides/sys/stat.h>
#include <OCS_stdio.h>
#include <OCS_stdlib.h>
#include <OCS_unistd.h>
#include <OCS_fcntl.h>
#include <OCS_stat.h>

#define OSAPI_TEST_FUNCTION_RC(func,exp) \
{ \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <osapi.h>
#include <os-impl.h>

#include <overrides/time.h>
#include <OCS_time.h>

#define OSAPI_TEST_FUNCTION_RC(func,exp) \
{ \
Expand Down
8 changes: 4 additions & 4 deletions src/unit-test-coverage/portable/coveragetest-posixio.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#include <osapi.h>
#include <os-impl.h>

#include <overrides/stdlib.h>
#include <overrides/unistd.h>
#include <overrides/fcntl.h>
#include <overrides/errno.h>
#include <OCS_stdlib.h>
#include <OCS_unistd.h>
#include <OCS_fcntl.h>
#include <OCS_errno.h>

#include "ut-osfileapi.h"

Expand Down
5 changes: 3 additions & 2 deletions src/unit-test-coverage/posix/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# - UT_C_FLAGS are enabled to include any code coverage instrumentation

# the "overrides" dir contains empty versions of the C-library include files.
include_directories(BEFORE ${OSALCOVERAGE_SOURCE_DIR}/ut-stubs/inc/overrides)
include_directories(${OSALCOVERAGE_SOURCE_DIR}/ut-stubs/inc)
include_directories(${OSALCOVERAGE_SOURCE_DIR}/ut-stubs/override_inc)

foreach(MODULE ${MODULE_LIST})
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/ut-${MODULE}.c)
Expand All @@ -21,4 +22,4 @@ foreach(MODULE ${MODULE_LIST})
endif ()
endforeach()



251 changes: 0 additions & 251 deletions src/unit-test-coverage/posix/modules/src/stub-map-to-real.h

This file was deleted.

1 change: 0 additions & 1 deletion src/unit-test-coverage/posix/modules/src/ut-osapi.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* pull in the OSAL configuration */
#include "stub-map-to-real.h"
#include "osconfig.h"

/*
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/posix/src/coveragetest-osapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <osapi.h>
#include <os-impl.h>

#include <overrides/stdlib.h>
#include <OCS_stdlib.h>


void Test_OS_Lock_Global_Impl(void)
Expand Down
5 changes: 3 additions & 2 deletions src/unit-test-coverage/shared/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
# stub (OCS) counterpart
# - UT_C_FLAGS are enabled to include any code coverage instrumentation

# the "overrides" dir contains empty versions of the C-library include files.
include_directories(BEFORE ${OSALCOVERAGE_SOURCE_DIR}/ut-stubs/inc/overrides)
# the "override_inc" dir contains replacement versions of the C-library include files.
include_directories(${OSALCOVERAGE_SOURCE_DIR}/ut-stubs/inc)
include_directories(${OSALCOVERAGE_SOURCE_DIR}/ut-stubs/override_inc)

foreach(MODULE ${MODULE_LIST})
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/ut-osapi-${MODULE}.c)
Expand Down
60 changes: 0 additions & 60 deletions src/unit-test-coverage/shared/modules/src/stub-map-to-real.h

This file was deleted.

Loading

0 comments on commit a2a97b7

Please sign in to comment.