diff --git a/cmake/mission_defaults.cmake b/cmake/mission_defaults.cmake index 20e921613..48dd61d15 100644 --- a/cmake/mission_defaults.cmake +++ b/cmake/mission_defaults.cmake @@ -69,6 +69,6 @@ set(psp_SEARCH_PATH ".") # If ENABLE_UNIT_TEST is enabled, then include the cfe_assert library in # all targets. This can still be overridden in targets.cmake. if (ENABLE_UNIT_TESTS) - list(APPEND MISSION_GLOBAL_APPLIST cfe_assert cfe_testrunner cfe_testcase) + list(APPEND MISSION_GLOBAL_APPLIST cfe_assert cfe_testcase) endif (ENABLE_UNIT_TESTS) diff --git a/cmake/sample_defs/cpu1_cfe_es_startup.scr b/cmake/sample_defs/cpu1_cfe_es_startup.scr index 990942c52..e48880e15 100644 --- a/cmake/sample_defs/cpu1_cfe_es_startup.scr +++ b/cmake/sample_defs/cpu1_cfe_es_startup.scr @@ -1,8 +1,9 @@ -CFE_LIB, sample_lib, SAMPLE_LIB_Init, SAMPLE_LIB, 0, 0, 0x0, 0; -CFE_APP, sample_app, SAMPLE_APP_Main, SAMPLE_APP, 50, 16384, 0x0, 0; -CFE_APP, ci_lab, CI_Lab_AppMain, CI_LAB_APP, 60, 16384, 0x0, 0; -CFE_APP, to_lab, TO_Lab_AppMain, TO_LAB_APP, 70, 16384, 0x0, 0; -CFE_APP, sch_lab, SCH_Lab_AppMain, SCH_LAB_APP, 80, 16384, 0x0, 0; +CFE_LIB, cfe_assert, CFE_Assert_LibInit, ASSERT_LIB, 0, 0, 0x0, 0; +CFE_LIB, sample_lib, SAMPLE_LIB_Init, SAMPLE_LIB, 0, 0, 0x0, 0; +CFE_APP, sample_app, SAMPLE_APP_Main, SAMPLE_APP, 50, 16384, 0x0, 0; +CFE_APP, ci_lab, CI_Lab_AppMain, CI_LAB_APP, 60, 16384, 0x0, 0; +CFE_APP, to_lab, TO_Lab_AppMain, TO_LAB_APP, 70, 16384, 0x0, 0; +CFE_APP, sch_lab, SCH_Lab_AppMain, SCH_LAB_APP, 80, 16384, 0x0, 0; ! ! Startup script fields: ! 1. Object Type -- CFE_APP for an Application, or CFE_LIB for a library. diff --git a/docs/README_functionaltest.md b/docs/README_functionaltest.md index b65a3f439..dddb45484 100644 --- a/docs/README_functionaltest.md +++ b/docs/README_functionaltest.md @@ -2,25 +2,25 @@ This version of CFE includes additional modular libraries and an application to execute functional tests within an unmodified CFE environment. These are -distinct from the unit tests, which are executed separately from CFE in a +distinct from the unit tests, which are executed separately from CFE in a confined (non-CFE, test-specific) environment. ## Building the modules -These modules are built automatically when `ENABLE_UNIT_TESTS` is enabled +These modules are built automatically when `ENABLE_UNIT_TESTS` is enabled in the build. However, they can be added to any CFE build by adding the following to the `APPLIST` of any target in `targets.cmake`: - `cfe_assert`: a CFE-compatible library wrapping the basic UT assert library. This -is the same library that all other unit tests use, but configured to be +is the same library that all other unit tests use, but configured to be dynamically loaded into the CFE environment, and using CFE syslog for its output. This must be the first library loaded for any functional test. - `cfe_testcase`: a CFE-compatible library implementing test cases for CFE core apps. -This must be loaded after `cfe_assert`. +This must be loaded after `cfe_assert`. -- `cfe_testrunner`: a CFE application that actually executes the tests. This is a very -simple app that waits for CFE startup to complete, then executes all registered test +- `cfe_testrunner`: a CFE application that actually executes the tests. This is a very +simple app that waits for CFE startup to complete, then executes all registered test cases. It also must be loaded after `cfe_assert`. @@ -29,12 +29,10 @@ cases. It also must be loaded after `cfe_assert`. To execute tests at startup, the following lines can be added to `cfe_es_startup.scr` on the designated test target: - CFE_LIB, cfe_assert, CFE_Assert_LibInit, ASSERT_LIB, 0, 0, 0x0, 0; - CFE_APP, cfe_testrunner, CFE_TR_AppMain, TESTRUN_APP, 100, 16384, 0x0, 0; - CFE_LIB, cfe_testcase, CFE_Test_Init, CFETEST_LIB, 0, 0, 0x0, 0; - CFE_LIB, psp_test, PSP_Test_Init, PSPTEST_LIB, 0, 0, 0x0, 0; + CFE_LIB, cfe_assert, CFE_Assert_LibInit, ASSERT_LIB, 0, 0, 0x0, 0; + CFE_APP, cfe_testcase, CFE_TestMain, CFE_TEST_APP, 100, 16384, 0x0, 0; -It is important that `cfe_assert` is loaded first, as all other test libraries depend on +It is important that `cfe_assert` is loaded first, as all other test applications depend on symbols provided in this library. The order of loading other test cases should not -matter with respect to symbol resolution, but note that test cases will be executed in -the same order that they are registered. +matter with respect to symbol resolution, but note that test apps may be executed in +a different order than they are listed in the startup script. diff --git a/modules/cfe_assert/CMakeLists.txt b/modules/cfe_assert/CMakeLists.txt index d4cc58182..10ae4428d 100644 --- a/modules/cfe_assert/CMakeLists.txt +++ b/modules/cfe_assert/CMakeLists.txt @@ -4,6 +4,7 @@ project(CFE_ASSERT C) add_cfe_app(cfe_assert src/cfe_assert_io.c src/cfe_assert_init.c + src/cfe_assert_runner.c $ ) diff --git a/modules/cfe_assert/inc/cfe_assert.h b/modules/cfe_assert/inc/cfe_assert.h index 9ca074134..084b860f4 100644 --- a/modules/cfe_assert/inc/cfe_assert.h +++ b/modules/cfe_assert/inc/cfe_assert.h @@ -38,6 +38,7 @@ ** Includes *************************************************************************/ #include "common_types.h" +#include "cfe_es_api_typedefs.h" /************************************************************************ ** Type Definitions @@ -50,11 +51,37 @@ typedef void (*CFE_Assert_StatusCallback_t)(uint8 MessageType, const char *Prefi *************************************************************************/ /************************************************************************/ -/** \brief Application Entry Point Function +/** \brief Library Init Function ** ** \par Description ** This function should be specified in the cfe_es_startup.scr file -** as part of starting this application. +** as part of loading this library. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \return #CFE_SUCCESS if successful, or error code +** +*************************************************************************/ +int32 CFE_Assert_LibInit(CFE_ES_LibId_t LibId); + +/************************************************************************/ +/** \brief Start Test +** +** \par Description +** +** \par Assumptions, External Events, and Notes: +** Must be followed by a call to CFE_Assert_ExecuteTest() +** +** \return None +** +*************************************************************************/ +int32 CFE_Assert_RegisterTest(const char *TestName); + +/************************************************************************/ +/** \brief Execute Test and Exit +** +** \par Description ** ** \par Assumptions, External Events, and Notes: ** None @@ -62,7 +89,7 @@ typedef void (*CFE_Assert_StatusCallback_t)(uint8 MessageType, const char *Prefi ** \return None ** *************************************************************************/ -void CFE_Assert_AppMain(void); +void CFE_Assert_ExecuteTest(void); /************************************************************************/ /** \brief Register a test status callback diff --git a/modules/cfe_assert/src/cfe_assert_init.c b/modules/cfe_assert/src/cfe_assert_init.c index 57d0ac9b5..d2852d92d 100644 --- a/modules/cfe_assert/src/cfe_assert_init.c +++ b/modules/cfe_assert/src/cfe_assert_init.c @@ -47,11 +47,22 @@ void CFE_Assert_RegisterCallback(CFE_Assert_StatusCallback_t Callback) /* * Initialization Function for this library */ -int32 CFE_Assert_LibInit(uint32 LibId) +int32 CFE_Assert_LibInit(CFE_ES_LibId_t LibId) { + int32 status; + + memset(&CFE_Assert_Global, 0, sizeof(CFE_Assert_Global)); + UtTest_EarlyInit(); UT_BSP_Setup(); + status = OS_MutSemCreate(&CFE_Assert_Global.AccessMutex, "CFE_Assert", 0); + if (status != OS_SUCCESS) + { + CFE_ES_WriteToSysLog("%s(): OS_MutSemCreate failed, rc=%d\n", __func__, (int)status); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } + /* * Start a test case for all startup logic. * diff --git a/modules/cfe_assert/src/cfe_assert_io.c b/modules/cfe_assert/src/cfe_assert_io.c index b68326e81..a9561222b 100644 --- a/modules/cfe_assert/src/cfe_assert_io.c +++ b/modules/cfe_assert/src/cfe_assert_io.c @@ -140,6 +140,4 @@ void UT_BSP_EndTest(const UtAssert_TestCounter_t *TestCounters) CFE_ES_WriteToSysLog("TEST COMPLETE: %u tests Segment(s) executed\n\n", (unsigned int)TestCounters->TestSegmentCount); - - OS_TaskExit(); } diff --git a/modules/cfe_assert/src/cfe_assert_priv.h b/modules/cfe_assert/src/cfe_assert_priv.h index 6bfb88b9d..9495590c8 100644 --- a/modules/cfe_assert/src/cfe_assert_priv.h +++ b/modules/cfe_assert/src/cfe_assert_priv.h @@ -39,6 +39,21 @@ *************************************************************************/ #include "common_types.h" #include "cfe_assert.h" +#include "cfe_mission_cfg.h" + +/** + * State of the CFE assert library. + * + * Note that typically tests need to be deferred until the CFE system + * reaches "operational" state. CFE assert has its own internal state + * that needs to be managed as well. + */ +typedef enum +{ + CFE_Assert_State_INIT, /**< Initial state prior to CFE_Assert_LibInit() */ + CFE_Assert_State_STARTUP, /**< cFE starting: successful CFE_Assert_LibInit(), but no tests run yet. */ + CFE_Assert_State_ACTIVE /**< cFE operational: Normal test applications are allowed to run */ +} CFE_Assert_State_Enum_t; /************************************************************************ ** Type Definitions @@ -46,12 +61,51 @@ typedef struct { + CFE_Assert_State_Enum_t LibState; + + /** + * Verbosity of default (syslog) output + * + * This controls the type(s) of assert messages that will be written to syslog. + * This only applies for default syslog output. Use of a status callback + * function overrides this. + */ uint32 CurrVerbosity; /** * Function to invoke to report test status */ CFE_Assert_StatusCallback_t StatusCallback; + + /** + * Mutex to control access to UtAssert structures. + * + * The UtAssert library is designed for single-threaded testing. To use it + * in a multi-threaded environment like CFE, it requires synchronization between + * apps, such that only one test app registers/runs tests at a time. + */ + osal_id_t AccessMutex; + + /** + * AppID of the current UtAssert resource owner. + * + * Only one test application may use UtAssert facilities at a given time. + * This records the AppID of the current owner. It is set when AccessMutex + * is first acquired, and cleared once the tests have executed and the + * resource becomes available to another app. + */ + CFE_ES_AppId_t OwnerAppId; + + /** + * Name of current test set being prepared/executed. + * + * This is set when the AccessMutex is first acquired, and cleared when + * the mutex is released. It is a free-form string to indicate the owner, + * and may or may not match the app name (i.e. test apps may implement + * more than one test set). + */ + char CurrentTestName[CFE_MISSION_MAX_API_LEN]; + } CFE_Assert_Global_t; extern CFE_Assert_Global_t CFE_Assert_Global; diff --git a/modules/cfe_testrunner/src/cfe_testrunner_main.c b/modules/cfe_assert/src/cfe_assert_runner.c similarity index 53% rename from modules/cfe_testrunner/src/cfe_testrunner_main.c rename to modules/cfe_assert/src/cfe_assert_runner.c index e2e8b0cbe..2d58daf46 100644 --- a/modules/cfe_testrunner/src/cfe_testrunner_main.c +++ b/modules/cfe_assert/src/cfe_assert_runner.c @@ -31,8 +31,7 @@ #include "cfe.h" -#include "cfe_testrunner.h" -#include "cfe_assert.h" +#include "cfe_assert_priv.h" #include "uttest.h" #include "utbsp.h" @@ -55,7 +54,7 @@ * * The value is in milliseconds. */ -#define CFE_TESTRUNNER_START_DELAY 4000 +#define CFE_TESTRUNNER_START_DELAY 1000 /* * This uses the message type as the event ID, because these are already @@ -70,7 +69,7 @@ static CFE_EVS_BinFilter_t CFE_TR_EventFilters[] = { {UTASSERT_CASETYPE_DEBUG, CFE_EVS_NO_FILTER}, }; -void CFE_TR_StatusReport(uint8 MessageType, const char *Prefix, const char *OutputMessage) +void CFE_Assert_StatusReport(uint8 MessageType, const char *Prefix, const char *OutputMessage) { uint16 EventType; @@ -84,13 +83,13 @@ void CFE_TR_StatusReport(uint8 MessageType, const char *Prefix, const char *Outp case UTASSERT_CASETYPE_TTF: EventType = CFE_EVS_EventType_ERROR; break; + case UTASSERT_CASETYPE_BEGIN: + case UTASSERT_CASETYPE_END: case UTASSERT_CASETYPE_INFO: case UTASSERT_CASETYPE_MIR: - case UTASSERT_CASETYPE_NA: EventType = CFE_EVS_EventType_INFORMATION; break; - case UTASSERT_CASETYPE_BEGIN: - case UTASSERT_CASETYPE_END: + case UTASSERT_CASETYPE_NA: case UTASSERT_CASETYPE_PASS: case UTASSERT_CASETYPE_DEBUG: default: @@ -101,68 +100,123 @@ void CFE_TR_StatusReport(uint8 MessageType, const char *Prefix, const char *Outp CFE_EVS_SendEvent(MessageType, EventType, "[%5s] %s", Prefix, OutputMessage); } -/* - * Entry point for this application - */ -void CFE_TR_AppMain(void) +int32 CFE_Assert_RegisterTest(const char *TestName) { - int32 rc; - uint32 RunStatus; + int32 rc; + char SetupSegmentName[64]; rc = CFE_EVS_Register(CFE_TR_EventFilters, sizeof(CFE_TR_EventFilters) / sizeof(CFE_EVS_BinFilter_t), CFE_EVS_EventFilter_BINARY); if (rc != CFE_SUCCESS) { CFE_ES_WriteToSysLog("Error from CFE_EVS_Register: %08lx\n", (unsigned long)rc); - return; + return rc; } /* * Delay until the system reaches "operational" state -- this is when all libs have initialized * and all apps have reached their RunLoop. + * + * If already operational then this should return immediately. This may be the case if/when + * test apps are started via ES command. */ rc = CFE_ES_WaitForSystemState(CFE_ES_SystemState_OPERATIONAL, CFE_TESTRUNNER_MAX_STARTUP_WAIT); if (rc != CFE_SUCCESS) { CFE_ES_WriteToSysLog("Error while waiting for OPERATIONAL state: %08lx\n", (unsigned long)rc); - return; + return rc; } /* - * Startup Phase has ended. + * Acquire the mutex. This is needed because UtAssert and its data structures are not thread-safe. + * Only one test app should use UtAssert facilities at a given time. */ - UtAssert_EndTest(); + rc = OS_MutSemTake(CFE_Assert_Global.AccessMutex); + if (rc != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemTake(): %d\n", __func__, (int)rc); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } /* - * Use the local status report function for the remainder of tests + * After acquiring mutex, record the fact that this app now "owns" the assert functions */ - CFE_Assert_RegisterCallback(CFE_TR_StatusReport); + rc = CFE_ES_GetAppID(&CFE_Assert_Global.OwnerAppId); + if (rc != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("%s(): Error from CFE_ES_GetAppId(): %08x\n", __func__, (unsigned int)rc); + OS_MutSemGive(CFE_Assert_Global.AccessMutex); + return rc; + } /* - * Note - in a normal app this would be a while loop, - * but is just an "if" right now as it only runs once. - * - * A future enhancement to this app might be to create an SB pipe - * and execute tests based on the receipt of a command to do so. - * - * For now, it just works in a one-shot mode to run tests that were - * registered during startup, then it self-exits. + * This means the system is operational and at least one app needs to run tests. + * Update library state accordingly. The first test app that gets to this point + * will handle this. */ - RunStatus = CFE_ES_RunStatus_APP_RUN; - if (CFE_ES_RunLoop(&RunStatus)) + if (CFE_Assert_Global.LibState != CFE_Assert_State_ACTIVE) { + UtAssert_EndTest(); + CFE_Assert_Global.LibState = CFE_Assert_State_ACTIVE; + OS_TaskDelay(CFE_TESTRUNNER_START_DELAY); + } - /* - * Run all registered test cases. - */ - UtTest_Run(); + /* + * This resets the underlying UtAssert test list to a clean slate + * + * NOTE: this is not the ideal API here; UtAssert was originally designed to + * run one set of tests and then exit. In this environment it might be used + * repeatedly by different apps. The "EarlyInit" will wipe and reset the + * internal global, which works, but is heavy handed and doesn't account for + * the possibility that tests have been added without running. + */ + UtTest_EarlyInit(); + + strncpy(CFE_Assert_Global.CurrentTestName, TestName, sizeof(CFE_Assert_Global.CurrentTestName) - 1); + CFE_Assert_Global.CurrentTestName[sizeof(CFE_Assert_Global.CurrentTestName) - 1] = 0; + + /* Use the local status report function for the remainder of tests */ + CFE_Assert_RegisterCallback(CFE_Assert_StatusReport); + + /* Start a test group in case UtAssert is used during setup phase */ + snprintf(SetupSegmentName, sizeof(SetupSegmentName), "%s TEST SETUP", TestName); + UtAssert_BeginTest(SetupSegmentName); - /* - * Exit the main task. - */ - RunStatus = CFE_ES_RunStatus_APP_EXIT; + return CFE_SUCCESS; +} + +void CFE_Assert_ExecuteTest(void) +{ + int32 rc; + CFE_ES_AppId_t AppId; + + /* + * Sanity check - This should only be called from the same app after CFE_Assert_RegisterTest() + */ + rc = CFE_ES_GetAppID(&AppId); + if (rc != CFE_SUCCESS || !CFE_RESOURCEID_TEST_EQUAL(AppId, CFE_Assert_Global.OwnerAppId)) + { + CFE_ES_WriteToSysLog("%s(): Invalid calling context, CFE_ES_GetAppId() rc=%08x AppId=%lx, OwnerAppId=%lx\n", + __func__, (unsigned int)rc, CFE_RESOURCEID_TO_ULONG(AppId), + CFE_RESOURCEID_TO_ULONG(CFE_Assert_Global.OwnerAppId)); + return; } - CFE_ES_ExitApp(RunStatus); + UtAssert_EndTest(); + + OS_TaskDelay(CFE_TESTRUNNER_START_DELAY); + + /* Run all registered test cases. */ + UtTest_Run(); + + /* unregister the callback and unset the appid */ + CFE_Assert_RegisterCallback(NULL); + + /* Release the access mutex so the next test program can run */ + rc = OS_MutSemGive(CFE_Assert_Global.AccessMutex); + if (rc != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemGive(): %d\n", __func__, (int)rc); + } } diff --git a/modules/cfe_testcase/CMakeLists.txt b/modules/cfe_testcase/CMakeLists.txt index 4bf6c0058..64f4180cf 100644 --- a/modules/cfe_testcase/CMakeLists.txt +++ b/modules/cfe_testcase/CMakeLists.txt @@ -1,9 +1,9 @@ -include_directories("${CFE_ASSERT_SOURCE_DIR}/inc") -include_directories("${UT_ASSERT_SOURCE_DIR}/inc") - -# Filenames based on doxygen groups. +# Filenames based on doxygen groups. # Create the app module add_cfe_app(cfe_testcase src/cfe_test.c src/es_info_test.c ) + +# register the dependency on cfe_assert +add_cfe_app_dependency(cfe_testcase cfe_assert) diff --git a/modules/cfe_testcase/src/cfe_test.c b/modules/cfe_testcase/src/cfe_test.c index 2b25755a6..f4015320c 100644 --- a/modules/cfe_testcase/src/cfe_test.c +++ b/modules/cfe_testcase/src/cfe_test.c @@ -30,14 +30,35 @@ * Includes */ +#include "cfe_assert.h" #include "cfe_test.h" /* - * Initialization function + * Test main function * Register this test routine with CFE Assert */ -int32 CFE_Test_Init(int32 LibId) +void CFE_TestMain(void) { - ESInfoTestSetup(LibId); - return CFE_SUCCESS; + /* + * Register this test app with CFE assert + * + * Note this also waits for the appropriate overall system + * state and gets ownership of the UtAssert subsystem + */ + CFE_Assert_RegisterTest("CFE API"); + + /* + * Register test cases in UtAssert + */ + ESInfoTestSetup(); + + /* + * Execute the tests + * + * Note this also releases ownership of the UtAssert subsystem when complete + */ + CFE_Assert_ExecuteTest(); + + /* Nothing more for this app to do */ + CFE_ES_ExitApp(CFE_ES_RunStatus_APP_EXIT); } diff --git a/modules/cfe_testcase/src/cfe_test.h b/modules/cfe_testcase/src/cfe_test.h index dced3d00c..87223e978 100644 --- a/modules/cfe_testcase/src/cfe_test.h +++ b/modules/cfe_testcase/src/cfe_test.h @@ -52,7 +52,7 @@ #define UtAssert_ResourceID_Undifeined(id) \ UtAssert_True(!CFE_RESOURCEID_TEST_DEFINED(id), "%s (%lu) not defined", #id, CFE_RESOURCEID_TO_ULONG(id)) -int32 CFE_Test_Init(int32 LibId); -int32 ESInfoTestSetup(int32 LibId); +void CFE_TestMain(void); +void ESInfoTestSetup(void); #endif /* CFE_TEST_H */ diff --git a/modules/cfe_testcase/src/es_info_test.c b/modules/cfe_testcase/src/es_info_test.c index f389394e4..f107b611c 100644 --- a/modules/cfe_testcase/src/es_info_test.c +++ b/modules/cfe_testcase/src/es_info_test.c @@ -33,41 +33,45 @@ #include "cfe_test.h" +const char TEST_EXPECTED_ENTRYPOINT[] = "CFE_TestMain"; +const char TEST_EXPECTED_APP_NAME[] = "CFE_TEST_APP"; +const char TEST_EXPECTED_FILE_NAME[] = "cfe_testcase"; +const char ES_APP_EXPECTED_NAME[] = "CFE_ES"; +const char INVALID_APP_NAME[] = "INVALID_NAME"; + void TestAppInfo(void) { CFE_ES_AppId_t TestAppId; CFE_ES_AppId_t ESAppId; CFE_ES_AppId_t AppIdByName; - const char * TestAppName = "TESTRUN_APP"; - const char * ESAppName = "CFE_ES"; - const char * InvalidName = "INVALID_NAME"; char AppNameBuf[OS_MAX_API_NAME + 4]; CFE_ES_AppInfo_t TestAppInfo; CFE_ES_AppInfo_t ESAppInfo; UtPrintf("Testing: CFE_ES_GetAppID, CFE_ES_GetAppIDByName, CFE_ES_GetAppName, CFE_ES_GetAppInfo"); - UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(&AppIdByName, TestAppName), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(&AppIdByName, TEST_EXPECTED_APP_NAME), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_GetAppID(&TestAppId), CFE_SUCCESS); UtAssert_ResourceID_EQ(TestAppId, AppIdByName); UtAssert_INT32_EQ(CFE_ES_GetAppName(AppNameBuf, TestAppId, sizeof(AppNameBuf)), CFE_SUCCESS); - UtAssert_StrCmp(AppNameBuf, TestAppName, "CFE_ES_GetAppName() = %s", AppNameBuf); + UtAssert_StrCmp(AppNameBuf, TEST_EXPECTED_APP_NAME, "CFE_ES_GetAppName() = %s", AppNameBuf); UtAssert_INT32_EQ(CFE_ES_GetAppInfo(&TestAppInfo, TestAppId), CFE_SUCCESS); - UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(&ESAppId, ESAppName), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(&ESAppId, ES_APP_EXPECTED_NAME), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_GetAppInfo(&ESAppInfo, ESAppId), CFE_SUCCESS); UtAssert_True(TestAppInfo.Type == CFE_ES_AppType_EXTERNAL, "Test App Info -> Type = %d", (int)TestAppInfo.Type); UtAssert_True(ESAppInfo.Type == CFE_ES_AppType_CORE, "ES App Info -> Type = %d", (int)ESAppInfo.Type); - UtAssert_StrCmp(TestAppInfo.Name, TestAppName, "Test App Info -> Name = %s", TestAppInfo.Name); - UtAssert_StrCmp(ESAppInfo.Name, ESAppName, "ES App Info -> Name = %s", ESAppInfo.Name); + UtAssert_StrCmp(TestAppInfo.Name, TEST_EXPECTED_APP_NAME, "Test App Info -> Name = %s", TestAppInfo.Name); + UtAssert_StrCmp(ESAppInfo.Name, ES_APP_EXPECTED_NAME, "ES App Info -> Name = %s", ESAppInfo.Name); - UtAssert_StrCmp(TestAppInfo.EntryPoint, "CFE_TR_AppMain", "Test App Info -> EntryPt = %s", TestAppInfo.EntryPoint); + UtAssert_StrCmp(TestAppInfo.EntryPoint, TEST_EXPECTED_ENTRYPOINT, "Test App Info -> EntryPt = %s", + TestAppInfo.EntryPoint); UtAssert_True(strlen(ESAppInfo.EntryPoint) == 0, "ES App Info -> EntryPt = %s", ESAppInfo.EntryPoint); - UtAssert_StrCmp(TestAppInfo.FileName, "/cf/cfe_testrunner.so", "Test App Info -> FileName = %s", - TestAppInfo.FileName); + UtAssert_True(strstr(TestAppInfo.FileName, TEST_EXPECTED_FILE_NAME) != NULL, "Test App Info -> FileName = %s", + TestAppInfo.FileName); UtAssert_True(strlen(ESAppInfo.FileName) == 0, "ES App Info -> FileName = %s", ESAppInfo.FileName); UtAssert_True(TestAppInfo.StackSize > 0, "Test App Info -> StackSz = %d", (int)TestAppInfo.StackSize); @@ -117,10 +121,10 @@ void TestAppInfo(void) (int)TestAppInfo.NumOfChildTasks); UtAssert_True(ESAppInfo.NumOfChildTasks > 0, "ES App Info -> Child Tasks = %d", (int)ESAppInfo.NumOfChildTasks); - UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(&AppIdByName, InvalidName), CFE_ES_ERR_NAME_NOT_FOUND); + UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(&AppIdByName, INVALID_APP_NAME), CFE_ES_ERR_NAME_NOT_FOUND); UtAssert_ResourceID_Undifeined(AppIdByName); UtAssert_INT32_EQ(CFE_ES_GetAppID(NULL), CFE_ES_BAD_ARGUMENT); - UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(NULL, TestAppName), CFE_ES_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(NULL, TEST_EXPECTED_APP_NAME), CFE_ES_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_ES_GetAppName(AppNameBuf, CFE_ES_APPID_UNDEFINED, sizeof(AppNameBuf)), CFE_ES_ERR_RESOURCEID_NOT_VALID); UtAssert_INT32_EQ(CFE_ES_GetAppName(NULL, TestAppId, sizeof(AppNameBuf)), CFE_ES_BAD_ARGUMENT); @@ -257,13 +261,11 @@ void TestModuleInfo(void) UtAssert_INT32_EQ(CFE_ES_GetModuleInfo(NULL, CFE_RESOURCEID_UNWRAP(TestAppId)), CFE_ES_BAD_ARGUMENT); } -int32 ESInfoTestSetup(int32 LibId) +void ESInfoTestSetup(void) { UtTest_Add(TestAppInfo, NULL, NULL, "Test App Info"); UtTest_Add(TestTaskInfo, NULL, NULL, "Test Task Info"); UtTest_Add(TestLibInfo, NULL, NULL, "Test Lib Info"); UtTest_Add(TestResetType, NULL, NULL, "Test Reset Type"); UtTest_Add(TestModuleInfo, NULL, NULL, "Test Module Info"); - - return CFE_SUCCESS; } diff --git a/modules/cfe_testrunner/CMakeLists.txt b/modules/cfe_testrunner/CMakeLists.txt deleted file mode 100644 index b4df50bc6..000000000 --- a/modules/cfe_testrunner/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -project(CFE_TESTRUNNER C) - -# Create the app module -add_cfe_app(cfe_testrunner - src/cfe_testrunner_main.c -) - -target_include_directories(cfe_testrunner PUBLIC - ${CFE_TESTRUNNER_SOURCE_DIR}/inc -) - -# register the dependency on cfe_assert -add_cfe_app_dependency(cfe_testrunner cfe_assert) diff --git a/modules/cfe_testrunner/inc/cfe_testrunner.h b/modules/cfe_testrunner/inc/cfe_testrunner.h deleted file mode 100644 index d4ae6cb96..000000000 --- a/modules/cfe_testrunner/inc/cfe_testrunner.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************* -** -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-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: cfe_testrunner.h -** -** Purpose: -** Specification for the CFE testrunner (UT testrunner wrapper) functions. -** -*************************************************************************/ - -/** - * @file - * - * Declarations and prototypes for cfe_testrunner module - */ - -#ifndef CFE_TESTRUNNER_H -#define CFE_TESTRUNNER_H - -/************************************************************************ -** Includes -*************************************************************************/ -#include "common_types.h" - -/************************************************************************ -** Type Definitions -*************************************************************************/ - -/************************************************************************* -** Exported Functions -*************************************************************************/ - -/************************************************************************/ -/** \brief Application Entry Point Function -** -** \par Description -** This function should be specified in the cfe_es_startup.scr file -** as part of starting this application. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \return Execution status, see \ref CFEReturnCodes -** -*************************************************************************/ -void CFE_TR_AppMain(void); - -#endif /* CFE_TESTRUNNER_H */