-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix nasa#821, add accessor functions for version strings
Adds 3 simple API calls: const char *OS_GetVersion(void); const char *OS_GetVersionCodeName(void); const char *OS_GetVersionDescription(void); These directly return the values of string macros in osapi-version.h. The accessor function should be the preferred way to get the OSAL version string (vs. using macro directly) as it is evaluated at OSAL library compile time, rather than application compile time, and thus will remain correct in the event that OSAL is relinked without recompiling the application.
- Loading branch information
Showing
5 changed files
with
247 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer" | ||
* | ||
* Copyright (c) 2019 United States Government as represented by | ||
* the Administrator of the National Aeronautics and Space Administration. | ||
* All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* \file osapi-version.c | ||
* \ingroup shared | ||
* \author joseph.p.hickey@nasa.gov | ||
* | ||
* Defines functions that return version information strings | ||
*/ | ||
|
||
/**************************************************************************************** | ||
INCLUDE FILES | ||
***************************************************************************************/ | ||
#include <osapi-version.h> | ||
|
||
/*---------------------------------------------------------------- | ||
* | ||
* Function: OS_GetVersion | ||
* | ||
* Purpose: Implemented per public OSAL API | ||
* See description in API and header file for detail | ||
* | ||
*-----------------------------------------------------------------*/ | ||
const char *OS_GetVersion(void) | ||
{ | ||
return OS_VERSION; | ||
} | ||
|
||
/*---------------------------------------------------------------- | ||
* | ||
* Function: OS_GetVersionCodeName | ||
* | ||
* Purpose: Implemented per public OSAL API | ||
* See description in API and header file for detail | ||
* | ||
*-----------------------------------------------------------------*/ | ||
const char *OS_GetVersionCodeName(void) | ||
{ | ||
return OS_VERSION_CODENAME; | ||
} | ||
|
||
/*---------------------------------------------------------------- | ||
* | ||
* Function: OS_GetVersionDescription | ||
* | ||
* Purpose: Implemented per public OSAL API | ||
* See description in API and header file for detail | ||
* | ||
*-----------------------------------------------------------------*/ | ||
const char *OS_GetVersionDescription(void) | ||
{ | ||
return OS_VERSION_STRING; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ set(MODULE_LIST | |
task | ||
timebase | ||
time | ||
version | ||
) | ||
|
||
set(SHARED_COVERAGE_LINK_LIST | ||
|
118 changes: 118 additions & 0 deletions
118
src/unit-test-coverage/shared/src/coveragetest-version.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer" | ||
* | ||
* Copyright (c) 2019 United States Government as represented by | ||
* the Administrator of the National Aeronautics and Space Administration. | ||
* All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* \file coveragetest-version.c | ||
* \ingroup shared | ||
* \author joseph.p.hickey@nasa.gov | ||
* | ||
* Exercise the "GetVersion" functions. These functions do not have any actual | ||
* logic, they just directly return fixed strings, but they should be called as | ||
* part of unit test for coverage reasons. | ||
* | ||
* The strings are free-form and no specific format is checked, the only real | ||
* requirement is that they are not NULL. | ||
*/ | ||
#include "os-shared-coveragetest.h" | ||
|
||
#include "osapi-version.h" | ||
|
||
/* | ||
********************************************************************************** | ||
** PUBLIC API FUNCTIONS | ||
********************************************************************************** | ||
*/ | ||
|
||
void Test_OS_GetVersion(void) | ||
{ | ||
/* | ||
* Test Case For: | ||
* const char *OS_GetVersion(void) | ||
*/ | ||
const char *Result; | ||
|
||
Result = OS_GetVersion(); | ||
UtAssert_NOT_NULL(Result); | ||
|
||
/* | ||
* Display the version description string, just for informational purposes | ||
*/ | ||
UtPrintf("OS_GetVersion() Returned: %s\n", Result); | ||
} | ||
|
||
void Test_OS_GetVersionCodeName(void) | ||
{ | ||
/* | ||
* Test Case For: | ||
* const char *OS_GetVersionCodeName(void) | ||
*/ | ||
const char *Result; | ||
|
||
Result = OS_GetVersionCodeName(); | ||
UtAssert_NOT_NULL(Result); | ||
|
||
/* | ||
* Display the code name string, just for informational purposes | ||
*/ | ||
UtPrintf("OS_GetVersionCodeName() Returned: %s\n", Result); | ||
} | ||
|
||
void Test_OS_GetVersionDescription(void) | ||
{ | ||
/* | ||
* Test Case For: | ||
* const char *OS_GetVersionDescription(void) | ||
*/ | ||
const char *Result; | ||
|
||
Result = OS_GetVersionDescription(); | ||
UtAssert_NOT_NULL(Result); | ||
|
||
/* | ||
* Display the version description string, just for informational purposes | ||
*/ | ||
UtPrintf("OS_GetVersionDescription() Returned: %s\n", Result); | ||
} | ||
|
||
|
||
/* Osapi_Test_Setup | ||
* | ||
* Purpose: | ||
* Called by the unit test tool to set up the app prior to each test | ||
*/ | ||
void Osapi_Test_Setup(void) {} | ||
|
||
/* | ||
* Osapi_Test_Teardown | ||
* | ||
* Purpose: | ||
* Called by the unit test tool to tear down the app after each test | ||
*/ | ||
void Osapi_Test_Teardown(void) {} | ||
|
||
/* | ||
* Register the test cases to execute with the unit test tool | ||
*/ | ||
void UtTest_Setup(void) | ||
{ | ||
ADD_TEST(OS_GetVersion); | ||
ADD_TEST(OS_GetVersionCodeName); | ||
ADD_TEST(OS_GetVersionDescription); | ||
} |