diff options
Diffstat (limited to 'tests')
4 files changed, 91 insertions, 5 deletions
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/RunCRuntimeTestcases.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/RunCRuntimeTestcases.c index 40be33446..31594f3ff 100644 --- a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/RunCRuntimeTestcases.c +++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/RunCRuntimeTestcases.c @@ -29,6 +29,7 @@ #include "TestEtQueue.h" #include "TestEtTimer.h" #include "TestEtDatatypes.h" +#include "TestEtConsoleLogger.h" #include "helpers/TestEtTimeHelpers.h" #include "util/TestUtil.h" @@ -53,6 +54,7 @@ void RunCRuntimeTestcases(void){ TestEtDatatypes_runSuite(); TestEtTimeHelpers_runSuite(); TestUtil_runSuite(); + TestEtConsoleLogger_runSuite(); TestEtStaticDeque_runSuite(); diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtConsoleLogger.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtConsoleLogger.c new file mode 100644 index 000000000..5cf0f9c04 --- /dev/null +++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtConsoleLogger.c @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2019 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Henrik Rentz-Reichert (initial contribution) + * + *******************************************************************************/ + + +/* + * TestEtConsoleLogger.c + */ + +#include "TestEtConsoleLogger.h" +#include "debugging/etConsoleLogger.h" +#include "etUnit/etUnit.h" + +static void TestEtUnit_useConsoleLogging(etInt16 id) { + etConsoleLogger_init(); + + /* will be dropped because of log level ERROR by default */ + etLogger_log(&theConsoleLogger, LOG_WARNING, "first message for testing (WARNING)"); + + theConsoleLogger.logLevel = LOG_WARNING; + etLogger_log(&theConsoleLogger, LOG_WARNING, "first message for testing (WARNING)"); + etLogger_logF(&theConsoleLogger, LOG_ERROR, "%d. message for testing (ERROR)", 2); +} + +static void TestEtUnit_useConsoleLoggingWithTimestamp(etInt16 id) { + etConsoleLogger_init(); + + etLogger_setUseTimestamp(&theConsoleLogger, ET_TRUE); + + etLogger_logF(&theConsoleLogger, LOG_ERROR, "%d. message for testing (ERROR with timestamp)", 3); +} + +void TestEtConsoleLogger_runSuite(void){ + etUnit_openTestSuite("org.eclipse.etrice.runtime.c.tests.TestEtConsoleLogger"); + ADD_TESTCASE(TestEtUnit_useConsoleLogging); + ADD_TESTCASE(TestEtUnit_useConsoleLoggingWithTimestamp); + etUnit_closeTestSuite(); +} + + diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtConsoleLogger.h b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtConsoleLogger.h new file mode 100644 index 000000000..641450f72 --- /dev/null +++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtConsoleLogger.h @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2019 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Henrik Rentz-Reichert (initial contribution) + * + *******************************************************************************/ + + +/* + * TestEtConsoleLogger.h + */ + +#ifndef _TESTETCONSOLELOGGER_H_ +#define _TESTETCONSOLELOGGER_H_ + +void TestEtConsoleLogger_runSuite(void); + +#endif /* _TESTETCONSOLELOGGER_H_ */ diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.c index ee60fbc8a..2dfecd216 100644 --- a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.c +++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.c @@ -18,6 +18,7 @@ #include "base/etMemory_VariableSize.h" #include "base/etMemory_FixedSize.h" #include "base/etMemory_FreeList.h" +#include "runtime/etRuntime.h" #define KBYTE 1024 #define BUF_SIZE (256*KBYTE) @@ -213,7 +214,7 @@ static void TestEtMemory_testFreeListOverflow(etInt16 id) { } static void TestEtMemory_testStatistics(etInt16 id) { - etMemoryStatistics* stat; + const etMemoryStatistics* stat; int n; EXPECT_EQUAL_INT32(id, "tests created some memory managements", 4, etRuntime_getMemoryManagementCount()); @@ -231,7 +232,11 @@ static void TestEtMemory_testStatistics(etInt16 id) { EXPECT_TRUE(id, "stat!=NULL", stat!=NULL); printf("checking memory management %d, %s, max %d, fail %d\n", n, etRuntime_getMemoryManagementName(n), stat->maxUsed, stat->nFailingRequests); fflush(stdout); - EXPECT_EQUAL_INT32(id, "maxUsed", 261784, stat->maxUsed); + /* + * the computation is too architecture dependent, we have a detailed check in TestEtMemory_testFreeList + * + * EXPECT_EQUAL_INT32(id, "maxUsed", 261784, stat->maxUsed); + */ EXPECT_EQUAL_INT32(id, "nFailingRequests", 0, stat->nFailingRequests); n = 2; @@ -239,7 +244,11 @@ static void TestEtMemory_testStatistics(etInt16 id) { EXPECT_TRUE(id, "stat!=NULL", stat!=NULL); printf("checking memory management %d, %s, max %d, fail %d\n", n, etRuntime_getMemoryManagementName(n), stat->maxUsed, stat->nFailingRequests); fflush(stdout); - EXPECT_EQUAL_INT32(id, "maxUsed", 131144, stat->maxUsed); + /* + * the computation is too architecture dependent, we have a detailed check in TestEtMemory_testFixedSize + * + * EXPECT_EQUAL_INT32(id, "maxUsed", 131144, stat->maxUsed); + */ EXPECT_EQUAL_INT32(id, "nFailingRequests", 0, stat->nFailingRequests); n = 3; @@ -247,7 +256,11 @@ static void TestEtMemory_testStatistics(etInt16 id) { EXPECT_TRUE(id, "stat!=NULL", stat!=NULL); printf("checking memory management %d, %s, max %d, fail %d\n", n, etRuntime_getMemoryManagementName(n), stat->maxUsed, stat->nFailingRequests); fflush(stdout); - EXPECT_EQUAL_INT32(id, "maxUsed", 260016, stat->maxUsed); + /* + * the computation is too architecture dependent, we have a detailed check in TestEtMemory_testVariableSize + * + * EXPECT_EQUAL_INT32(id, "maxUsed", 260016, stat->maxUsed); + */ EXPECT_EQUAL_INT32(id, "nFailingRequests", 1, stat->nFailingRequests); } @@ -257,7 +270,7 @@ void TestEtMemory_runSuite(void){ ADD_TESTCASE(TestEtMemory_testFixedSize); ADD_TESTCASE(TestEtMemory_testFreeList); ADD_TESTCASE(TestEtMemory_testFreeListOverflow); - /*ADD_TESTCASE(TestEtMemory_testStatistics);*/ + ADD_TESTCASE(TestEtMemory_testStatistics); etUnit_closeTestSuite(); } |