From 6d1ef7079d9eeaf91089febeebef697952a97280 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 18 Aug 2023 09:42:40 -0400 Subject: [PATCH] Fix #1404, skip condvar tests if not implemented This reports that the functionality is not implemented and reports it as an MIR result, instead of having most/all of the tests fail. --- src/tests/condvar-test/condvar-test.c | 33 ++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/tests/condvar-test/condvar-test.c b/src/tests/condvar-test/condvar-test.c index 59d2ede78..c5a583498 100644 --- a/src/tests/condvar-test/condvar-test.c +++ b/src/tests/condvar-test/condvar-test.c @@ -366,6 +366,20 @@ void CondVarTest_Ops(void) } } +bool CondVarTest_CheckImpl(void) +{ + int32_t status; + osal_id_t cvid; + + status = OS_CondVarCreate(&cvid, "ut", 0); + if (status == OS_SUCCESS) + { + OS_CondVarDelete(cvid); + } + + return (status != OS_ERR_NOT_IMPLEMENTED); +} + void UtTest_Setup(void) { if (OS_API_Init() != OS_SUCCESS) @@ -376,10 +390,17 @@ void UtTest_Setup(void) /* the test should call OS_API_Teardown() before exiting */ UtTest_AddTeardown(OS_API_Teardown, "Cleanup"); - /* - * Register the test setup and check routines in UT assert - */ - UtTest_Add(CondVarTest_Ops, NULL, NULL, "CondVarOps"); - UtTest_Add(CondVarTest_Execute, CondVarTest_Setup, CondVarTest_Teardown, "CondVarBasic"); - UtTest_Add(CondVarTimedWait_Execute, CondVarTimedWait_Setup, CondVarTimedWait_Teardown, "CondVarTimed"); + if (CondVarTest_CheckImpl()) + { + /* + * Register the test setup and check routines in UT assert + */ + UtTest_Add(CondVarTest_Ops, NULL, NULL, "CondVarOps"); + UtTest_Add(CondVarTest_Execute, CondVarTest_Setup, CondVarTest_Teardown, "CondVarBasic"); + UtTest_Add(CondVarTimedWait_Execute, CondVarTimedWait_Setup, CondVarTimedWait_Teardown, "CondVarTimed"); + } + else + { + UtAssert_MIR("Condition variables not implemented; skipping tests"); + } }