Skip to content

Commit

Permalink
Merge pull request #1006 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
osal Integration candidate: 2021-05-18
  • Loading branch information
astrogeco authored May 19, 2021
2 parents 9756b03 + c8a97ab commit 1d183e9
Show file tree
Hide file tree
Showing 54 changed files with 1,717 additions and 4,647 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/codeql-osal-default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "CodeQL Analysis OSAL Default Build"

on:
push:
pull_request:

env:
SIMULATION: native
ENABLE_UNIT_TESTS: true
OMIT_DEPRECATED: true
BUILDTYPE: release
PERMISSIVE_MODE: true

jobs:

#Checks for duplicate actions. Skips push actions if there is a matching or duplicate pull-request action.
check-for-duplicates:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
skip_after_successful_duplicate: 'true'
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'


CodeQL-Build:
#Continue if check-for-duplicates found no duplicates. Always runs for pull-requests.
needs: check-for-duplicates
if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }}
runs-on: ubuntu-18.04
timeout-minutes: 15

steps:
- name: Checkout submodule
uses: actions/checkout@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: c
queries: +security-extended, security-and-quality

- name: Set up for build
run: |
cp Makefile.sample Makefile
make prep
- name: Build
run: make -j

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF

## Version History

### Development Build: v5.1.0-rc1+dev452

- Makes filenames better match terms used in implementation.
- Propagates return code from the caller in low-level implementations when status is not `OS_SUCCESS`.
- The status returned from `OS_rmdir()` should now be correct if the implementation failed.
- Adds details to log file and can be cross referenced back to documentation.
- Updates most of the conditions in the "unit tests" to use the support macros whenever possible.
- The macros display the function being called as well as the return value being checked for and enables that documented return codes are being tested. Removes repetition in the test programs.
- Removes blank lines in test log while preserving extra newlines in the event that the test case was intentionally adding whitespace.
- Adds tests for object id inline functions: `OS_ObjectIdToInteger`, `OS_ObjectIdFromInteger`, `OS_ObjectIdEqual`, `OS_ObjectIdDefined`
- Changes tests to use valid inputs for all `OS_mkdir` calls.
- [docs] Improves config guide documentation issues referenced in #384, #640, #672
- [continuous-integration] Adds new workflow to display CodeQL alerts preview

### Development Build: v5.1.0-rc1+dev434

- Updates the configuration guide to reflect cmake build system and the currently provided set of OS/BSP layers. Removes obsolete items from guide.
Expand Down
32 changes: 12 additions & 20 deletions doc/OSAL-Configuration-Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,7 @@ These terms are identified as proper nouns and are capitalized.
| MMU | Memory Management Unit. A piece of hardware that manages virtual memory systems. It automatically translates addresses into physical addresses so that an application can be linked with one set of addresses but actually reside in a different part of memory. |
| Network | A connection between subsystems used for communication purposes. |
| Platform | See "Hardware Platform" above. |
| User | Anyone who interacts with the Software Application or system in its operational state. A user can be a developer, a tester, an operator, or a maintainer.
| Application (APP) | A generic term for a computer program in a desktop or embedded system. An Application is generally not part of the operating system. |
| Application Programmer's Interface (API) | A set of routines, protocols, and tools for building software applications |
| Board Support Package (BSP) | A collection of user-provided facilities that interface an OS and the cFE with a specific hardware platform. The BSP is responsible for hardware initialization. |
| Core Flight Executive (cFE) | A runtime environment and a set of services for hosting FSW Applications |
| Cyclic Redundancy Check | A polynomial based method for checking that a data set has remained unchanged from one time period to another. |
| Developer | Anyone who is coding a software Application. |
| Hardware Platform | The target hardware that hosts the Operating System and Application. |
| Interface Control Document | A document that describes the software interface, in detail, to another piece of software or hardware. |
| I/O Data | Any data being written to and read from an I/O port. No structure is placed on the data and no distinction as to the type of I/O device. I/O data is defined separately from memory data because it has a separate API and it's an optional interface of the cFE. |
| Log | A collection of data that an application stores that provides information to diagnose and debug FSW problems. |
| Memory Data | Any data being written to and read from memory. No structure is placed on the data and no distinction as to the type of memory is made. |
| MMU | Memory Management Unit. A piece of hardware that manages virtual memory systems. It automatically translates addresses into physical addresses so that an application can be linked with one set of addresses but actually reside in a different part of memory. |
| Network | A connection between subsystems used for communication purposes. |
| Platform | See "Hardware Platform" above. |
| User | Anyone who interacts with the Software Application or system in its operational state. A user can be a developer, a tester, an operator, or a maintainer.|
| User | Anyone who interacts with the Software Application or system in its operational state. A user can be a developer, a tester, an operator, or a maintainer.

# How to Configure, Build, and Run the OSAL

