Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-11-11 06:52:06 -0500
committerHenrik Rentz-Reichert2011-11-11 06:52:06 -0500
commit6343bc722f2fe0c2ca6d65560a5e09c200c940b6 (patch)
tree5e1936d05d14feda554ac10b83ffa3058281e959
parent381122d528c9d122f8f6dfe2fa5c3e2eab81e550 (diff)
downloadorg.eclipse.etrice-6343bc722f2fe0c2ca6d65560a5e09c200c940b6.tar.gz
org.eclipse.etrice-6343bc722f2fe0c2ca6d65560a5e09c200c940b6.tar.xz
org.eclipse.etrice-6343bc722f2fe0c2ca6d65560a5e09c200c940b6.zip
[integration.tests] added some debug code
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java2
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java28
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/TestSemaphore.java45
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/base/IntegrationTestBase.java8
4 files changed, 65 insertions, 18 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
index 8ec213054..bbcf6e892 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
@@ -40,6 +40,8 @@ public class MessageService extends Thread implements IMessageReceiver,
public MessageService(IRTObject parent, Address addr, String name, int priority) {
+ super("MessageService "+name);
+
this.parent = parent;
address = addr;
this.name = name;
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
index 765a12f6e..52fc4b7a1 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
@@ -8,8 +8,6 @@
package org.eclipse.etrice.runtime.java.modelbase;
-import java.util.concurrent.Semaphore;
-
import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
import org.eclipse.etrice.runtime.java.messaging.MessageService;
@@ -31,7 +29,7 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
//--------------------- interface item IDs
protected static final int IFITEM_RTSystemPort = 0;
protected ActorClassBase[] instances = null;
- private Semaphore testSem=null;
+ private TestSemaphore testSem=null;
private int testErrorCode;
public SubSystemClassBase(IRTObject parent, String name) {
@@ -127,7 +125,7 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
}
// this is to run integration tests
- public synchronized void setTestSemaphore(Semaphore sem){
+ public synchronized void setTestSemaphore(TestSemaphore sem){
testErrorCode = -1;
testSem=sem;
}
@@ -136,19 +134,17 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
return testErrorCode;
}
- public synchronized void testFinished(int errorCode){
+ public void testFinished(int errorCode){
if (testSem != null) {
- testErrorCode = errorCode;
- testSem.release(1);
-
- // TODO: TS: if the non deterministic errors in integration.tests are fixed, please delete this work around!
- // making this thread sleep seems to fix a problem that the tester thread doesn't
- // acquire control before the test timeout is reached
-// try {
-// Thread.sleep(100);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// }
+ System.out.println("org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase.testFinished(int): before releasing semaphore");
+ testSem.printWaitingThreads();
+ synchronized (this) {
+ testErrorCode = errorCode;
+ testSem.release(1);
+ }
+ System.out.println("org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase.testFinished(int): semaphore released");
+ //testSem.printWaitingThreads();
+ Thread.yield();
}
}
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/TestSemaphore.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/TestSemaphore.java
new file mode 100644
index 000000000..973db66a9
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/TestSemaphore.java
@@ -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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.runtime.java.modelbase;
+
+import java.util.Collection;
+import java.util.concurrent.Semaphore;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class TestSemaphore extends Semaphore {
+
+ private static final long serialVersionUID = -2067749220670716523L;
+
+ /**
+ * @param permits
+ */
+ public TestSemaphore(int permits) {
+ super(permits);
+ }
+
+ public void printWaitingThreads() {
+ System.out.println("=== begin semaphore info ===");
+ System.out.println("current thread is "+Thread.currentThread().getName());
+ Collection<Thread> threads = getQueuedThreads();
+ if (threads.isEmpty())
+ System.out.println(" no waiting threads");
+ else
+ for (Thread thread : threads) {
+ System.out.println(" "+thread.getName());
+ }
+ System.out.println("=== end semaphore info ===");
+ }
+}
diff --git a/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/base/IntegrationTestBase.java b/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/base/IntegrationTestBase.java
index e4909436c..8ec2f1437 100644
--- a/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/base/IntegrationTestBase.java
+++ b/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/base/IntegrationTestBase.java
@@ -2,18 +2,22 @@ package org.eclipse.etrice.integration.tests.base;
import java.util.concurrent.Semaphore;
+import org.eclipse.etrice.runtime.java.modelbase.TestSemaphore;
+
public class IntegrationTestBase {
- protected Semaphore testSem = new Semaphore(0);
+ protected TestSemaphore testSem = new TestSemaphore(0);
public IntegrationTestBase() {
super();
}
// TODO: is this the right place here? -> the functionality is scattered between IntegrationTestBase and SubSystemClassBase
- protected synchronized void waitForTestcase() {
+ protected void waitForTestcase() {
try{
+ System.out.println("=== waitForTestcase: before acq. semaphore, thread "+Thread.currentThread().getName());
this.testSem.acquire(1);
+ System.out.println("=== waitForTestcase: after acq. semaphore, thread "+Thread.currentThread().getName());
}catch(InterruptedException e){
System.out.println("Semaphore fault !");
}

Back to the top