diff options
author | Thomas Schuetz | 2012-02-26 14:58:40 +0000 |
---|---|---|
committer | Thomas Schuetz | 2012-02-26 14:58:40 +0000 |
commit | afc4b117aab39c0f6f726c4efdaa83f441faf61c (patch) | |
tree | daaef66ac1629df2d828aff1559434fe67f55d13 /runtime/org.eclipse.etrice.runtime.c | |
parent | 724f46d55b352c16731b46a332b13d436b536aae (diff) | |
download | org.eclipse.etrice-afc4b117aab39c0f6f726c4efdaa83f441faf61c.tar.gz org.eclipse.etrice-afc4b117aab39c0f6f726c4efdaa83f441faf61c.tar.xz org.eclipse.etrice-afc4b117aab39c0f6f726c4efdaa83f441faf61c.zip |
[runtime.c] reorganized runtime.c for separation of common and platform specific parts, adapted include pathes, C-generator and tests
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c')
23 files changed, 1326 insertions, 1228 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/.cproject b/runtime/org.eclipse.etrice.runtime.c/.cproject index 40cfcf676..3df281dc8 100644 --- a/runtime/org.eclipse.etrice.runtime.c/.cproject +++ b/runtime/org.eclipse.etrice.runtime.c/.cproject @@ -5,7 +5,13 @@ <storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.lib.debug.505530637">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.lib.debug.505530637" moduleId="org.eclipse.cdt.core.settings" name="Debug">
- <externalSettings/>
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/org.eclipse.etrice.runtime.c"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/org.eclipse.etrice.runtime.c/Debug"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="org.eclipse.etrice.runtime.c"/>
+ </externalSetting>
+ </externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
@@ -34,7 +40,10 @@ <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug.1185604346" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.lib.debug.option.optimization.level.157947957" name="Optimization Level" superClass="gnu.c.compiler.mingw.lib.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.lib.debug.option.debugging.level.1083191317" name="Debug Level" superClass="gnu.c.compiler.mingw.lib.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
- <option id="gnu.c.compiler.option.include.paths.790097072" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths"/>
+ <option id="gnu.c.compiler.option.include.paths.790097072" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/platforms/generic}""/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/common}""/>
+ </option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.361048721" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.597146923" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"/>
@@ -42,8 +51,8 @@ </toolChain>
</folderInfo>
<sourceEntries>
+ <entry excluding="platforms/MSP430" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="test|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
@@ -88,7 +97,7 @@ </toolChain>
</folderInfo>
<sourceEntries>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+ <entry excluding="platforms/MSP430" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="test|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
diff --git a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a Binary files differindex 3885aae84..7ac25a93e 100644 --- a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a +++ b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etLogger.h b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etLogger.h index 6c46889a8..b353e6f1a 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etLogger.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etLogger.h @@ -1,48 +1,48 @@ -/*******************************************************************************
- * Copyright (c) 2011 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-/*
- * etLogger.h
- *
- * Created on: 16.01.2012
- * Author: tschuetz
- */
-
-#ifndef _ETLOGGER_H_
-#define _ETLOGGER_H_
-
-#include <stdio.h>
-#include "etDatatypes.h"
-/* logging */
-
-void etLogger_logError(const char* message);
-
-void etLogger_logWarning(const char* message);
-
-void etLogger_logInfo(const char* message);
-
-void etLogger_logErrorF(const char* format, ... );
-
-void etLogger_logWarningF(const char* format, ... );
-
-void etLogger_logInfoF(const char* format, ... );
-
-
-/* File handling */
-
-etFileHandle etLogger_fopen(const char* filename, const char* mode);
-
-int etLogger_fclose(etFileHandle file);
-
-void etLogger_fprintf(etFileHandle file, const char* format, ... );
-
-#endif /* _ETLOGGER_H_ */
+/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +/* + * etLogger.h + * + * Created on: 16.01.2012 + * Author: tschuetz + */ + +#ifndef _ETLOGGER_H_ +#define _ETLOGGER_H_ + +#include <stdio.h> +#include "etDatatypes.h" +/* logging */ + +void etLogger_logError(const char* message); + +void etLogger_logWarning(const char* message); + +void etLogger_logInfo(const char* message); + +void etLogger_logErrorF(const char* format, ... ); + +void etLogger_logWarningF(const char* format, ... ); + +void etLogger_logInfoF(const char* format, ... ); + + +/* File handling */ + +etFileHandle etLogger_fopen(const char* filename, const char* mode); + +int etLogger_fclose(etFileHandle file); + +void etLogger_fprintf(etFileHandle file, const char* format, ... ); + +#endif /* _ETLOGGER_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMSCLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c index 9abc9be9d..fee947eab 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etMSCLogger.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c @@ -1,57 +1,57 @@ -/*******************************************************************************
- * Copyright (c) 2012 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#include "etMSCLogger.h"
-
-#include "etLogger.h"
-
-static etFileHandle etMSCLogger_fileHandle = NULL;
-static char* etMSCLogger_objectName = "";
-
-#define ET_MAX_FILENAME_LEN 256
-
-void etMSCLogger_open(char* logPath, char* mscName){
- char path[ET_MAX_FILENAME_LEN];
- sprintf(path, "%s/%s.seq", logPath, mscName);
- etMSCLogger_fileHandle = etLogger_fopen(path, "w+");
-}
-
-void etMSCLogger_close(void){
- if (etMSCLogger_fileHandle != NULL){
- etLogger_fclose(etMSCLogger_fileHandle);
- }
-
-}
-
-void etMSCLogger_setObjectName(char* objectName){
- etMSCLogger_objectName = objectName;
-}
-
-char* etMSCLogger_getObjectName(void){
- return etMSCLogger_objectName;
-}
-
-void etMSCLogger_syncCall(char* sourceName, char* messageName, char* targetName){
- etLogger_fprintf(etMSCLogger_fileHandle, "%s ==> %s %s\n", sourceName, targetName, messageName);
-}
-
-void etMSCLogger_syncReturn(char* sourceName, char* targetName){
- etLogger_fprintf(etMSCLogger_fileHandle, "%s <== %s\n", sourceName, targetName);
-}
-
-void etMSCLogger_asyncOut(char* sourceName, char* messageName, char* targetName){
- etLogger_fprintf(etMSCLogger_fileHandle, "%s >-- %s %s\n", sourceName, targetName, messageName);
-}
-
-void etMSCLogger_asyncIn(char* sourceName, char* messageName, char* targetName){
- etLogger_fprintf(etMSCLogger_fileHandle, "%s --> %s %s\n", sourceName, targetName, messageName);
-}
+/******************************************************************************* + * Copyright (c) 2012 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#include "debugging/etMSCLogger.h" + +#include "debugging/etLogger.h" + +static etFileHandle etMSCLogger_fileHandle = NULL; +static char* etMSCLogger_objectName = ""; + +#define ET_MAX_FILENAME_LEN 256 + +void etMSCLogger_open(char* logPath, char* mscName){ + char path[ET_MAX_FILENAME_LEN]; + sprintf(path, "%s/%s.seq", logPath, mscName); + etMSCLogger_fileHandle = etLogger_fopen(path, "w+"); +} + +void etMSCLogger_close(void){ + if (etMSCLogger_fileHandle != NULL){ + etLogger_fclose(etMSCLogger_fileHandle); + } + +} + +void etMSCLogger_setObjectName(char* objectName){ + etMSCLogger_objectName = objectName; +} + +char* etMSCLogger_getObjectName(void){ + return etMSCLogger_objectName; +} + +void etMSCLogger_syncCall(char* sourceName, char* messageName, char* targetName){ + etLogger_fprintf(etMSCLogger_fileHandle, "%s ==> %s %s\n", sourceName, targetName, messageName); +} + +void etMSCLogger_syncReturn(char* sourceName, char* targetName){ + etLogger_fprintf(etMSCLogger_fileHandle, "%s <== %s\n", sourceName, targetName); +} + +void etMSCLogger_asyncOut(char* sourceName, char* messageName, char* targetName){ + etLogger_fprintf(etMSCLogger_fileHandle, "%s >-- %s %s\n", sourceName, targetName, messageName); +} + +void etMSCLogger_asyncIn(char* sourceName, char* messageName, char* targetName){ + etLogger_fprintf(etMSCLogger_fileHandle, "%s --> %s %s\n", sourceName, targetName, messageName); +} diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMSCLogger.h b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.h index af78894bd..1d3ec868f 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etMSCLogger.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.h @@ -1,56 +1,56 @@ -/*******************************************************************************
- * Copyright (c) 2012 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef _ETMSCLOGGER_H_
-#define _ETMSCLOGGER_H_
-
-#define ET_MSC_LOGGER_ACTIVATE
-
-void etMSCLogger_open(char* logPath, char* mscName);
-void etMSCLogger_close(void);
-
-void etMSCLogger_setObjectName(char* objectName);
-char* etMSCLogger_getObjectName(void);
-
-void etMSCLogger_syncCall(char* sourceName, char* messageName, char* targetName);
-void etMSCLogger_syncReturn(char* sourceName, char* targetName);
-
-void etMSCLogger_asyncOut(char* sourceName, char* messageName, char* targetName);
-void etMSCLogger_asyncIn(char* sourceName, char* messageName, char* targetName);
-
-#ifdef ET_MSC_LOGGER_ACTIVATE
- #define ET_MSC_LOGGER_OPEN(object) \
- etMSCLogger_open("tmp", "msc"); \
- etMSCLogger_setObjectName(object);
-
- #define ET_MSC_LOGGER_CLOSE etMSCLogger_close();
-
- #define ET_MSC_LOGGER_SYNC_ENTRY(object, message) \
- char* sourceName = etMSCLogger_getObjectName(); \
- char* targetName = object; \
- etMSCLogger_syncCall(sourceName, message, targetName); \
- etMSCLogger_setObjectName(targetName);
-
- #define ET_MSC_LOGGER_SYNC_EXIT \
- etMSCLogger_syncReturn(sourceName, targetName); \
- etMSCLogger_setObjectName(sourceName);
-
-#else
- #define ET_MSC_LOGGER_OPEN
- #define ET_MSC_LOGGER_CLOSE
-
- #define ET_MSC_LOGGER_SYNC_ENTRY(object, message)
- #define ET_MSC_LOGGER_SYNC_EXIT
-#endif
-
-
-#endif /* _ETMSCLOGGER_H_ */
+/******************************************************************************* + * Copyright (c) 2012 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#ifndef _ETMSCLOGGER_H_ +#define _ETMSCLOGGER_H_ + +#include "etGlobalFlags.h" + +void etMSCLogger_open(char* logPath, char* mscName); +void etMSCLogger_close(void); + +void etMSCLogger_setObjectName(char* objectName); +char* etMSCLogger_getObjectName(void); + +void etMSCLogger_syncCall(char* sourceName, char* messageName, char* targetName); +void etMSCLogger_syncReturn(char* sourceName, char* targetName); + +void etMSCLogger_asyncOut(char* sourceName, char* messageName, char* targetName); +void etMSCLogger_asyncIn(char* sourceName, char* messageName, char* targetName); + +#ifdef ET_MSC_LOGGER_ACTIVATE + #define ET_MSC_LOGGER_OPEN(object) \ + etMSCLogger_open("tmp", "msc"); \ + etMSCLogger_setObjectName(object); + + #define ET_MSC_LOGGER_CLOSE etMSCLogger_close(); + + #define ET_MSC_LOGGER_SYNC_ENTRY(object, message) \ + char* sourceName = etMSCLogger_getObjectName(); \ + char* targetName = object; \ + etMSCLogger_syncCall(sourceName, message, targetName); \ + etMSCLogger_setObjectName(targetName); + + #define ET_MSC_LOGGER_SYNC_EXIT \ + etMSCLogger_syncReturn(sourceName, targetName); \ + etMSCLogger_setObjectName(sourceName); + +#else + #define ET_MSC_LOGGER_OPEN + #define ET_MSC_LOGGER_CLOSE + + #define ET_MSC_LOGGER_SYNC_ENTRY(object, message) + #define ET_MSC_LOGGER_SYNC_EXIT +#endif + + +#endif /* _ETMSCLOGGER_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etUnit.c b/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.c index f9a963664..e1880b761 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etUnit.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.c @@ -1,338 +1,334 @@ -/*******************************************************************************
- * Copyright (c) 2011 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#include "etUnit.h"
-#include <string.h>
-#include <time.h>
-#include "etLogger.h"
-
-
-/*** member variables */
-
-/* file handling */
-static FILE* etUnit_reportfile = NULL;
-
-/* names */
-static char* etUnit_TestFileName = NULL;
-static char* etUnit_TestResultPath = NULL;
-
-static char* etUnit_TestSuiteName = NULL;
-static char* etUnit_TestCaseName = NULL;
-
-/* counters */
-static etInt32 etUnit_passCount = 0;
-static etInt32 etUnit_failCount = 0;
-static etInt32 etUnit_passCountTotal = 0;
-static etInt32 etUnit_failCountTotal = 0;
-
-static etBool etUnit_testcaseSuccess = TRUE;
-
-#define ETUNIT_FAILURE_TEXT_LEN 256
-
-static char etUnit_failureText[ETUNIT_FAILURE_TEXT_LEN];
-
-/* time measuring */
-static clock_t etUnit_startTime = 0;
-static clock_t etUnit_currentTime = 0;
-
-/* forward declarations of private functions */
-void expect_equal_int(const char* message, etInt32 expected, etInt32 actual);
-void expect_equal_uint(const char* message, etUInt32 expected, etUInt32 actual);
-void expect_equal_float(const char* message, etFloat64 expected, etFloat64 actual, etFloat64 precision);
-void etUnit_writeTestLog(const char *testcase, etBool result, const char *resulttext);
-void etUnit_handleExpect(etBool result, const char *resulttext);
-
-/* public functions */
-
-void etUnit_open(char* testResultPath, char* testFileName) {
- etUnit_passCount = 0;
- etUnit_failCount = 0;
- strcpy(etUnit_failureText,"");
-
- etUnit_TestFileName = testFileName;
- etUnit_TestResultPath = testResultPath;
-
- etLogger_logInfoF("************* TEST START (%s) **************", etUnit_TestFileName);
-
- char filename[ETUNIT_FAILURE_TEXT_LEN];
- sprintf(filename, "%s/%s.xml", etUnit_TestResultPath, etUnit_TestFileName);
-
- if (etUnit_reportfile == NULL) {
- etUnit_reportfile = etLogger_fopen(filename, "w+");
- if (etUnit_reportfile != NULL) {
- etLogger_fprintf(etUnit_reportfile, "<testsuites name=\"%s\" tests=\"0\" failures=\"0\" errors=\"0\" time=\"0\">\n", etUnit_TestFileName);
- } else {
- etLogger_logErrorF("Unable to open file %s/%s.xml", etUnit_TestResultPath, etUnit_TestFileName);
- }
- }
- /* prepare time measurement */
- etUnit_startTime = clock();
- etUnit_currentTime = clock();
- etLogger_logInfoF("Start Time: %ld", etUnit_startTime);
-
-}
-
-void etUnit_close(void) {
- etLogger_logInfoF("");
- if (etUnit_failCount > 0) {
- etLogger_logInfoF("************* TEST FAILED *************");
- } else {
- etLogger_logInfoF("************* TEST PASSED *************");
- }
- etLogger_logInfoF("Number of Tests: %ld", etUnit_failCount + etUnit_passCount);
- etLogger_logInfoF("Failed: %ld", etUnit_failCount);
- etLogger_logInfoF("Passed: %ld", etUnit_passCount);
- etLogger_logInfoF("Time: %ld", clock() - etUnit_startTime);
- etLogger_logInfoF("End Time: %ld[ms]", (clock() / 1000) * CLOCKS_PER_SEC );
- etLogger_logInfoF("***************************************");
- if (etUnit_failCountTotal > 0) {
- etLogger_logInfoF(" ******* %d TEST(S) FAILED *****", etUnit_failCountTotal);
- } else {
- etLogger_logInfoF(" ******* ALL TESTS PASSED ******");
- }
- etLogger_logInfoF("***************************************");
-
- if (etUnit_reportfile != NULL) {
- etLogger_fprintf(etUnit_reportfile, "</testsuites>\n");
- etLogger_fclose(etUnit_reportfile);
- etUnit_reportfile = NULL;
- }
-}
-
-void etUnit_openTestSuite(char* testSuiteName) {
- etUnit_TestSuiteName = testSuiteName;
- if (etUnit_reportfile != NULL) {
- etLogger_fprintf(etUnit_reportfile, "\t<testsuite name=\"%s\" tests=\"0\" failures=\"0\" errors=\"0\" time=\"0\">\n",
- etUnit_TestSuiteName);
- }
-}
-
-void etUnit_closeTestSuite(void) {
- if (etUnit_reportfile != NULL) {
- etLogger_fprintf(etUnit_reportfile, "\t</testsuite>\n");
- }
-}
-
-void etUnit_openTestCase(char* testCaseName) {
- etUnit_TestCaseName = testCaseName;
- etUnit_testcaseSuccess = TRUE;
- strcpy(etUnit_failureText,"");
-}
-
-void etUnit_closeTestCase(void) {
- if (etUnit_reportfile != NULL && etUnit_TestSuiteName != NULL) {
- etUnit_writeTestLog(etUnit_TestCaseName, etUnit_testcaseSuccess, etUnit_failureText);
- }
-}
-
-void etUnit_openAll(char* testResultPath, char* testFileName, char* testSuiteName, char* testCaseName){
- etUnit_open(testResultPath, testFileName);
- etUnit_openTestSuite(testSuiteName);
- etUnit_openTestCase(testCaseName);
-}
-
-void etUnit_closeAll(void){
- etUnit_closeTestCase();
- etUnit_closeTestSuite();
- etUnit_close();
-}
-
-void EXPECT_TRUE(const char* message, etBool condition) {
- if (condition == FALSE) {
- char testresult[ETUNIT_FAILURE_TEXT_LEN];
- sprintf(testresult, "%s: *** EXPECT_TRUE == FALSE", message);
- etUnit_handleExpect(FALSE, testresult);
- } else {
- etUnit_handleExpect(TRUE, "");
- }
-}
-
-void EXPECT_FALSE(const char* message, etBool condition) {
- if (condition == TRUE) {
- char testresult[ETUNIT_FAILURE_TEXT_LEN];
- sprintf(testresult, "%s: EXPECT_FALSE == TRUE", message);
- etUnit_handleExpect(FALSE, testresult);
- } else {
- etUnit_handleExpect(TRUE, "");
- }
-}
-
-void EXPECT_EQUAL_INT8(const char* message, etInt8 expected, etInt8 actual) {
- expect_equal_int(message, (etInt32) expected, (etInt32) actual);
-}
-
-void EXPECT_EQUAL_INT16(const char* message, etInt16 expected, etInt16 actual) {
- expect_equal_int(message, (etInt32) expected, (etInt32) actual);
-}
-
-void EXPECT_EQUAL_INT32(const char* message, etInt32 expected, etInt32 actual) {
- expect_equal_int(message, (etInt32) expected, (etInt32) actual);
-}
-
-void EXPECT_EQUAL_UINT8(const char* message, etUInt8 expected, etUInt8 actual) {
- expect_equal_uint(message, (etUInt32) expected, (etUInt32) actual);
-}
-
-void EXPECT_EQUAL_UINT16(const char* message, etUInt16 expected, etUInt16 actual) {
- expect_equal_uint(message, (etUInt32) expected, (etUInt32) actual);
-}
-
-void EXPECT_EQUAL_UINT32(const char* message, etUInt32 expected, etUInt32 actual) {
- expect_equal_uint(message, (etUInt32) expected, (etUInt32) actual);
-}
-
-
-void EXPECT_EQUAL_FLOAT32(const char* message, etFloat32 expected, etFloat32 actual, etFloat32 precision) {
- expect_equal_float(message, (etFloat64) expected, (etFloat64) actual, (etFloat64) precision);
-}
-
-void EXPECT_EQUAL_FLOAT64(const char* message, etFloat64 expected, etFloat64 actual, etFloat64 precision) {
- expect_equal_float(message, (etFloat64) expected, (etFloat64) actual, (etFloat64) precision);
-}
-
-/* order */
-static etInt16 etUnit_orderCurrentIndex = 0;
-static etInt16 etUnit_orderSize = 0;
-static etInt16* etUnit_orderList = NULL;
-
-void EXPECT_ORDER_START(etInt16* list, etInt16 size){
- etUnit_orderCurrentIndex = 0;
- etUnit_orderSize = size;
- etUnit_orderList = list;
-}
-
-void EXPECT_ORDER(const char* message, etInt16 identifier){
- if (etUnit_orderCurrentIndex < etUnit_orderSize) {
- if (etUnit_orderList[etUnit_orderCurrentIndex] != identifier){
- char testresult[ETUNIT_FAILURE_TEXT_LEN];
- sprintf(testresult, "EXPECT_ORDER %s: index=%d, expected=%d, actual=%d", message, etUnit_orderCurrentIndex, identifier, etUnit_orderList[etUnit_orderCurrentIndex]);
- etUnit_handleExpect(FALSE, testresult);
- }
- else {
- etUnit_handleExpect(TRUE, "");
- etUnit_orderCurrentIndex++;
- }
- }
- else {
- char testresult[ETUNIT_FAILURE_TEXT_LEN];
- sprintf(testresult, "EXPECT_ORDER: index(%d) is too big in %s", etUnit_orderCurrentIndex, message);
- etUnit_handleExpect(FALSE, testresult);
- etLogger_logInfoF("EXPECT_ORDER: index too big in %s", message);
- }
-}
-
-void EXPECT_ORDER_END(const char* message, etInt16 identifier){
- EXPECT_ORDER(message, identifier);
- if (etUnit_orderCurrentIndex != etUnit_orderSize){
- char testresult[ETUNIT_FAILURE_TEXT_LEN];
- sprintf(testresult, "EXPECT_ORDER_END %s: wrong index at the end: expected=%d, actual=%d", message, etUnit_orderSize, etUnit_orderCurrentIndex);
- etUnit_handleExpect(FALSE, testresult);
- }
-}
-
-/* private functions */
-
-void expect_equal_int(const char* message, etInt32 expected, etInt32 actual) {
- if (expected != actual) {
- char testresult[ETUNIT_FAILURE_TEXT_LEN];
- sprintf(testresult, "%s: expected=%ld, actual=%ld", message, expected, actual);
- etUnit_handleExpect(FALSE, testresult);
- } else {
- etUnit_handleExpect(TRUE, "");
- }
-}
-
-void expect_equal_uint(const char* message, etUInt32 expected, etUInt32 actual) {
- if (expected != actual) {
- char testresult[ETUNIT_FAILURE_TEXT_LEN];
- sprintf(testresult, "%s: expected=%lu, actual=%lu", message, expected, actual);
- etUnit_handleExpect(FALSE, testresult);
- } else {
- etUnit_handleExpect(TRUE, "");
- }
-}
-
-
-void expect_equal_float(const char* message, etFloat64 expected, etFloat64 actual, etFloat64 precision) {
- if (expected - actual < -precision || expected - actual > precision) {
- char testresult[ETUNIT_FAILURE_TEXT_LEN];
- sprintf(testresult, "%s: expected=%lf, actual=%lf", message, expected, actual);
- etUnit_handleExpect(FALSE, testresult);
- } else {
- etUnit_handleExpect(TRUE, "");
- }
-}
-
-void expect_equal_void_ptr(const char* message, const void* expected, const void* actual) {
- if (expected != actual) {
- char testresult[ETUNIT_FAILURE_TEXT_LEN];
- sprintf(testresult, "%s: expected=%ld, actual=%ld", message, (etUInt32) expected, (etUInt32) actual);
- etUnit_handleExpect(FALSE, testresult);
- } else {
- etUnit_handleExpect(TRUE, "");
- }
-}
-
-
-//_________
-
-void etUnit_handleExpect(etBool result, const char *resulttext){
- if (result == TRUE) {
- /* nothing to do because no failure */
- }
- else {
- if (etUnit_testcaseSuccess == TRUE){
- /* first failure will be remembered */
- etUnit_testcaseSuccess = FALSE;
- strcpy(etUnit_failureText, resulttext);
- }
- else{
- /* more than one error will be ignored */
- }
- }
-}
-
-void etUnit_buildTestLogXML(char* xml, const char *testcase, etBool result, const char *resulttext, clock_t time) {
- if (result == TRUE) {
- sprintf(xml, "\t\t<testcase name=\"%s\" time=\"%ld\"/>\n", testcase, time);
- } else {
- sprintf(
- xml,
- "\t\t<testcase name=\"%s\" classname=\"none\" time=\"%ld\">\n\t\t\t<failure>%s</failure>\n\t\t</testcase>\n",
- testcase, time, resulttext);
- }
-}
-
-void etUnit_writeTestLog(const char *testcase, etBool result, const char *resulttext) {
- char writeBuffer[ETUNIT_FAILURE_TEXT_LEN];
-
- // counting
- if (result == TRUE) {
- etUnit_passCount++;
- etUnit_passCountTotal++;
- etLogger_logInfoF("PASS: %s %s", testcase, resulttext);
- } else {
- etUnit_failCount++;
- etUnit_failCountTotal++;
- etLogger_logInfoF("FAIL: %s : %s", testcase, resulttext);
- }
-
- clock_t time = clock() - etUnit_currentTime;
- etUnit_currentTime = clock();
-
- // writing to file
- if (etUnit_reportfile != NULL) {
- etUnit_buildTestLogXML(writeBuffer, testcase, result, resulttext, time);
- etLogger_fprintf(etUnit_reportfile, writeBuffer);
- }
-}
-
+/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#include "etUnit/etUnit.h" +#include <string.h> +#include <time.h> +#include "debugging/etLogger.h" + + +/*** member variables */ + +/* file handling */ +static FILE* etUnit_reportfile = NULL; + +/* names */ +static char* etUnit_TestFileName = NULL; +static char* etUnit_TestResultPath = NULL; + +static char* etUnit_TestSuiteName = NULL; +static char* etUnit_TestCaseName = NULL; + +/* counters */ +static etInt32 etUnit_passCount = 0; +static etInt32 etUnit_failCount = 0; +static etInt32 etUnit_passCountTotal = 0; +static etInt32 etUnit_failCountTotal = 0; + +static etBool etUnit_testcaseSuccess = TRUE; + +#define ETUNIT_FAILURE_TEXT_LEN 256 + +static char etUnit_failureText[ETUNIT_FAILURE_TEXT_LEN]; + +/* time measuring */ +static clock_t etUnit_startTime = 0; +static clock_t etUnit_currentTime = 0; + +/* forward declarations of private functions */ +void expect_equal_int(const char* message, etInt32 expected, etInt32 actual); +void expect_equal_uint(const char* message, etUInt32 expected, etUInt32 actual); +void expect_equal_float(const char* message, etFloat32 expected, etFloat32 actual, etFloat32 precision); +void etUnit_writeTestLog(const char *testcase, etBool result, const char *resulttext); +void etUnit_handleExpect(etBool result, const char *resulttext); + +/* public functions */ + +void etUnit_open(char* testResultPath, char* testFileName) { + etUnit_passCount = 0; + etUnit_failCount = 0; + strcpy(etUnit_failureText,""); + + etUnit_TestFileName = testFileName; + etUnit_TestResultPath = testResultPath; + + etLogger_logInfoF("************* TEST START (%s) **************", etUnit_TestFileName); + + char filename[ETUNIT_FAILURE_TEXT_LEN]; + sprintf(filename, "%s/%s.xml", etUnit_TestResultPath, etUnit_TestFileName); + + if (etUnit_reportfile == NULL) { + etUnit_reportfile = etLogger_fopen(filename, "w+"); + if (etUnit_reportfile != NULL) { + etLogger_fprintf(etUnit_reportfile, "<testsuites name=\"%s\" tests=\"0\" failures=\"0\" errors=\"0\" time=\"0\">\n", etUnit_TestFileName); + } else { + etLogger_logErrorF("Unable to open file %s/%s.xml", etUnit_TestResultPath, etUnit_TestFileName); + } + } + /* prepare time measurement */ + etUnit_startTime = clock(); + etUnit_currentTime = clock(); + etLogger_logInfoF("Start Time: %ld", etUnit_startTime); + +} + +void etUnit_close(void) { + etLogger_logInfoF(""); + if (etUnit_failCount > 0) { + etLogger_logInfoF("************* TEST FAILED *************"); + } else { + etLogger_logInfoF("************* TEST PASSED *************"); + } + etLogger_logInfoF("Number of Tests: %ld", etUnit_failCount + etUnit_passCount); + etLogger_logInfoF("Failed: %ld", etUnit_failCount); + etLogger_logInfoF("Passed: %ld", etUnit_passCount); + etLogger_logInfoF("Time: %ld", clock() - etUnit_startTime); + etLogger_logInfoF("End Time: %ld[ms]", (clock() / 1000) * CLOCKS_PER_SEC ); + etLogger_logInfoF("***************************************"); + if (etUnit_failCountTotal > 0) { + etLogger_logInfoF(" ******* %d TEST(S) FAILED *****", etUnit_failCountTotal); + } else { + etLogger_logInfoF(" ******* ALL TESTS PASSED ******"); + } + etLogger_logInfoF("***************************************"); + + if (etUnit_reportfile != NULL) { + etLogger_fprintf(etUnit_reportfile, "</testsuites>\n"); + etLogger_fclose(etUnit_reportfile); + etUnit_reportfile = NULL; + } +} + +void etUnit_openTestSuite(char* testSuiteName) { + etUnit_TestSuiteName = testSuiteName; + if (etUnit_reportfile != NULL) { + etLogger_fprintf(etUnit_reportfile, "\t<testsuite name=\"%s\" tests=\"0\" failures=\"0\" errors=\"0\" time=\"0\">\n", + etUnit_TestSuiteName); + } +} + +void etUnit_closeTestSuite(void) { + if (etUnit_reportfile != NULL) { + etLogger_fprintf(etUnit_reportfile, "\t</testsuite>\n"); + } +} + +void etUnit_openTestCase(char* testCaseName) { + etUnit_TestCaseName = testCaseName; + etUnit_testcaseSuccess = TRUE; + strcpy(etUnit_failureText,""); +} + +void etUnit_closeTestCase(void) { + if (etUnit_reportfile != NULL && etUnit_TestSuiteName != NULL) { + etUnit_writeTestLog(etUnit_TestCaseName, etUnit_testcaseSuccess, etUnit_failureText); + } +} + +void etUnit_openAll(char* testResultPath, char* testFileName, char* testSuiteName, char* testCaseName){ + etUnit_open(testResultPath, testFileName); + etUnit_openTestSuite(testSuiteName); + etUnit_openTestCase(testCaseName); +} + +void etUnit_closeAll(void){ + etUnit_closeTestCase(); + etUnit_closeTestSuite(); + etUnit_close(); +} + +void EXPECT_TRUE(const char* message, etBool condition) { + if (condition == FALSE) { + char testresult[ETUNIT_FAILURE_TEXT_LEN]; + sprintf(testresult, "%s: *** EXPECT_TRUE == FALSE", message); + etUnit_handleExpect(FALSE, testresult); + } else { + etUnit_handleExpect(TRUE, ""); + } +} + +void EXPECT_FALSE(const char* message, etBool condition) { + if (condition == TRUE) { + char testresult[ETUNIT_FAILURE_TEXT_LEN]; + sprintf(testresult, "%s: EXPECT_FALSE == TRUE", message); + etUnit_handleExpect(FALSE, testresult); + } else { + etUnit_handleExpect(TRUE, ""); + } +} + +void EXPECT_EQUAL_INT8(const char* message, etInt8 expected, etInt8 actual) { + expect_equal_int(message, (etInt32) expected, (etInt32) actual); +} + +void EXPECT_EQUAL_INT16(const char* message, etInt16 expected, etInt16 actual) { + expect_equal_int(message, (etInt32) expected, (etInt32) actual); +} + +void EXPECT_EQUAL_INT32(const char* message, etInt32 expected, etInt32 actual) { + expect_equal_int(message, (etInt32) expected, (etInt32) actual); +} + +void EXPECT_EQUAL_UINT8(const char* message, etUInt8 expected, etUInt8 actual) { + expect_equal_uint(message, (etUInt32) expected, (etUInt32) actual); +} + +void EXPECT_EQUAL_UINT16(const char* message, etUInt16 expected, etUInt16 actual) { + expect_equal_uint(message, (etUInt32) expected, (etUInt32) actual); +} + +void EXPECT_EQUAL_UINT32(const char* message, etUInt32 expected, etUInt32 actual) { + expect_equal_uint(message, (etUInt32) expected, (etUInt32) actual); +} + + +void EXPECT_EQUAL_FLOAT32(const char* message, etFloat32 expected, etFloat32 actual, etFloat32 precision) { + expect_equal_float(message, expected, actual, precision); +} + +/* order */ +static etInt16 etUnit_orderCurrentIndex = 0; +static etInt16 etUnit_orderSize = 0; +static etInt16* etUnit_orderList = NULL; + +void EXPECT_ORDER_START(etInt16* list, etInt16 size){ + etUnit_orderCurrentIndex = 0; + etUnit_orderSize = size; + etUnit_orderList = list; +} + +void EXPECT_ORDER(const char* message, etInt16 identifier){ + if (etUnit_orderCurrentIndex < etUnit_orderSize) { + if (etUnit_orderList[etUnit_orderCurrentIndex] != identifier){ + char testresult[ETUNIT_FAILURE_TEXT_LEN]; + sprintf(testresult, "EXPECT_ORDER %s: index=%d, expected=%d, actual=%d", message, etUnit_orderCurrentIndex, identifier, etUnit_orderList[etUnit_orderCurrentIndex]); + etUnit_handleExpect(FALSE, testresult); + } + else { + etUnit_handleExpect(TRUE, ""); + etUnit_orderCurrentIndex++; + } + } + else { + char testresult[ETUNIT_FAILURE_TEXT_LEN]; + sprintf(testresult, "EXPECT_ORDER: index(%d) is too big in %s", etUnit_orderCurrentIndex, message); + etUnit_handleExpect(FALSE, testresult); + etLogger_logInfoF("EXPECT_ORDER: index too big in %s", message); + } +} + +void EXPECT_ORDER_END(const char* message, etInt16 identifier){ + EXPECT_ORDER(message, identifier); + if (etUnit_orderCurrentIndex != etUnit_orderSize){ + char testresult[ETUNIT_FAILURE_TEXT_LEN]; + sprintf(testresult, "EXPECT_ORDER_END %s: wrong index at the end: expected=%d, actual=%d", message, etUnit_orderSize, etUnit_orderCurrentIndex); + etUnit_handleExpect(FALSE, testresult); + } +} + +/* private functions */ + +void expect_equal_int(const char* message, etInt32 expected, etInt32 actual) { + if (expected != actual) { + char testresult[ETUNIT_FAILURE_TEXT_LEN]; + sprintf(testresult, "%s: expected=%ld, actual=%ld", message, expected, actual); + etUnit_handleExpect(FALSE, testresult); + } else { + etUnit_handleExpect(TRUE, ""); + } +} + +void expect_equal_uint(const char* message, etUInt32 expected, etUInt32 actual) { + if (expected != actual) { + char testresult[ETUNIT_FAILURE_TEXT_LEN]; + sprintf(testresult, "%s: expected=%lu, actual=%lu", message, expected, actual); + etUnit_handleExpect(FALSE, testresult); + } else { + etUnit_handleExpect(TRUE, ""); + } +} + + +void expect_equal_float(const char* message, etFloat32 expected, etFloat32 actual, etFloat32 precision) { + if (expected - actual < -precision || expected - actual > precision) { + char testresult[ETUNIT_FAILURE_TEXT_LEN]; + sprintf(testresult, "%s: expected=%f, actual=%f", message, expected, actual); + etUnit_handleExpect(FALSE, testresult); + } else { + etUnit_handleExpect(TRUE, ""); + } +} + +void expect_equal_void_ptr(const char* message, const void* expected, const void* actual) { + if (expected != actual) { + char testresult[ETUNIT_FAILURE_TEXT_LEN]; + sprintf(testresult, "%s: expected=%ld, actual=%ld", message, (etUInt32) expected, (etUInt32) actual); + etUnit_handleExpect(FALSE, testresult); + } else { + etUnit_handleExpect(TRUE, ""); + } +} + + +//_________ + +void etUnit_handleExpect(etBool result, const char *resulttext){ + if (result == TRUE) { + /* nothing to do because no failure */ + } + else { + if (etUnit_testcaseSuccess == TRUE){ + /* first failure will be remembered */ + etUnit_testcaseSuccess = FALSE; + strcpy(etUnit_failureText, resulttext); + } + else{ + /* more than one error will be ignored */ + } + } +} + +void etUnit_buildTestLogXML(char* xml, const char *testcase, etBool result, const char *resulttext, clock_t time) { + if (result == TRUE) { + sprintf(xml, "\t\t<testcase name=\"%s\" time=\"%ld\"/>\n", testcase, time); + } else { + sprintf( + xml, + "\t\t<testcase name=\"%s\" classname=\"none\" time=\"%ld\">\n\t\t\t<failure>%s</failure>\n\t\t</testcase>\n", + testcase, time, resulttext); + } +} + +void etUnit_writeTestLog(const char *testcase, etBool result, const char *resulttext) { + char writeBuffer[ETUNIT_FAILURE_TEXT_LEN]; + + // counting + if (result == TRUE) { + etUnit_passCount++; + etUnit_passCountTotal++; + etLogger_logInfoF("PASS: %s %s", testcase, resulttext); + } else { + etUnit_failCount++; + etUnit_failCountTotal++; + etLogger_logInfoF("FAIL: %s : %s", testcase, resulttext); + } + + clock_t time = clock() - etUnit_currentTime; + etUnit_currentTime = clock(); + + // writing to file + if (etUnit_reportfile != NULL) { + etUnit_buildTestLogXML(writeBuffer, testcase, result, resulttext, time); + etLogger_fprintf(etUnit_reportfile, writeBuffer); + } +} + diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etUnit.h b/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.h index 34284c541..2a25289bc 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etUnit.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.h @@ -1,70 +1,69 @@ -/*******************************************************************************
- * Copyright (c) 2011 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef _ETUNIT_H_
-#define _ETUNIT_H_
-
-#include "etDatatypes.h"
-
-
-/* open / close */
-void etUnit_open(char* testResultPath, char* testFileName);
-void etUnit_close(void);
-void etUnit_openTestSuite(char* testSuiteName);
-void etUnit_closeTestSuite(void);
-void etUnit_openTestCase(char* testCaseName);
-void etUnit_closeTestCase(void);
-
-/* functions for more convenience for model and generator tests */
-
-void etUnit_openAll(char* testResultPath, char* testFileName, char* testSuiteName, char* testCaseName);
-void etUnit_closeAll(void);
-
-/* boolean values */
-void EXPECT_TRUE(const char* testcase, etBool condition);
-void EXPECT_FALSE(const char* testcase, etBool condition);
-
-/* signed integer values */
-void EXPECT_EQUAL_INT8(const char* testcase, etInt8 expected, etInt8 actual);
-void EXPECT_EQUAL_INT16(const char* testcase, etInt16 expected, etInt16 actual);
-void EXPECT_EQUAL_INT32(const char* testcase, etInt32 expected, etInt32 actual);
-
-/* unsigned integer values */
-void EXPECT_EQUAL_UINT8(const char* testcase, etUInt8 expected, etUInt8 actual);
-void EXPECT_EQUAL_UINT16(const char* testcase, etUInt16 expected, etUInt16 actual);
-void EXPECT_EQUAL_UINT32(const char* testcase, etUInt32 expected, etUInt32 actual);
-
-/* float values */
-void EXPECT_EQUAL_FLOAT32(const char* testcase, etFloat32 expected, etFloat32 actual, etFloat32 precision);
-void EXPECT_EQUAL_FLOAT64(const char* testcase, etFloat64 expected, etFloat64 actual, etFloat64 precision);
-
-/* Pointers */
-#define EXPECT_EQUAL_PTR(testcase, expected, actual) \
- expect_equal_void_ptr(testcase, (const void*) expected, (const void*) actual);
-
-void expect_equal_void_ptr(const char* testcase, const void* expected, const void* actual);
-
-/* more specialized functions */
-void EXPECT_ORDER_START(etInt16* list, etInt16 size);
-void EXPECT_ORDER(const char* message, etInt16 identifier);
-void EXPECT_ORDER_END(const char* message, etInt16 identifier);
-
-
-/* Helpers for adding testcases */
-
-#define ADD_TESTCASE(testcase) \
- etUnit_openTestCase(#testcase); \
- testcase(); \
- etUnit_closeTestCase();
-
-
-#endif /* _ETUNIT_H_ */
+/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#ifndef _ETUNIT_H_ +#define _ETUNIT_H_ + +#include "etDatatypes.h" + + +/* open / close */ +void etUnit_open(char* testResultPath, char* testFileName); +void etUnit_close(void); +void etUnit_openTestSuite(char* testSuiteName); +void etUnit_closeTestSuite(void); +void etUnit_openTestCase(char* testCaseName); +void etUnit_closeTestCase(void); + +/* functions for more convenience for model and generator tests */ + +void etUnit_openAll(char* testResultPath, char* testFileName, char* testSuiteName, char* testCaseName); +void etUnit_closeAll(void); + +/* boolean values */ +void EXPECT_TRUE(const char* testcase, etBool condition); +void EXPECT_FALSE(const char* testcase, etBool condition); + +/* signed integer values */ +void EXPECT_EQUAL_INT8(const char* testcase, etInt8 expected, etInt8 actual); +void EXPECT_EQUAL_INT16(const char* testcase, etInt16 expected, etInt16 actual); +void EXPECT_EQUAL_INT32(const char* testcase, etInt32 expected, etInt32 actual); + +/* unsigned integer values */ +void EXPECT_EQUAL_UINT8(const char* testcase, etUInt8 expected, etUInt8 actual); +void EXPECT_EQUAL_UINT16(const char* testcase, etUInt16 expected, etUInt16 actual); +void EXPECT_EQUAL_UINT32(const char* testcase, etUInt32 expected, etUInt32 actual); + +/* float values */ +void EXPECT_EQUAL_FLOAT32(const char* testcase, etFloat32 expected, etFloat32 actual, etFloat32 precision); + +/* Pointers */ +#define EXPECT_EQUAL_PTR(testcase, expected, actual) \ + expect_equal_void_ptr(testcase, (const void*) expected, (const void*) actual); + +void expect_equal_void_ptr(const char* testcase, const void* expected, const void* actual); + +/* more specialized functions */ +void EXPECT_ORDER_START(etInt16* list, etInt16 size); +void EXPECT_ORDER(const char* message, etInt16 identifier); +void EXPECT_ORDER_END(const char* message, etInt16 identifier); + + +/* Helpers for adding testcases */ + +#define ADD_TESTCASE(testcase) \ + etUnit_openTestCase(#testcase); \ + testcase(); \ + etUnit_closeTestCase(); + + +#endif /* _ETUNIT_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessage.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.c index 146467c23..224461432 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etMessage.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.c @@ -1,25 +1,25 @@ -/*******************************************************************************
- * Copyright (c) 2011 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#include "etMessage.h"
-
-#include "etMSCLogger.h"
-
-#include <stddef.h>
-
-void etMessage_init(etMessage* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessage", "init")
- self->next = NULL;
- self->address = 0;
- self->evtID = 0;
- ET_MSC_LOGGER_SYNC_EXIT
-}
+/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#include "messaging/etMessage.h" + +#include "debugging/etMSCLogger.h" + +#include <stddef.h> + +void etMessage_init(etMessage* self){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessage", "init") + self->next = NULL; + self->address = 0; + self->evtID = 0; + ET_MSC_LOGGER_SYNC_EXIT +} diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessage.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h index 698a89c09..7bba6a1f3 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etMessage.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h @@ -1,26 +1,26 @@ -/*******************************************************************************
- * Copyright (c) 2011 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef _ETMESSAGE_H_
-#define _ETMESSAGE_H_
-
-#include "etDatatypes.h"
-
-typedef struct etMessage{
- struct etMessage* next;
- etInt16 address;
- etInt16 evtID;
-} etMessage;
-
-void etMessage_init(etMessage* self);
-
-#endif /* _ETMESSAGE_H_ */
+/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#ifndef _ETMESSAGE_H_ +#define _ETMESSAGE_H_ + +#include "etDatatypes.h" + +typedef struct etMessage{ + struct etMessage* next; + etInt16 address; + etInt16 evtID; +} etMessage; + +void etMessage_init(etMessage* self); + +#endif /* _ETMESSAGE_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c index 639798bc6..2ba045420 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c @@ -1,99 +1,99 @@ -/*******************************************************************************
- * Copyright (c) 2011 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#include "etMessageQueue.h"
-
-#include "etMSCLogger.h"
-
-void etMessageQueue_init(etMessageQueue* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init")
- self->first = NULL;
- self->last = NULL;
- self->highWaterMark = 0;
- self->size = 0;
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-
-void etMessageQueue_push(etMessageQueue* self, etMessage* msg){
- // TODO: optimize queue for concurrent push / pop
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "push")
- if (self->first == NULL) {
- /*no message in queue*/
- self->first = self->last = msg;
- }
- else {
- /*at least one message in queue*/
- self->last->next = msg;
- self->last = msg;
- }
- msg->next = NULL; /*TODO: optimization: this line could be removed if we assume that all messages are initialized*/
-
- if (++self->size > self->highWaterMark)
- self->highWaterMark++;
-
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-etMessage* etMessageQueue_pop(etMessageQueue* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "pop")
- etMessage* pop_msg = self->first;
- if(self->first == NULL){
- /*no message in queue*/
- ET_MSC_LOGGER_SYNC_EXIT
- return NULL;
- }
- if (self->first->next==NULL){
- /*only one message in queue*/
- self->first = self->last = NULL;
- }
- else {
- /*more than one message in queue -> set first to nex message*/
- self->first = self->first->next;
- }
-
- pop_msg->next=NULL;
- self->size--;
-
- ET_MSC_LOGGER_SYNC_EXIT
- return pop_msg;
-}
-
-etInt16 etMessageQueue_getSize(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getSize")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->size;
-}
-
-etMessage* etMessageQueue_getFirst(etMessageQueue* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getFirst")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->first;
-}
-
-etMessage* etMessageQueue_getLast(etMessageQueue* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getLast")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->last;
-}
-
-etBool etMessageQueue_isNotEmpty(etMessageQueue* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "isNotEmpty")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->last != NULL;
-}
-
-etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getHightWaterMark")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->highWaterMark;
-}
+/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#include "messaging/etMessageQueue.h" + +#include "debugging/etMSCLogger.h" + +void etMessageQueue_init(etMessageQueue* self){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init") + self->first = NULL; + self->last = NULL; + self->highWaterMark = 0; + self->size = 0; + ET_MSC_LOGGER_SYNC_EXIT +} + + +void etMessageQueue_push(etMessageQueue* self, etMessage* msg){ + // TODO: optimize queue for concurrent push / pop + ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "push") + if (self->first == NULL) { + /*no message in queue*/ + self->first = self->last = msg; + } + else { + /*at least one message in queue*/ + self->last->next = msg; + self->last = msg; + } + msg->next = NULL; /*TODO: optimization: this line could be removed if we assume that all messages are initialized*/ + + if (++self->size > self->highWaterMark) + self->highWaterMark++; + + ET_MSC_LOGGER_SYNC_EXIT +} + +etMessage* etMessageQueue_pop(etMessageQueue* self){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "pop") + etMessage* pop_msg = self->first; + if(self->first == NULL){ + /*no message in queue*/ + ET_MSC_LOGGER_SYNC_EXIT + return NULL; + } + if (self->first->next==NULL){ + /*only one message in queue*/ + self->first = self->last = NULL; + } + else { + /*more than one message in queue -> set first to nex message*/ + self->first = self->first->next; + } + + pop_msg->next=NULL; + self->size--; + + ET_MSC_LOGGER_SYNC_EXIT + return pop_msg; +} + +etInt16 etMessageQueue_getSize(etMessageQueue* self) { + ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getSize") + ET_MSC_LOGGER_SYNC_EXIT + return self->size; +} + +etMessage* etMessageQueue_getFirst(etMessageQueue* self){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getFirst") + ET_MSC_LOGGER_SYNC_EXIT + return self->first; +} + +etMessage* etMessageQueue_getLast(etMessageQueue* self){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getLast") + ET_MSC_LOGGER_SYNC_EXIT + return self->last; +} + +etBool etMessageQueue_isNotEmpty(etMessageQueue* self){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "isNotEmpty") + ET_MSC_LOGGER_SYNC_EXIT + return self->last != NULL; +} + +etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self) { + ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getHightWaterMark") + ET_MSC_LOGGER_SYNC_EXIT + return self->highWaterMark; +} diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h index a303146ec..473df5c0f 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h @@ -1,45 +1,45 @@ -/*******************************************************************************
- * Copyright (c) 2011 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef _ETMESSAGEQUEUE_H_
-#define _ETMESSAGEQUEUE_H_
-
-#include "etMessage.h"
-#include <stddef.h>
-
-typedef struct etMessageQueue {
- etMessage* first;
- etMessage* last;
- etInt16 highWaterMark;
- etInt16 size;
-
-} etMessageQueue;
-
-void etMessageQueue_init(etMessageQueue* self);
-
-void etMessageQueue_push(etMessageQueue* self, etMessage* msg);
-
-etMessage* etMessageQueue_pop(etMessageQueue* self);
-
-etMessage* etMessageQueue_getFirst(etMessageQueue* self);
-
-etMessage* etMessageQueue_getLast(etMessageQueue* self);
-
-etBool etMessageQueue_isNotEmpty(etMessageQueue* self);
-
-etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self);
-
-etInt16 etMessageQueue_getSize(etMessageQueue* self);
-
-
-
-#endif /* _RMESSAGEQUEUE_H_ */
+/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#ifndef _ETMESSAGEQUEUE_H_ +#define _ETMESSAGEQUEUE_H_ + +#include "messaging/etMessage.h" +#include <stddef.h> + +typedef struct etMessageQueue { + etMessage* first; + etMessage* last; + etInt16 highWaterMark; + etInt16 size; + +} etMessageQueue; + +void etMessageQueue_init(etMessageQueue* self); + +void etMessageQueue_push(etMessageQueue* self, etMessage* msg); + +etMessage* etMessageQueue_pop(etMessageQueue* self); + +etMessage* etMessageQueue_getFirst(etMessageQueue* self); + +etMessage* etMessageQueue_getLast(etMessageQueue* self); + +etBool etMessageQueue_isNotEmpty(etMessageQueue* self); + +etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self); + +etInt16 etMessageQueue_getSize(etMessageQueue* self); + + + +#endif /* _RMESSAGEQUEUE_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageReceiver.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h index c75686654..5c6aa690a 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageReceiver.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h @@ -1,23 +1,23 @@ -/*******************************************************************************
- * Copyright (c) 2012 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-
-
-#ifndef _ETMESSAGERECEIVER_H_
-#define _ETMESSAGERECEIVER_H_
-
-#include "etMessage.h"
-
-typedef void (*etActorReceiveMessage)(void* self, void* ifitem, const etMessage* msg);
-typedef void (*etDispatcherReceiveMessage)(const etMessage* msg);
-
-#endif /* _ETMESSAGERECEIVER_H_ */
+/******************************************************************************* + * Copyright (c) 2012 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + + + +#ifndef _ETMESSAGERECEIVER_H_ +#define _ETMESSAGERECEIVER_H_ + +#include "messaging/etMessage.h" + +typedef void (*etActorReceiveMessage)(void* self, void* ifitem, const etMessage* msg); +typedef void (*etDispatcherReceiveMessage)(const etMessage* msg); + +#endif /* _ETMESSAGERECEIVER_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c index 10e2fe00c..b7c91faf8 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c @@ -1,103 +1,103 @@ -/*******************************************************************************
- * Copyright (c) 2011 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-
-#include "etMessageService.h"
-
-
-#include "etLogger.h"
-#include "etMSCLogger.h"
-
-void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 maxBlocks, etUInt16 blockSize, etDispatcherReceiveMessage msgDispatcher){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "init")
- self->messageBuffer.buffer = buffer;
- self->messageBuffer.maxBlocks = maxBlocks;
- self->messageBuffer.blockSize = blockSize;
- self->msgDispatcher = msgDispatcher;
-
- etMessageQueue_init(&self->messagePool);
- etMessageQueue_init(&self->messageQueue);
-
- etMessageService_initMessagePool(self);
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-/*
- * initialize message pool with block buffer
- * all blocks are added to pool
- */
-void etMessageService_initMessagePool(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "initMessagePool")
- etInt16 i;
-
- for (i=0; i<self->messageBuffer.maxBlocks; i++){
- etMessage* block = (etMessage*) &self->messageBuffer.buffer[i*self->messageBuffer.blockSize];
- etMessageQueue_push(&self->messagePool, block);
- }
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etMessageService_pushMessage(etMessageService* self, etMessage* msg){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "pushMessage")
- etMessageQueue_push(&self->messageQueue, msg);
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-etMessage* etMessageService_popMessage(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "popMessage")
- etMessage* msg = etMessageQueue_pop(&self->messageQueue);
- ET_MSC_LOGGER_SYNC_EXIT
- return msg;
-}
-
-
-etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 size){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessageBuffer")
- if (size<=self->messageBuffer.blockSize){
- if (self->messagePool.size>0){
- etMessage* msg = etMessageQueue_pop(&self->messagePool);
- ET_MSC_LOGGER_SYNC_EXIT
- return msg;
- }
- }
- ET_MSC_LOGGER_SYNC_EXIT
- return NULL;
-}
-
-void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "returnMessageBuffer")
- etMessageQueue_push(&self->messagePool, buffer);
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etMessageService_deliverAllMessages(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "deliverAllMessages")
- while (etMessageQueue_isNotEmpty(&self->messageQueue)){
- etMessage* msg = etMessageService_popMessage(self);
- self->msgDispatcher(msg);
- etMessageService_returnMessageBuffer(self, msg);
- }
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etMessageService_execute(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "execute")
- etMessageService_deliverAllMessages(self);
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessagePoolLowWaterMark")
- etInt16 lowWaterMark = self->messageBuffer.maxBlocks - etMessageQueue_getHighWaterMark(&self->messageQueue);
- ET_MSC_LOGGER_SYNC_EXIT
- return lowWaterMark;
-}
+/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + + +#include "etMessageService.h" + + +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" + +void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 maxBlocks, etUInt16 blockSize, etDispatcherReceiveMessage msgDispatcher){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "init") + self->messageBuffer.buffer = buffer; + self->messageBuffer.maxBlocks = maxBlocks; + self->messageBuffer.blockSize = blockSize; + self->msgDispatcher = msgDispatcher; + + etMessageQueue_init(&self->messagePool); + etMessageQueue_init(&self->messageQueue); + + etMessageService_initMessagePool(self); + ET_MSC_LOGGER_SYNC_EXIT +} + +/* + * initialize message pool with block buffer + * all blocks are added to pool + */ +void etMessageService_initMessagePool(etMessageService* self){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "initMessagePool") + etInt16 i; + + for (i=0; i<self->messageBuffer.maxBlocks; i++){ + etMessage* block = (etMessage*) &self->messageBuffer.buffer[i*self->messageBuffer.blockSize]; + etMessageQueue_push(&self->messagePool, block); + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void etMessageService_pushMessage(etMessageService* self, etMessage* msg){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "pushMessage") + etMessageQueue_push(&self->messageQueue, msg); + ET_MSC_LOGGER_SYNC_EXIT +} + +etMessage* etMessageService_popMessage(etMessageService* self){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "popMessage") + etMessage* msg = etMessageQueue_pop(&self->messageQueue); + ET_MSC_LOGGER_SYNC_EXIT + return msg; +} + + +etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 size){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessageBuffer") + if (size<=self->messageBuffer.blockSize){ + if (self->messagePool.size>0){ + etMessage* msg = etMessageQueue_pop(&self->messagePool); + ET_MSC_LOGGER_SYNC_EXIT + return msg; + } + } + ET_MSC_LOGGER_SYNC_EXIT + return NULL; +} + +void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "returnMessageBuffer") + etMessageQueue_push(&self->messagePool, buffer); + ET_MSC_LOGGER_SYNC_EXIT +} + +void etMessageService_deliverAllMessages(etMessageService* self){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "deliverAllMessages") + while (etMessageQueue_isNotEmpty(&self->messageQueue)){ + etMessage* msg = etMessageService_popMessage(self); + self->msgDispatcher(msg); + etMessageService_returnMessageBuffer(self, msg); + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void etMessageService_execute(etMessageService* self){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "execute") + etMessageService_deliverAllMessages(self); + ET_MSC_LOGGER_SYNC_EXIT +} + +etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self){ + ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessagePoolLowWaterMark") + etInt16 lowWaterMark = self->messageBuffer.maxBlocks - etMessageQueue_getHighWaterMark(&self->messageQueue); + ET_MSC_LOGGER_SYNC_EXIT + return lowWaterMark; +} diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h index 5997363d1..f978e1eb7 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h @@ -1,50 +1,50 @@ -/*******************************************************************************
- * Copyright (c) 2011 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef _ETMESSAGESERVICE_H_
-#define _ETMESSAGESERVICE_H_
-
-#include <stddef.h>
-#include "etDatatypes.h"
-#include "etMessageQueue.h"
-#include "etMessageReceiver.h"
-
-typedef struct etBuffer{
- etUInt8 *buffer;
- etUInt16 maxBlocks;
- etUInt16 blockSize;
-} etBuffer;
-
-typedef struct etMessageService {
- etMessageQueue messageQueue;
- etMessageQueue messagePool;
- etBuffer messageBuffer;
- etDispatcherReceiveMessage msgDispatcher;
-} etMessageService;
-
-void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 maxBlocks, etUInt16 blockSize, etDispatcherReceiveMessage msgDispatcher);
-
-void etMessageService_initMessagePool(etMessageService* self);
-
-void etMessageService_pushMessage(etMessageService* self, etMessage* msg);
-etMessage* etMessageService_popMessage(etMessageService* self);
-
-etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 size);
-void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer);
-
-void etMessageService_execute(etMessageService* self);
-
-/* functions for debug and service information */
-etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self);
-
-
-#endif /* RMESSAGESERVICE_H_ */
+/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#ifndef _ETMESSAGESERVICE_H_ +#define _ETMESSAGESERVICE_H_ + +#include <stddef.h> +#include "etDatatypes.h" +#include "messaging/etMessageQueue.h" +#include "messaging/etMessageReceiver.h" + +typedef struct etBuffer{ + etUInt8 *buffer; + etUInt16 maxBlocks; + etUInt16 blockSize; +} etBuffer; + +typedef struct etMessageService { + etMessageQueue messageQueue; + etMessageQueue messagePool; + etBuffer messageBuffer; + etDispatcherReceiveMessage msgDispatcher; +} etMessageService; + +void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 maxBlocks, etUInt16 blockSize, etDispatcherReceiveMessage msgDispatcher); + +void etMessageService_initMessagePool(etMessageService* self); + +void etMessageService_pushMessage(etMessageService* self, etMessage* msg); +etMessage* etMessageService_popMessage(etMessageService* self); + +etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 size); +void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer); + +void etMessageService_execute(etMessageService* self); + +/* functions for debug and service information */ +etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self); + + +#endif /* RMESSAGESERVICE_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etActor.c b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.c index 008a6474d..dc7e1adcf 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etActor.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.c @@ -1,18 +1,18 @@ -/*******************************************************************************
- * Copyright (c) 2012 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)
- *
- *******************************************************************************/
-
-#include "etActor.h"
-
-boolean handleSystemEvent(InterfaceItemBase ifitem, int evt, void* generic_data) {
- /* TODO */
- return FALSE;
-}
+/******************************************************************************* + * Copyright (c) 2012 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) + * + *******************************************************************************/ + +#include "modelbase/etActor.h" + +boolean handleSystemEvent(InterfaceItemBase ifitem, int evt, void* generic_data) { + /* TODO */ + return FALSE; +} diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etActor.h b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h index 5cd70f694..8f115849f 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etActor.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h @@ -1,24 +1,24 @@ -/*******************************************************************************
- * Copyright (c) 2012 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)
- *
- *******************************************************************************/
-
-#ifndef _ETACTOR_H_
-#define _ETACTOR_H_
-
-#include "etDataTypes.h"
-#include "etPort.h"
-
-#define NOT_CAUGHT 0
-#define EVT_SHIFT 100
-
-boolean handleSystemEvent(InterfaceItemBase ifitem, int evt, void* generic_data);
-
-#endif /* _ETACTOR_H_ */
+/******************************************************************************* + * Copyright (c) 2012 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) + * + *******************************************************************************/ + +#ifndef _ETACTOR_H_ +#define _ETACTOR_H_ + +#include "etDatatypes.h" +#include "modelbase/etPort.h" + +#define NOT_CAUGHT 0 +#define EVT_SHIFT 100 + +boolean handleSystemEvent(InterfaceItemBase ifitem, int evt, void* generic_data); + +#endif /* _ETACTOR_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etPort.c b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.c index 24f22043d..cbdbdaaf7 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etPort.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.c @@ -1,30 +1,30 @@ -/*******************************************************************************
- * Copyright (c) 2012 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#include "etPort.h"
-
-#include "etMSCLogger.h"
-
-void etPort_receive(const etPort* self, const etMessage* msg) {
- ET_MSC_LOGGER_SYNC_ENTRY("etPort", "receive")
- if (self->receiveMessageFunc!=NULL)
- (self->receiveMessageFunc)(self->myActor, (void*)self, msg);
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-
-void etPort_sendMessage(const etPort* self, etInt16 evtId) {
- etMessage* msg = etMessageService_getMessageBuffer(self->msgService, sizeof(etMessage));
- msg->address = self->peerAddress;
- msg->evtID = evtId;
- etMessageService_pushMessage(self->msgService, msg);
-}
+/******************************************************************************* + * Copyright (c) 2012 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#include "modelbase/etPort.h" + +#include "debugging/etMSCLogger.h" + +void etPort_receive(const etPort* self, const etMessage* msg) { + ET_MSC_LOGGER_SYNC_ENTRY("etPort", "receive") + if (self->receiveMessageFunc!=NULL) + (self->receiveMessageFunc)(self->myActor, (void*)self, msg); + ET_MSC_LOGGER_SYNC_EXIT +} + + +void etPort_sendMessage(const etPort* self, etInt16 evtId) { + etMessage* msg = etMessageService_getMessageBuffer(self->msgService, sizeof(etMessage)); + msg->address = self->peerAddress; + msg->evtID = evtId; + etMessageService_pushMessage(self->msgService, msg); +} diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etPort.h b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h index 797adb9ad..3ddecd74d 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etPort.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h @@ -1,62 +1,62 @@ -/*******************************************************************************
- * Copyright (c) 2012 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-
-
-#ifndef _ETPORT_H_
-#define _ETPORT_H_
-
-
-#include "etMessage.h"
-#include "etMessageReceiver.h"
-#include "etMessageService.h"
-
-typedef struct {
- void* myActor;
- etActorReceiveMessage receiveMessageFunc;
- etMessageService* msgService;
- etAddressId peerAddress;
- etAddressId localId;
-
- #ifdef etDEBUG
- etAddressId address;
- /* thread ID from msg service: msgService->threadId */
- #endif
-} etPort;
-
-typedef struct {
- void* myActor;
- etActorReceiveMessage receiveMessageFunc;
- etMessageService* msgService;
- etAddressId peerAddress;
- etAddressId localId;
- etAddressId index;
-
- #ifdef etDEBUG
- etAddressId address;
- /* thread ID from msg service: msgService->threadId */
- #endif
-} etReplSubPort;
-
-typedef struct {
- etInt16 size;
- const etReplSubPort* ports;
-} etReplPort;
-
-typedef etPort* InterfaceItemBase;
-
-void etPort_receive(const etPort* self, const etMessage* msg);
-void etPort_sendMessage(const etPort* self, etInt16 evtId);
-
-
-
-#endif /* _ETPORT_H_ */
+/******************************************************************************* + * Copyright (c) 2012 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + + + +#ifndef _ETPORT_H_ +#define _ETPORT_H_ + + +#include "messaging/etMessage.h" +#include "messaging/etMessageReceiver.h" +#include "messaging/etMessageService.h" + +typedef struct { + void* myActor; + etActorReceiveMessage receiveMessageFunc; + etMessageService* msgService; + etAddressId peerAddress; + etAddressId localId; + + #ifdef etDEBUG + etAddressId address; + /* thread ID from msg service: msgService->threadId */ + #endif +} etPort; + +typedef struct { + void* myActor; + etActorReceiveMessage receiveMessageFunc; + etMessageService* msgService; + etAddressId peerAddress; + etAddressId localId; + etAddressId index; + + #ifdef etDEBUG + etAddressId address; + /* thread ID from msg service: msgService->threadId */ + #endif +} etReplSubPort; + +typedef struct { + etInt16 size; + const etReplSubPort* ports; +} etReplPort; + +typedef etPort* InterfaceItemBase; + +void etPort_receive(const etPort* self, const etMessage* msg); +void etPort_sendMessage(const etPort* self, etInt16 evtId); + + + +#endif /* _ETPORT_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etDatatypes.h new file mode 100644 index 000000000..da1effaa2 --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etDatatypes.h @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#ifndef _ETDATATYPES_H_ +#define _ETDATATYPES_H_ + +/* + * typedefs for platform specific datatypes + * Version for TI MSP 430 + * + * */ + +#include <stdio.h> + +/* global definitions for datatypes */ +//#define HAS_64_BIT_TYPES + +/* unsigned integer datatypes */ +typedef unsigned char uint8; +typedef unsigned short int uint16; +typedef unsigned long uint32; +/* typedef unsigned long long uint64; */ /* not available on this platform */ + +/* signed integer datatypes */ +typedef char int8; +typedef short int int16; +typedef long int32; +/* typedef long long int64; */ /* not available on this platform */ + + +/* float datatypes */ +typedef float float32; +/* typedef double float64; */ /* not available on this platform */ + +/* boolean datatypes and values */ +typedef char bool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/ +typedef bool boolean; +#ifndef TRUE + #define TRUE 1 +#endif +#ifndef FALSE + #define FALSE 0 +#endif + +/* + * typedefs for eTrice Runtime and Testing + * + * */ + +typedef int8 etInt8; +typedef int16 etInt16; +typedef int32 etInt32; + +typedef uint8 etUInt8; +typedef uint16 etUInt16; +typedef uint32 etUInt32; + +typedef bool etBool; + +typedef float32 etFloat32; + +typedef FILE* etFileHandle; + +typedef int8 etAddressId; + +#endif /* _DATATYPES_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h index bf161f396..48a35e37f 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h @@ -1,72 +1,72 @@ -/*******************************************************************************
- * Copyright (c) 2011 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef _ETDATATYPES_H_
-#define _ETDATATYPES_H_
-
-/*
- * typedefs for platform specific datatypes
- *
- * */
-
-#include <stdio.h>
-
-/* unsigned integer datatypes */
-typedef unsigned char uint8;
-typedef unsigned short int uint16;
-typedef unsigned long uint32;
-typedef unsigned long long uint64;
-
-/* signed integer datatypes */
-typedef char int8;
-typedef short int int16;
-typedef long int32;
-typedef long long int64;
-
-
-/* float datatypes */
-typedef float float32;
-typedef double float64;
-
-/* boolean datatypes and values */
-typedef char bool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/
-typedef bool boolean;
-#ifndef TRUE
- #define TRUE 1
-#endif
-#ifndef FALSE
- #define FALSE 0
-#endif
-
-/*
- * typedefs for eTrice Runtime and Testing
- *
- * */
-
-typedef int8 etInt8;
-typedef int16 etInt16;
-typedef int32 etInt32;
-
-typedef uint8 etUInt8;
-typedef uint16 etUInt16;
-typedef uint32 etUInt32;
-
-typedef bool etBool;
-
-typedef float32 etFloat32;
-typedef float64 etFloat64;
-
-typedef FILE* etFileHandle;
-
-typedef int8 etAddressId;
-
-#endif /* _DATATYPES_H_ */
+/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#ifndef _ETDATATYPES_H_ +#define _ETDATATYPES_H_ + +/* + * typedefs for platform specific datatypes + * + * */ + +#include <stdio.h> + +/* unsigned integer datatypes */ +typedef unsigned char uint8; +typedef unsigned short int uint16; +typedef unsigned long uint32; +typedef unsigned long long uint64; + +/* signed integer datatypes */ +typedef char int8; +typedef short int int16; +typedef long int32; +typedef long long int64; + + +/* float datatypes */ +typedef float float32; +typedef double float64; + +/* boolean datatypes and values */ +typedef char bool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/ +typedef bool boolean; +#ifndef TRUE + #define TRUE 1 +#endif +#ifndef FALSE + #define FALSE 0 +#endif + +/* + * typedefs for eTrice Runtime and Testing + * + * */ + +typedef int8 etInt8; +typedef int16 etInt16; +typedef int32 etInt32; + +typedef uint8 etUInt8; +typedef uint16 etUInt16; +typedef uint32 etUInt32; + +typedef bool etBool; + +typedef float32 etFloat32; +typedef float64 etFloat64; + +typedef FILE* etFileHandle; + +typedef int8 etAddressId; + +#endif /* _DATATYPES_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etGlobalFlags.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etGlobalFlags.h new file mode 100644 index 000000000..80b16b5b0 --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etGlobalFlags.h @@ -0,0 +1,17 @@ +/* + * etGlobalFlags.h + * + * Created on: 26.02.2012 + * Author: tschuetz + */ + +#ifndef ETGLOBALFLAGS_H_ +#define ETGLOBALFLAGS_H_ + +/* flags for debugging */ +#define ET_MSC_LOGGER_ACTIVATE /* needs ET_LOGGER_ACTIVATE */ +#define ET_LOGGER_ACTIVATE + + + +#endif /* ETGLOBALFLAGS_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etLogger.c index 13c2fea0a..9b20f31a3 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/etLogger.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etLogger.c @@ -1,78 +1,78 @@ -/*******************************************************************************
- * Copyright (c) 2011 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:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-/*
- * etLogger.c
- *
- * Created on: 16.01.2012
- * Author: tschuetz
- */
-
-
-#include "etLogger.h"
-
-#include <stdarg.h>
-
-
-void etLogger_logError(const char* message){
- printf("ERROR: %s\n", message);
-}
-
-void etLogger_logWarning(const char* message){
- printf("WARNING: %s\n", message);
-}
-
-void etLogger_logInfo(const char* message){
- printf("INFO: %s\n", message);
-}
-
-void etLogger_logErrorF(const char* format, ... ){
- printf("ERROR: ");
- va_list arglist;
- va_start( arglist, format );
- vprintf( format, arglist );
- va_end( arglist );
- printf("\n");
-}
-
-void etLogger_logWarningF(const char* format, ... ){
- printf("WARNING: ");
- va_list arglist;
- va_start( arglist, format );
- vprintf( format, arglist );
- va_end( arglist );
- printf("\n");
-}
-
-void etLogger_logInfoF(const char* format, ... ){
- printf("INFO: ");
- va_list arglist;
- va_start( arglist, format );
- vprintf( format, arglist );
- va_end( arglist );
- printf("\n");
-}
-
-etFileHandle etLogger_fopen(const char* filename, const char* mode){
- return( fopen(filename, mode) );
-}
-
-int etLogger_fclose(etFileHandle file){
- return( fclose(file) );
-}
-
-void etLogger_fprintf(etFileHandle file, const char* format, ... ){
- va_list arglist;
- va_start( arglist, format );
- vfprintf(file, format, arglist );
- va_end( arglist );
-}
+/******************************************************************************* + * Copyright (c) 2011 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: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +/* + * etLogger.c + * + * Created on: 16.01.2012 + * Author: tschuetz + */ + + +#include "debugging/etLogger.h" + +#include <stdarg.h> + + +void etLogger_logError(const char* message){ + printf("ERROR: %s\n", message); +} + +void etLogger_logWarning(const char* message){ + printf("WARNING: %s\n", message); +} + +void etLogger_logInfo(const char* message){ + printf("INFO: %s\n", message); +} + +void etLogger_logErrorF(const char* format, ... ){ + printf("ERROR: "); + va_list arglist; + va_start( arglist, format ); + vprintf( format, arglist ); + va_end( arglist ); + printf("\n"); +} + +void etLogger_logWarningF(const char* format, ... ){ + printf("WARNING: "); + va_list arglist; + va_start( arglist, format ); + vprintf( format, arglist ); + va_end( arglist ); + printf("\n"); +} + +void etLogger_logInfoF(const char* format, ... ){ + printf("INFO: "); + va_list arglist; + va_start( arglist, format ); + vprintf( format, arglist ); + va_end( arglist ); + printf("\n"); +} + +etFileHandle etLogger_fopen(const char* filename, const char* mode){ + return( fopen(filename, mode) ); +} + +int etLogger_fclose(etFileHandle file){ + return( fclose(file) ); +} + +void etLogger_fprintf(etFileHandle file, const char* format, ... ){ + va_list arglist; + va_start( arglist, format ); + vfprintf(file, format, arglist ); + va_end( arglist ); +} diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/info.txt b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/info.txt new file mode 100644 index 000000000..bcb721d20 --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/info.txt @@ -0,0 +1,2 @@ +This generic platform can be used for most 32 or 64 bit systems like windows and linux. +It uses standard c libraries only and it makes use of the file system. |