Expand Down Expand Up @@ -265,7 +250,7 @@ makefiles, supplying values for the required variables.
The following example will generate a build tree that allows testing
of the OSAL library on a standard Linux workstation:

```
```bash
$ mkdir build
$ cd build
$ cmake \
Expand Down Expand Up @@ -328,8 +313,9 @@ build system can be directly used as a component within a larger
"mission" build, as long as the same variables are supplied via the
parent cmake script:

```
SET(OSAL_SYSTEM_BSPTYPE “pc-linux”)
```cmake
SET(OSAL_SYSTEM_OSTYPE "posix")
SET(OSAL_SYSTEM_BSPTYPE "generic-linux")
ADD_SUBDIRECTORY(path/to/osal)
```

Expand All @@ -356,6 +342,12 @@ this type of setup, the developer must manually propagate the include directorie
the path to the `src/os/inc` subdirectory) and any necessary compile definitions to the
parent application.

#### Linking OSAL into another target
```cmake
add_executable(my_executable main.c)
target_link_libraries(my_executable osal)
```

### Cross compiling with Cmake

To cross compile, cmake uses a separate "toolchain file" that indicates
Expand Down Expand Up @@ -779,4 +771,4 @@ For example:
| 1.5 | 12/13/11 | Updates for OSAL 3.4 release -- added support for sis-rtems Removed cFE configuration text | A. Cudmore |
| 1.6 | 12/21/12 | Updates for OSAL 4.0 release -- Removed Cygwin and OS X configurations | A. Cudmore |
| 4.1 | 01/17/14 | Updates for OSAL 4.1 release. Sync document version ID to software version. Add information for building and running unit tests. | A. Cudmore |
| 4.2 | 01/31/16 | Moved osconfig.h description into section 2.2.h Consolidated the \"classic\" build and prerequisites setup into section 2.3. Added new section 2.4 on provisioning a build using cmake. Minor </br> modifications to subsequent sections only where there was a difference between cmake and classic builds; i.e. the cmake build has no \"make config\" or \"make depend\". Updated title page to replace Code 582 banner with cFS. Added header. | J.Hickey S.Strege |
| 4.2 | 01/31/16 | Moved osconfig.h description into section 2.2.h Consolidated the \"classic\" build and prerequisites setup into section 2.3. Added new section 2.4 on provisioning a build using cmake. Minor </br> modifications to subsequent sections only where there was a difference between cmake and classic builds; i.e. the cmake build has no \"make config\" or \"make depend\". Updated title page to replace Code 582 banner with cFS. Added header. | J.Hickey S.Strege |
2 changes: 1 addition & 1 deletion src/os/inc/osapi-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/*
* Development Build Macro Definitions
*/
#define OS_BUILD_NUMBER 434
#define OS_BUILD_NUMBER 452
#define OS_BUILD_BASELINE "v5.1.0-rc1"

/*
Expand Down
17 changes: 17 additions & 0 deletions src/os/shared/inc/os-shared-idmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ struct OS_common_record
uint16 refcount;
};

typedef enum
{
OS_TASK_BASE = 0,
OS_QUEUE_BASE = OS_TASK_BASE + OS_MAX_TASKS,
OS_BINSEM_BASE = OS_QUEUE_BASE + OS_MAX_QUEUES,
OS_COUNTSEM_BASE = OS_BINSEM_BASE + OS_MAX_BIN_SEMAPHORES,
OS_MUTEX_BASE = OS_COUNTSEM_BASE + OS_MAX_COUNT_SEMAPHORES,
OS_STREAM_BASE = OS_MUTEX_BASE + OS_MAX_MUTEXES,
OS_DIR_BASE = OS_STREAM_BASE + OS_MAX_NUM_OPEN_FILES,
OS_TIMEBASE_BASE = OS_DIR_BASE + OS_MAX_NUM_OPEN_DIRS,
OS_TIMECB_BASE = OS_TIMEBASE_BASE + OS_MAX_TIMEBASES,
OS_MODULE_BASE = OS_TIMECB_BASE + OS_MAX_TIMERS,
OS_FILESYS_BASE = OS_MODULE_BASE + OS_MAX_MODULES,
OS_CONSOLE_BASE = OS_FILESYS_BASE + OS_MAX_FILE_SYSTEMS,
OS_MAX_TOTAL_RECORDS = OS_CONSOLE_BASE + OS_MAX_CONSOLES
} OS_ObjectIndex_t;

/*
* Type of locking that should occur when checking IDs.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/os/shared/src/osapi-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ int32 OS_rmdir(const char *path)
return_code = OS_TranslatePath(path, local_path);
if (return_code == OS_SUCCESS)
{
OS_DirRemove_Impl(local_path);
return_code = OS_DirRemove_Impl(local_path);
}

return return_code;
Expand Down
17 changes: 0 additions & 17 deletions src/os/shared/src/osapi-idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,6 @@
#define OS_LOCK_KEY_FIXED_VALUE 0x4D000000
#define OS_LOCK_KEY_INVALID ((osal_key_t) {0})

typedef enum
{
OS_TASK_BASE = 0,
OS_QUEUE_BASE = OS_TASK_BASE + OS_MAX_TASKS,
OS_BINSEM_BASE = OS_QUEUE_BASE + OS_MAX_QUEUES,
OS_COUNTSEM_BASE = OS_BINSEM_BASE + OS_MAX_BIN_SEMAPHORES,
OS_MUTEX_BASE = OS_COUNTSEM_BASE + OS_MAX_COUNT_SEMAPHORES,
OS_STREAM_BASE = OS_MUTEX_BASE + OS_MAX_MUTEXES,
OS_DIR_BASE = OS_STREAM_BASE + OS_MAX_NUM_OPEN_FILES,
OS_TIMEBASE_BASE = OS_DIR_BASE + OS_MAX_NUM_OPEN_DIRS,
OS_TIMECB_BASE = OS_TIMEBASE_BASE + OS_MAX_TIMEBASES,
OS_MODULE_BASE = OS_TIMECB_BASE + OS_MAX_TIMERS,
OS_FILESYS_BASE = OS_MODULE_BASE + OS_MAX_MODULES,
OS_CONSOLE_BASE = OS_FILESYS_BASE + OS_MAX_FILE_SYSTEMS,
OS_MAX_TOTAL_RECORDS = OS_CONSOLE_BASE + OS_MAX_CONSOLES
} OS_ObjectIndex_t;

/*
* A structure containing the user-specified
* details of a "foreach" iteration request
Expand Down
12 changes: 6 additions & 6 deletions src/tests/file-api-test/file-api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,10 @@ void TestMkRmDirFreeBytes(void)
"Checking Free Blocks: status=%d blocks=%lu", (int)status, (unsigned long)statbuf.blocks_free);

/* make the two directories */
status = OS_mkdir(dir1, 0);
status = OS_mkdir(dir1, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status);

status = OS_mkdir(dir2, 0);
status = OS_mkdir(dir2, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 2 = %d", (int)status);

/* now create two files in the two directories (1 file per directory) */
Expand Down Expand Up @@ -580,10 +580,10 @@ void TestOpenReadCloseDir(void)

/* make the two directories */

status = OS_mkdir(dir1, 0);
status = OS_mkdir(dir1, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status);

status = OS_mkdir(dir2, 0);
status = OS_mkdir(dir2, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 2 = %d", (int)status);

/* now create two files in the two directories (1 file per directory) */
Expand Down Expand Up @@ -788,7 +788,7 @@ void TestRename(void)

/* make the directory */

status = OS_mkdir(dir1, 0);
status = OS_mkdir(dir1, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status);

/* now create a file in the directory */
Expand Down Expand Up @@ -866,7 +866,7 @@ void TestStat(void)
strcpy(buffer1, "111111111111");

/* make the directory */
status = OS_mkdir(dir1, 0);
status = OS_mkdir(dir1, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status);

/* now create a file */
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void Test_OS_mkdir(void)
* int32 OS_mkdir (const char *path, uint32 access)
*/
int32 expected = OS_SUCCESS;
int32 actual = OS_mkdir("Dir", 0);
int32 actual = OS_mkdir("Dir", OS_READ_WRITE);

UtAssert_True(actual == expected, "OS_mkdir() (%ld) == OS_SUCCESS", (long)actual);
}
Expand Down
72 changes: 72 additions & 0 deletions src/unit-test-coverage/shared/src/coveragetest-idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,76 @@ void Test_OS_ObjectIdIterator(void)
UtAssert_STUB_COUNT(OS_Unlock_Global_Impl, 2);
}

void Test_OS_ObjectIDInteger(void)
{
/*
* Test Case For:
* OS_ObjectIdToInteger, OS_ObjectIdFromInteger, OS_ObjectIdEqual, OS_ObjectIdDefined
*/
int32 actual;
OS_object_token_t token;
osal_id_t typesI[OS_MAX_TOTAL_RECORDS];
osal_id_t typesJ[OS_MAX_TOTAL_RECORDS];
uint32 intID;
int32 recordscount = 0;
osal_objtype_t idtype;
char str[OS_MAX_API_NAME];

for (idtype = 0; idtype < OS_OBJECT_TYPE_USER; ++idtype)
{
actual = OS_SUCCESS;
while (actual == OS_SUCCESS && recordscount < OS_MAX_TOTAL_RECORDS)
{
snprintf(str, sizeof(str), "%d", (int)recordscount);
actual = OS_ObjectIdAllocateNew(idtype, str, &token);

if (actual == OS_SUCCESS)
{
typesI[recordscount] = token.obj_id;
intID = OS_ObjectIdToInteger(typesI[recordscount]);
typesJ[recordscount] = OS_ObjectIdFromInteger(intID);

recordscount++;
}
}
}

UtAssert_True(recordscount < OS_MAX_TOTAL_RECORDS, "All Id types checked");

for (int i = 0; i < recordscount; i++)
{
UtAssert_True(OS_ObjectIdDefined(typesI[i]), "%lu Is defined", OS_ObjectIdToInteger(typesI[i]));

for (int j = 0; j < recordscount; j++)
{
if (i == j)
{
UtAssert_True(OS_ObjectIdEqual(typesI[i], typesJ[j]), "%lu equals %lu", OS_ObjectIdToInteger(typesI[i]),
OS_ObjectIdToInteger(typesJ[j]));
}
else if (OS_ObjectIdEqual(typesI[i], typesJ[j]))
{
UtAssert_Failed("%lu does not equal %lu", OS_ObjectIdToInteger(typesI[i]),
OS_ObjectIdToInteger(typesJ[j]));
}
}
}
}

void Test_OS_ObjectIDUndefined(void)
{
osal_id_t id;
uint32 intID;

UtAssert_True(!OS_ObjectIdDefined(OS_OBJECT_ID_UNDEFINED), "%lu Is undefined",
OS_ObjectIdToInteger(OS_OBJECT_ID_UNDEFINED));

intID = OS_ObjectIdToInteger(OS_OBJECT_ID_UNDEFINED);
id = OS_ObjectIdFromInteger(intID);

UtAssert_True(!OS_ObjectIdDefined(id), "%lu Is undefined", OS_ObjectIdToInteger(id));
}

/* Osapi_Test_Setup
*
* Purpose:
Expand Down Expand Up @@ -1138,4 +1208,6 @@ void UtTest_Setup(void)
ADD_TEST(OS_GetBaseForObjectType);
ADD_TEST(OS_GetResourceName);
ADD_TEST(OS_ObjectIdIterator);
ADD_TEST(OS_ObjectIDInteger);
ADD_TEST(OS_ObjectIDUndefined);
}
12 changes: 6 additions & 6 deletions src/unit-test-coverage/ut-stubs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ add_custom_target(generate_osal_coverage_stubs
COMMAND ${UT_ASSERT_SOURCE_DIR}/scripts/generate_stubs.pl
--filter=/_Impl$/
--stub-suffix=impl-stubs
--hook-suffix=impl-hooks
--handler-suffix=impl-handlers
${CMAKE_CURRENT_SOURCE_DIR}/src
${OSAL_SHARED_IMPL_HEADERS}
COMMAND ${UT_ASSERT_SOURCE_DIR}/scripts/generate_stubs.pl
--filter=/_Init$/
--stub-suffix=init-stubs
--hook-suffix=init-hooks
--handler-suffix=init-handlers
${CMAKE_CURRENT_SOURCE_DIR}/src
${OSAL_SHARED_IMPL_HEADERS}
COMMAND ${UT_ASSERT_SOURCE_DIR}/scripts/generate_stubs.pl
Expand All @@ -158,15 +158,15 @@ add_library(ut_osapi_impl_stubs STATIC EXCLUDE_FROM_ALL
src/os-shared-console-impl-stubs.c
src/os-shared-countsem-impl-stubs.c
src/os-shared-dir-impl-stubs.c
src/os-shared-file-impl-hooks.c
src/os-shared-file-impl-handlers.c
src/os-shared-file-impl-stubs.c
src/os-shared-filesys-impl-hooks.c
src/os-shared-filesys-impl-handlers.c
src/os-shared-filesys-impl-stubs.c
src/os-shared-heap-impl-stubs.c
src/os-shared-idmap-impl-stubs.c
src/os-shared-module-impl-stubs.c
src/os-shared-mutex-impl-stubs.c
src/os-shared-network-impl-hooks.c
src/os-shared-network-impl-handlers.c
src/os-shared-network-impl-stubs.c
src/os-shared-printf-impl-stubs.c
src/os-shared-queue-impl-stubs.c
Expand Down Expand Up @@ -210,7 +210,7 @@ add_library(ut_osapi_shared_stubs STATIC EXCLUDE_FROM_ALL
src/os-shared-file-stubs.c
src/os-shared-filesys-stubs.c
src/os-shared-globaldefs-stubs.c
src/os-shared-idmap-hooks.c
src/os-shared-idmap-handlers.c
src/os-shared-idmap-stubs.c
src/os-shared-module-stubs.c
src/os-shared-sockets-stubs.c
Expand Down
Loading

0 comments on commit 1d183e9

Please sign in to comment.