Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Chouinard2012-07-18 20:14:16 +0000
committerPatrick Tasse2012-07-19 22:26:48 +0000
commit2e7e8fbdd69f6060a793885aab56f6f418d3017d (patch)
tree7133b279622d015a1d286a299e431621aa5c88aa
parent9ca995aef2ee7fc3e302a9f3fc0a2525688dccbe (diff)
downloadorg.eclipse.linuxtools-2e7e8fbdd69f6060a793885aab56f6f418d3017d.tar.gz
org.eclipse.linuxtools-2e7e8fbdd69f6060a793885aab56f6f418d3017d.tar.xz
org.eclipse.linuxtools-2e7e8fbdd69f6060a793885aab56f6f418d3017d.zip
Add test cases for Bug385432
Change-Id: I29602c425b71a81fa51633b4317b062266c8a56b Signed-off-by: Francois Chouinard <fchouinard@gmail.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedDataRequestTest.java12
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java84
2 files changed, 50 insertions, 46 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedDataRequestTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedDataRequestTest.java
index 9a196f1679..4d72b8eb5e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedDataRequestTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedDataRequestTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
+ * Copyright (c) 2009, 2010, 2012 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -8,11 +8,11 @@
*
* Contributors:
* Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Added tests to check offsets
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.tests.request;
-
import junit.framework.TestCase;
import org.eclipse.linuxtools.internal.tmf.core.request.TmfCoalescedDataRequest;
@@ -21,8 +21,6 @@ import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.tests.stubs.request.TmfDataRequestStub;
/**
- * <b><u>TmfCoalescedDataRequestTest</u></b>
- * <p>
* Test suite for the TmfCoalescedDataRequest class.
*/
@SuppressWarnings({ "nls" })
@@ -502,11 +500,7 @@ public class TmfCoalescedDataRequestTest extends TestCase {
assertTrue ("handleCompleted", crFlags[0]);
assertFalse("handleSuccess", crFlags[1]);
assertFalse("handleFailure", crFlags[2]);
- assertTrue ("handleCancel", crFlags[3]);
+ assertTrue ("handleCancel", crFlags[3]);
}
- // ------------------------------------------------------------------------
- // waitForCompletion
- // ------------------------------------------------------------------------
-
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java
index d058342ef7..acc606e49b 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java
@@ -424,10 +424,6 @@ public class TmfCoalescedEventRequestTest extends TestCase {
}
// ------------------------------------------------------------------------
- // waitForCompletion
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
// Coalescing
// ------------------------------------------------------------------------
@@ -467,21 +463,22 @@ public class TmfCoalescedEventRequestTest extends TestCase {
private static class TmfTestTriggerSignal extends TmfSignal {
public final boolean forceCancel;
- public TmfTestTriggerSignal(Object source, boolean cancel) {
+ public final long fIndex;
+ public TmfTestTriggerSignal(Object source, long index, boolean cancel) {
super(source);
forceCancel = cancel;
-
+ fIndex = index;
}
}
- @SuppressWarnings("unchecked")
@TmfSignalHandler
+ @SuppressWarnings("unchecked")
public void trigger(final TmfTestTriggerSignal signal) {
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
requestedEvents1 = new Vector<TmfEvent>();
- request1 = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ request1 = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, signal.fIndex, NB_EVENTS, BLOCK_SIZE) {
int nbRead = 0;
@Override
public void handleData(TmfEvent event) {
@@ -496,7 +493,7 @@ public class TmfCoalescedEventRequestTest extends TestCase {
};
requestedEvents2 = new Vector<TmfEvent>();
- request2 = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ request2 = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, signal.fIndex, NB_EVENTS, BLOCK_SIZE) {
@Override
public void handleData(TmfEvent event) {
super.handleData(event);
@@ -507,7 +504,7 @@ public class TmfCoalescedEventRequestTest extends TestCase {
};
requestedEvents3 = new Vector<TmfEvent>();
- request3 = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ request3 = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, signal.fIndex, NB_EVENTS, BLOCK_SIZE) {
@Override
public void handleData(TmfEvent event) {
super.handleData(event);
@@ -523,41 +520,50 @@ public class TmfCoalescedEventRequestTest extends TestCase {
providers[0].sendRequest(request3);
}
- public void testCoalescedRequest() throws Exception {
+ public void runCoalescedRequest(long startIndex) throws Exception {
- fTrace = setupTrace(DIRECTORY + File.separator + TEST_STREAM);
+ fTrace = setupTrace(DIRECTORY + File.separator + TEST_STREAM);
- TmfSignalManager.register(this);
- TmfTestTriggerSignal signal = new TmfTestTriggerSignal(this, false);
- TmfSignalManager.dispatchSignal(signal);
+ TmfSignalManager.register(this);
+ TmfTestTriggerSignal signal = new TmfTestTriggerSignal(this, startIndex, false);
+ TmfSignalManager.dispatchSignal(signal);
request1.waitForCompletion();
request2.waitForCompletion();
request3.waitForCompletion();
- assertEquals("Request1: nbEvents", NB_EVENTS, requestedEvents1.size());
- assertTrue ("Request1: isCompleted", request1.isCompleted());
- assertFalse ("Request1: isCancelled", request1.isCancelled());
-
- assertEquals("Request2: nbEvents", NB_EVENTS, requestedEvents2.size());
- assertTrue ("Request2: isCompleted", request2.isCompleted());
- assertFalse ("Request2: isCancelled", request2.isCancelled());
-
- assertEquals("Request3: nbEvents", NB_EVENTS, requestedEvents3.size());
- assertTrue ("Request3: isCompleted", request3.isCompleted());
- assertFalse ("Request3: isCancelled", request3.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < NB_EVENTS; i++) {
- assertEquals("Distinct events", i+1, requestedEvents1.get(i).getTimestamp().getValue());
- assertEquals("Distinct events", i+1, requestedEvents2.get(i).getTimestamp().getValue());
- assertEquals("Distinct events", i+1, requestedEvents3.get(i).getTimestamp().getValue());
+ try {
+ assertEquals("Request1: nbEvents", NB_EVENTS - startIndex, requestedEvents1.size());
+ assertTrue ("Request1: isCompleted", request1.isCompleted());
+ assertFalse ("Request1: isCancelled", request1.isCancelled());
+
+ assertEquals("Request2: nbEvents", NB_EVENTS - startIndex, requestedEvents2.size());
+ assertTrue ("Request2: isCompleted", request2.isCompleted());
+ assertFalse ("Request2: isCancelled", request2.isCancelled());
+
+ assertEquals("Request3: nbEvents", NB_EVENTS - startIndex, requestedEvents3.size());
+ assertTrue ("Request3: isCompleted", request3.isCompleted());
+ assertFalse ("Request3: isCancelled", request3.isCancelled());
+
+ // Ensure that we have distinct events.
+ // Don't go overboard: we are not validating the stub!
+ for (int i = 0; i < NB_EVENTS - startIndex; i++) {
+ assertEquals("Distinct events", i + 1 + startIndex, requestedEvents1.get(i).getTimestamp().getValue());
+ assertEquals("Distinct events", i + 1 + startIndex, requestedEvents2.get(i).getTimestamp().getValue());
+ assertEquals("Distinct events", i + 1 + startIndex, requestedEvents3.get(i).getTimestamp().getValue());
+ }
+ }
+ finally {
+ TmfSignalManager.deregister(this);
+ fTrace.dispose();
+ fTrace = null;
}
+ }
- TmfSignalManager.deregister(this);
- fTrace.dispose();
- fTrace = null;
+ public void testCoalescedRequest() throws Exception {
+ runCoalescedRequest(0);
+ runCoalescedRequest(1);
+ runCoalescedRequest(5);
}
public void testCancelCoalescedRequest() throws Exception {
@@ -565,7 +571,7 @@ public class TmfCoalescedEventRequestTest extends TestCase {
fTrace = setupTrace(DIRECTORY + File.separator + TEST_STREAM);
TmfSignalManager.register(this);
- TmfTestTriggerSignal signal = new TmfTestTriggerSignal(this, true);
+ TmfTestTriggerSignal signal = new TmfTestTriggerSignal(this, 0, true);
TmfSignalManager.dispatchSignal(signal);
request1.waitForCompletion();
@@ -596,4 +602,8 @@ public class TmfCoalescedEventRequestTest extends TestCase {
fTrace = null;
}
+ // ------------------------------------------------------------------------
+ //
+ // ------------------------------------------------------------------------
+
}

Back to the top