From d5afc9c0c42138ac147199ae60193899953869cb Mon Sep 17 00:00:00 2001 From: Thomas Schuetz Date: Mon, 30 Jan 2012 16:05:42 +0100 Subject: [generator.c.tests] moved testcases for C-generator to generator.c.tests --- .../org.eclipse.etrice.generator.c.tests/.cproject | 150 +++++++ .../.gitignore | 2 + .../org.eclipse.etrice.generator.c.tests/.project | 77 ++++ .../.settings/org.eclipse.cdt.codan.core.prefs | 66 +++ .../org.eclipse.cdt.managedbuilder.core.prefs | 22 + .../.settings/org.eclipse.cdt.ui.prefs | 3 + .../manualCGenLaunch.launch | 13 + .../model/CTypes.room | 21 + .../model/cGenRef.room | 178 ++++++++ .../model/diagrams/cGenRef.Broadcast.behavior | 458 +++++++++++++++++++++ .../model/diagrams/cGenRef.Broadcast.structure | 52 +++ .../model/diagrams/cGenRef.Receiver.structure | 36 ++ .../model/diagrams/cGenRef.SS.structure | 356 ++++++++++++++++ .../model/diagrams/cGenRef.Sender.structure | 36 ++ .../src-gen/cGenRef/CommunicationProtocol.c | 21 + .../src-gen/cGenRef/CommunicationProtocol.h | 50 +++ .../src-gen/cGenRef/DataClass1.c | 24 ++ .../src-gen/cGenRef/DataClass1.h | 33 ++ .../src-gen/cGenRef/DataClass2.c | 18 + .../src-gen/cGenRef/DataClass2.h | 25 ++ .../src-gen/readme.txt | 4 + .../src/RunAllTestcases.c | 30 ++ .../src/test/generator/RunCGeneratorTestcases.c | 30 ++ .../src/test/generator/RunCGeneratorTestcases.h | 26 ++ .../src/test/generator/TestDataClass.c | 67 +++ .../src/test/generator/TestDataClass.h | 26 ++ .../src/test/runtime/RunCRuntimeTestcases.c | 49 +++ .../src/test/runtime/RunCRuntimeTestcases.h | 26 ++ .../src/test/runtime/TestEtMessage.c | 45 ++ .../src/test/runtime/TestEtMessage.h | 20 + .../src/test/runtime/TestEtMessageQueue.c | 99 +++++ .../src/test/runtime/TestEtMessageQueue.h | 18 + .../src/test/runtime/TestEtMessageService.c | 116 ++++++ .../src/test/runtime/TestEtMessageService.h | 21 + .../src/test/runtime/TestEtUnit.c | 67 +++ .../src/test/runtime/TestEtUnit.h | 26 ++ .../tmp/testlog/TestCGenerator.xml | 6 + .../tmp/testlog/TestCRuntime.xml | 18 + .../tmp/testlog/TestEtUnitSpecial.xml | 5 + 39 files changed, 2340 insertions(+) create mode 100644 tests/org.eclipse.etrice.generator.c.tests/.cproject create mode 100644 tests/org.eclipse.etrice.generator.c.tests/.gitignore create mode 100644 tests/org.eclipse.etrice.generator.c.tests/.project create mode 100644 tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.codan.core.prefs create mode 100644 tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.managedbuilder.core.prefs create mode 100644 tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.ui.prefs create mode 100644 tests/org.eclipse.etrice.generator.c.tests/manualCGenLaunch.launch create mode 100644 tests/org.eclipse.etrice.generator.c.tests/model/CTypes.room create mode 100644 tests/org.eclipse.etrice.generator.c.tests/model/cGenRef.room create mode 100644 tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Broadcast.behavior create mode 100644 tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Broadcast.structure create mode 100644 tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Receiver.structure create mode 100644 tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.SS.structure create mode 100644 tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Sender.structure create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.c create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.h create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass1.c create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass1.h create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass2.c create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass2.h create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src-gen/readme.txt create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/RunAllTestcases.c create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.c create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.h create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.c create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.h create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.c create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.h create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.c create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.h create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageQueue.c create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageQueue.h create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.h create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtUnit.c create mode 100644 tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtUnit.h create mode 100644 tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCGenerator.xml create mode 100644 tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCRuntime.xml create mode 100644 tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestEtUnitSpecial.xml (limited to 'tests') diff --git a/tests/org.eclipse.etrice.generator.c.tests/.cproject b/tests/org.eclipse.etrice.generator.c.tests/.cproject new file mode 100644 index 000000000..f811adc92 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/.cproject @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.eclipse.etrice.generator.c.tests/.gitignore b/tests/org.eclipse.etrice.generator.c.tests/.gitignore new file mode 100644 index 000000000..0f3a6b1b9 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/.gitignore @@ -0,0 +1,2 @@ +Debug +Release diff --git a/tests/org.eclipse.etrice.generator.c.tests/.project b/tests/org.eclipse.etrice.generator.c.tests/.project new file mode 100644 index 000000000..d59cce925 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/.project @@ -0,0 +1,77 @@ + + + org.eclipse.etrice.generator.c.tests + + + org.eclipse.etrice.runtime.c + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/org.eclipse.etrice.generator.c.tests/Debug} + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.codan.core.prefs b/tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 000000000..9f5f4e439 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,66 @@ +#Mon Dec 26 18:56:09 CET 2011 +eclipse.preferences.version=1 +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={} +org.eclipse.cdt.codan.checkers.noreturn=Error +org.eclipse.cdt.codan.checkers.noreturn.params={implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={macro\=>true,exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} diff --git a/tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 000000000..dea3bcaa0 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,22 @@ +#Tue Dec 27 19:24:40 CET 2011 +eclipse.preferences.version=1 +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.54263550/CPATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.54263550/CPATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.54263550/C_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.54263550/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.54263550/append=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.54263550/appendContributed=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1445732435/CPATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1445732435/CPATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1445732435/C_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1445732435/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1445732435/append=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1445732435/appendContributed=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.54263550/LIBRARY_PATH/delimiter=; +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.54263550/LIBRARY_PATH/operation=remove +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.54263550/append=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.54263550/appendContributed=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1445732435/LIBRARY_PATH/delimiter=; +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1445732435/LIBRARY_PATH/operation=remove +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1445732435/append=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1445732435/appendContributed=true diff --git a/tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.ui.prefs b/tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.ui.prefs new file mode 100644 index 000000000..ea816250e --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/.settings/org.eclipse.cdt.ui.prefs @@ -0,0 +1,3 @@ +#Wed Jan 11 10:35:04 CET 2012 +eclipse.preferences.version=1 +formatter_settings_version=1 diff --git a/tests/org.eclipse.etrice.generator.c.tests/manualCGenLaunch.launch b/tests/org.eclipse.etrice.generator.c.tests/manualCGenLaunch.launch new file mode 100644 index 000000000..4472ae430 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/manualCGenLaunch.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/tests/org.eclipse.etrice.generator.c.tests/model/CTypes.room b/tests/org.eclipse.etrice.generator.c.tests/model/CTypes.room new file mode 100644 index 000000000..9c76a085e --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/model/CTypes.room @@ -0,0 +1,21 @@ +RoomModel room.basic.types.c { + + PrimitiveType boolean -> boolean (boolean) default "FALSE" + PrimitiveType char -> char (char) default "0" + PrimitiveType int8 -> int8 (int8) default "0" + PrimitiveType int16 -> int16 (int16) default "0" + PrimitiveType int32 -> int32 (int32) default "0" + PrimitiveType int64 -> int64 (int64) default "0" + + PrimitiveType uint8 -> uint8 (uint8) default "0" + PrimitiveType uint16 -> uint16 (uint16) default "0" + PrimitiveType uint32 -> uint32 (uint32) default "0" + PrimitiveType uint64 -> uint64 (uint64) default "0" + + PrimitiveType float32 -> float32 (float32) default "0" + PrimitiveType float64 -> float64 (float64) default "0" + + // TODO: define strings for C + // PrimitiveType string -> string (String) default "\"\"" + +} \ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.c.tests/model/cGenRef.room b/tests/org.eclipse.etrice.generator.c.tests/model/cGenRef.room new file mode 100644 index 000000000..c1ec04d23 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/model/cGenRef.room @@ -0,0 +1,178 @@ +RoomModel cGenRef { + import room.basic.types.c.* from "CTypes.room" + + SubSystemClass SS { + ActorRef Receiver: Receiver + ActorRef Sender: Sender + ActorRef Broadcast: Broadcast + ActorRef Receiver2: Receiver + ActorRef ref0: Broadcast + ActorRef ref1: Broadcast + ActorRef ref2: Receiver + ActorRef ref3: Receiver + Binding Sender.dataOut and Broadcast.dataIn + Binding Broadcast.dataOut and ref0.dataIn + Binding Broadcast.dataOut and ref1.dataIn + Binding Receiver.dataIn and ref0.dataOut + Binding Receiver2.dataIn and ref0.dataOut + Binding ref2.dataIn and ref1.dataOut + Binding ref3.dataIn and ref1.dataOut + } + + ActorClass Receiver { + Interface { + Port dataIn: CommunicationProtocol + } + Structure { + external Port dataIn + Attribute attr1: DataClass1 + } + Behavior { + StateMachine { + Transition init: initial -> Idle { } + Transition tr0: Idle -> DataReceived { + triggers { + + } + action { + "dataIn.receivedData();" + } + } + State Idle + State DataReceived + } + } + } + + ActorClass Broadcast { + Interface { + Port dataIn: CommunicationProtocol + conjugated Port dataOut [2]: CommunicationProtocol + } + Structure { + external Port dataIn + external Port dataOut + } + Behavior { + StateMachine { + Transition init: initial -> Idle { } + Transition tr0: Idle -> tp0 of Sending { + triggers { + + } + action { + "//dataOut.get(0).sendData(data);" + "//dataOut.get(1).sendData(data);" + "dataOut.sendData(data);" + } + } + Transition tr1: tp1 of Sending -> ReceivedBoth { + action { + "dataIn.receivedData();" + } + } + State Idle + State Sending { + subgraph { + Transition tr0: my tp0 -> WaitingForReceived + Transition tr1: WaitingForReceived -> ReceivedOne { + triggers { + + } + } + Transition tr2: WaitingForReceived -> ReceivedTheOther { + triggers { + + } + } + Transition tr3: ReceivedOne -> my tp1 { + triggers { + + } + } + Transition tr4: ReceivedTheOther -> my tp1 { + triggers { + + } + } + EntryPoint tp0 + ExitPoint tp1 + State WaitingForReceived + State ReceivedOne + State ReceivedTheOther + } + } + State ReceivedBoth + } + } + } + + ActorClass Sender { + Interface { + conjugated Port dataOut: CommunicationProtocol + } + Structure { + external Port dataOut + } + Behavior { + StateMachine { + Transition init: initial -> SendingData { } + Transition tr0: SendingData -> Done { + triggers { + + } + } + State SendingData { + entry { + "dataOut.sendData(1234);" + } + } + State Done + } + } + } + + ProtocolClass CommunicationProtocol { + incoming { + Message sendData(data: int32) + Message sendData2(data: DataClass1) + + } + outgoing { + Message receivedData() + } + } + + + DataClass DataClass1 { + usercode1 {"// usercode1"} + usercode2 {"// usercode2"} + usercode3 {"// usercode3"} + Attribute Attr1: int32 + Attribute ComplexAttr: DataClass2 + Attribute Attr3: float32 + + Operation MultiplyWithAttr1(value: int32): int32 { + "return self->Attr1*value;" + } + Operation MultiplyWithAttr3(value: float32): float32 { + "return self->Attr3*value;" + } + } + + DataClass DataClass2 { + Attribute Attr1: int32 + Attribute Attr2: float32 + Attribute Attr3: int32 + Operation Operation1(): void {"/*nothing to do*/"} + } + +} \ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Broadcast.behavior b/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Broadcast.behavior new file mode 100644 index 000000000..5fb0a165b --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Broadcast.behavior @@ -0,0 +1,458 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Broadcast.structure b/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Broadcast.structure new file mode 100644 index 000000000..e588b0c21 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Broadcast.structure @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Receiver.structure b/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Receiver.structure new file mode 100644 index 000000000..dffdfb858 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Receiver.structure @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.SS.structure b/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.SS.structure new file mode 100644 index 000000000..93082cde0 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.SS.structure @@ -0,0 +1,356 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Sender.structure b/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Sender.structure new file mode 100644 index 000000000..d39809681 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/model/diagrams/cGenRef.Sender.structure @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.c b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.c new file mode 100644 index 000000000..22bc04cec --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.c @@ -0,0 +1,21 @@ +#include "CommunicationProtocol.h" + +/*--------------------- port classes */ + + + +/*--------------------- debug helpers */ + +/* TODO: make this optional or different for smaller footprint */ +/* message names as strings for debugging (generate MSC) */ +static const char* CommunicationProtocol_messageStrings[] = {"MIN", "receivedData","sendData", "sendData2", "MAX"}; + +const char* CommunicationProtocol_getMessageString(int msg_id) { + if (msg_idCommunicationProtocol_MSG_MAX+1){ + /* id out of range */ + return "Message ID out of range"; + } + else{ + return CommunicationProtocol_messageStrings[msg_id]; + } +} diff --git a/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.h b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.h new file mode 100644 index 000000000..937c181f6 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.h @@ -0,0 +1,50 @@ +#ifndef _CommunicationProtocol_H_ +#define _CommunicationProtocol_H_ + +#include "etDatatypes.h" + + +#include "DataClass1.h" + +typedef struct { + + +} CommunicationProtocol; + +/* message IDs */ +enum { + CommunicationProtocol_MSG_MIN = 0, + /* IDs for outgoing messages */ + CommunicationProtocol_OUT_receivedData = 1, + /* IDs for incoming messages */ + CommunicationProtocol_IN_sendData = 2, + CommunicationProtocol_IN_sendData2 = 3, + /* error if msgID >= MSG_MAX */ + CommunicationProtocol_MSG_MAX = 4 +}; + +/*--------------------- port classes */ + +typedef struct etPort CommunicationProtocolPort; + +void CommunicationProtocolPort_MyOperation1(CommunicationProtocolPort* self, int a, int b); +int CommunicationProtocolPort_MyOperation2(CommunicationProtocolPort* self); + + + +typedef struct etPort CommunicationProtocolConjPort; + +void CommunicationProtocolConjPort_MyOperation1(CommunicationProtocolConjPort* self, int a, int b); +int CommunicationProtocolConjPort_MyOperation2(CommunicationProtocolConjPort* self); + + + +/*--------------------- debug helpers */ + +/* get message string for message id */ +const char* CommunicationProtocol_getMessageString(int msg_id); + + + +#endif /* _CommunicationProtocol_H_ */ + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass1.c b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass1.c new file mode 100644 index 000000000..d4235dbc3 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass1.c @@ -0,0 +1,24 @@ +#include "DataClass1.h" + +#include + +//--------------------- begin user code + // usercode3 +//--------------------- end user code + +// TODO: do we need setters and getters for C and C++ ? + +//--------------------- operations +int32 DataClass1_MultiplyWithAttr1(DataClass1* self, int32 value) { + return self->Attr1*value; +} +float32 DataClass1_MultiplyWithAttr3(DataClass1* self, float32 value) { + return self->Attr3*value; +} + +// deep copy +void DataClass1_deepCopy(DataClass1* source, DataClass1* target) { + memcpy(target, source, sizeof(DataClass1)); +} + + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass1.h b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass1.h new file mode 100644 index 000000000..dbf8dee81 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass1.h @@ -0,0 +1,33 @@ +#ifndef _DataClass1_H_ +#define _DataClass1_H_ + +#include "etDatatypes.h" + +/* TODO: includes only for used DataClasses, also for other models */ +#include "DataClass2.h" + +//--------------------- begin user code + // usercode1 +//--------------------- end user code + +typedef struct { + //--------------------- begin user code + // usercode2 + //--------------------- end user code + //--------------------- attributes + int32 Attr1; + DataClass2 ComplexAttr; + float32 Attr3; +} DataClass1; + +// TODO: do we need setters and getters for C and C++ ? + +//--------------------- operations +int32 DataClass1_MultiplyWithAttr1(DataClass1* self, int32 value); +float32 DataClass1_MultiplyWithAttr3(DataClass1* self, float32 value); + +// deep copy +void DataClass1_deepCopy(DataClass1* source, DataClass1* target); + +#endif /* _DataClass1_H_ */ + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass2.c b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass2.c new file mode 100644 index 000000000..2150d7b41 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass2.c @@ -0,0 +1,18 @@ +#include "DataClass2.h" + +#include + + +// TODO: do we need setters and getters for C and C++ ? + +//--------------------- operations +void DataClass2_Operation1(DataClass2* self) { + /*nothing to do*/ +} + +// deep copy +void DataClass2_deepCopy(DataClass2* source, DataClass2* target) { + memcpy(target, source, sizeof(DataClass2)); +} + + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass2.h b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass2.h new file mode 100644 index 000000000..2d8cbb74f --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/DataClass2.h @@ -0,0 +1,25 @@ +#ifndef _DataClass2_H_ +#define _DataClass2_H_ + +#include "etDatatypes.h" + +/* TODO: includes only for used DataClasses, also for other models */ + + +typedef struct { + //--------------------- attributes + int32 Attr1; + float32 Attr2; + int32 Attr3; +} DataClass2; + +// TODO: do we need setters and getters for C and C++ ? + +//--------------------- operations +void DataClass2_Operation1(DataClass2* self); + +// deep copy +void DataClass2_deepCopy(DataClass2* source, DataClass2* target); + +#endif /* _DataClass2_H_ */ + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src-gen/readme.txt b/tests/org.eclipse.etrice.generator.c.tests/src-gen/readme.txt new file mode 100644 index 000000000..1dc2b35ab --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src-gen/readme.txt @@ -0,0 +1,4 @@ +This directory is an eTrice code generation target. +It will be erased every time the generator is executed. + +DO NOT PLACE OTHER FILES HERE! diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/RunAllTestcases.c b/tests/org.eclipse.etrice.generator.c.tests/src/RunAllTestcases.c new file mode 100644 index 000000000..c21cc4074 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/RunAllTestcases.c @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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 + +#include "test/generator/RunCGeneratorTestcases.h" +#include "test/runtime/RunCRuntimeTestcases.h" + +void runTestCases(void); + +int main(void){ + runTestCases(); + return 0; +} + + +void runTestCases(void){ + RunCGeneratorTestcases(); + RunCRuntimeTestcases(); +} + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.c new file mode 100644 index 000000000..cf2d11e9c --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.c @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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) + * + *******************************************************************************/ + +/* + * RunCGeneratorTestcases.c + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + +#include "RunCGeneratorTestcases.h" + +#include "TestDataClass.h" +#include "etUnit.h" + + +void RunCGeneratorTestcases(void){ + etUnit_open("tmp/testlog","TestCGenerator"); + TestDataClass_runSuite(); + etUnit_close(); +} diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.h b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.h new file mode 100644 index 000000000..03d5c4276 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.h @@ -0,0 +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) + * + *******************************************************************************/ + + +/* + * RunCGeneratorTestcases.h + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + +#ifndef _RUNCGENERATORTESTCASES_H_ +#define _RUNCGENERATORTESTCASES_H_ + +void RunCGeneratorTestcases(void); + +#endif /* _RUNCGENERATORTESTCASES_H_ */ diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.c new file mode 100644 index 000000000..e3c521dd3 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.c @@ -0,0 +1,67 @@ +/******************************************************************************* + * 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) + * + *******************************************************************************/ + + +/* + * TestDataClass.c + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + + +#include "TestDataClass.h" + +#include "etUnit.h" + +#include "../../../src-gen/cGenRef/DataClass1.h" + +void TestDataClass_Operations(void){ + + DataClass1 d; + d.Attr1 = 123; + d.ComplexAttr.Attr1 = 456; + d.ComplexAttr.Attr2 = (float32)789.123; + d.ComplexAttr.Attr3 = 789; + d.Attr3 = (float32)321.123; + + EXPECT_EQUAL_INT32("Operation DataClass1_MultiplyWithAttr1", 246, DataClass1_MultiplyWithAttr1(&d, 2)); + EXPECT_EQUAL_FLOAT32("Operation DataClass1_MultiplyWithAttr3", (float32)642.246, DataClass1_MultiplyWithAttr3(&d, 2), (float32)0.0001); + +} + + +void TestDataClass_testDataClassDeepCopy(void){ + + DataClass1 d, e; + d.Attr1 = 123; + d.ComplexAttr.Attr1 = 456; + d.ComplexAttr.Attr2 = (float32)789.123; + d.ComplexAttr.Attr3 = 789; + d.Attr3 = (float32)321.123; + + DataClass1_deepCopy(&d,&e); + + EXPECT_EQUAL_INT32("Attr1", 123, e.Attr1); + EXPECT_EQUAL_INT32("ComplexAttr.Attr1", 456, e.ComplexAttr.Attr1); + EXPECT_EQUAL_FLOAT32("ComplexAttr.Attr2", (float32)789.123, e.ComplexAttr.Attr2, 0.001f); + EXPECT_EQUAL_INT32("ComplexAttr.Attr3", 789, e.ComplexAttr.Attr3); + EXPECT_EQUAL_FLOAT32("Attr3", (float32)321.123, e.Attr3, (float32)0.0001); + +} + +void TestDataClass_runSuite(void){ + etUnit_openTestSuite("TestDataClass"); + ADD_TESTCASE(TestDataClass_Operations); + ADD_TESTCASE(TestDataClass_testDataClassDeepCopy); + etUnit_closeTestSuite(); +} diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.h b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.h new file mode 100644 index 000000000..3cbce4bc1 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.h @@ -0,0 +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) + * + *******************************************************************************/ + + +/* + * TestEmDataClass.h + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + +#ifndef _TESTDATACLASS_H_ +#define _TESTDATACLASS_H_ + +void TestDataClass_runSuite(void); + +#endif /* _TESTDATACLASS_H_ */ diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.c new file mode 100644 index 000000000..a9a502f3b --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.c @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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) + * + *******************************************************************************/ + + +/* + * RunRuntimeTestcases.c + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + + + +#include "RunCRuntimeTestcases.h" + +#include "TestEtMessage.h" +#include "TestEtMessageQueue.h" +#include "TestEtMessageService.h" +#include "TestEtUnit.h" + +#include "etUnit.h" + + +void RunCRuntimeTestcases(void){ + etUnit_open("tmp/testlog","TestCRuntime"); + + TestEtMessage_runSuite(); + TestEtMessageQueue_runSuite(); + TestEtMessageService_runSuite(); + TestEtUnit_runSuite(); + + etUnit_close(); + + /* special situation for testing openAll and closeAll of etUnit + * this has to be done outside of etUnit_open and etUnit_close */ + etUnit_openAll("tmp/testlog","TestEtUnitSpecial", "etUnit", "openAll and closeAll"); + EXPECT_TRUE("Open and Close", TRUE); + etUnit_closeAll(); +} + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.h b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.h new file mode 100644 index 000000000..5d17f7ddb --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.h @@ -0,0 +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) + * + *******************************************************************************/ + + +/* + * RunRuntimeTestcases.h + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + +#ifndef _RUNCRUNTIMETESTCASES_H_ +#define _RUNCRUNTIMETESTCASES_H_ + +void RunCRuntimeTestcases(void); + +#endif /* _RUNCRUNTIMETESTCASES_H_ */ diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.c new file mode 100644 index 000000000..c360b0a84 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.c @@ -0,0 +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) + * + *******************************************************************************/ + +#include "TestEtMessage.h" + +#include +#include "etUnit.h" +#include "etMessage.h" + + + +void TestEtMessage_testBasicMessage(void){ + + etMessage msg1 = {(etMessage*)1234567, 123,456,}; + etMessage msg2 = {NULL, 222,333}; + + // basic checks -> detects structure changes that would cause problems for generated code + EXPECT_EQUAL_PTR("Message.next", 1234567, msg1.next); + EXPECT_EQUAL_INT16("Message.address", 123, msg1.address); + EXPECT_EQUAL_INT16("Message.evtID", 456, msg1.evtID); + + // build pointer ring + msg1.next = &msg2; + msg2.next = &msg1; + + EXPECT_EQUAL_INT16("msg1.NextMsg", msg2.evtID, msg1.next->evtID); + EXPECT_EQUAL_INT16("msg2.NextMsg", msg1.evtID, msg2.next->evtID); + +} + +void TestEtMessage_runSuite(void){ + etUnit_openTestSuite("TestMessage"); + ADD_TESTCASE(TestEtMessage_testBasicMessage); + etUnit_closeTestSuite(); +} + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.h b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.h new file mode 100644 index 000000000..67b45e4e1 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.h @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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 _TESTMESSAGE_H_ +#define _TESTMESSAGE_H_ + + +void TestEtMessage_runSuite(void); + + +#endif /* _TESTMESSAGE_H_ */ diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageQueue.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageQueue.c new file mode 100644 index 000000000..3a453962c --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageQueue.c @@ -0,0 +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 "TestEtMessageQueue.h" +#include "etUnit.h" +#include "etMessageQueue.h" + +void TestEtMessageQueue_testPushPop(void){ + + etMessage msg1 = {NULL, 123, 456}; + etMessage msg2 = {NULL, 222, 333}; + + etMessageQueue queue1; + etMessageQueue_init(&queue1); + + etMessageQueue_push(&queue1, &msg1); + etMessageQueue_push(&queue1, &msg2); + + EXPECT_EQUAL_INT16("etMessageQueue.size before", 2, queue1.size); + EXPECT_EQUAL_INT16("etMessageQueue.highWaterMark before", 2, queue1.highWaterMark); + + etMessage* rcvMsg1 = etMessageQueue_pop(&queue1); + etMessage* rcvMsg2 = etMessageQueue_pop(&queue1); + + EXPECT_EQUAL_INT16("etMessageQueue.size after", 0, queue1.size); + EXPECT_EQUAL_INT16("etMessageQueue.highWaterMark after", 2, queue1.highWaterMark); + + EXPECT_EQUAL_INT16("rcvMsg1->address", 123, rcvMsg1->address); + EXPECT_EQUAL_INT16("rcvMsg1->evtID", 456, rcvMsg1->evtID); + EXPECT_EQUAL_PTR("rcvMsg1->next", NULL, rcvMsg1->next); + + EXPECT_EQUAL_INT16("rcvMsg2->address", 222, rcvMsg2->address); + EXPECT_EQUAL_INT16("rcvMsg2->evtID", 333, rcvMsg2->evtID); + EXPECT_EQUAL_PTR("rcvMsg2->next", NULL, rcvMsg2->next); + + EXPECT_EQUAL_PTR("etMessageQueue->first", NULL, queue1.first); + EXPECT_EQUAL_PTR("etMessageQueue->last", NULL, queue1.last); + + etMessage* rcvMsg3 = etMessageQueue_pop(&queue1); + EXPECT_EQUAL_PTR("etMessageQueue_pop if empty", NULL, rcvMsg3); + +} + +#define MAX 1000 + +void TestEtMessageQueue_testMassiveMessaging(void){ + + etMessage msgArray[MAX]; + + etMessageQueue queue1; + etMessageQueue_init(&queue1); + + int16 i; + for(i=0; i