aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Montplaisir2012-03-23 13:26:25 (EDT)
committerFrancois Chouinard2012-03-27 13:52:24 (EDT)
commit5dea65a54b20bdf792e4a5a901e3bf67c9eac34f (patch)
treed7b45f34ad9e029e025425d594749278302a7e91
parent3b64b4e3caac38ab55a5fd20a8daed92e3ca5c74 (diff)
downloadorg.eclipse.linuxtools-5dea65a54b20bdf792e4a5a901e3bf67c9eac34f.zip
org.eclipse.linuxtools-5dea65a54b20bdf792e4a5a901e3bf67c9eac34f.tar.gz
org.eclipse.linuxtools-5dea65a54b20bdf792e4a5a901e3bf67c9eac34f.tar.xz
Add unit tests for the new getQuarks() method
Also handle the case where the wildcard character is the last element of the array (which mimics the behaviour of getSubAttributes()) Signed-off-by: Alexandre Montplaisir <alexandre.montplaisir@polymtl.ca>
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java25
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java6
2 files changed, 30 insertions, 1 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java b/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java
index 6ef8494..1c0be27 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java
@@ -315,6 +315,31 @@ public class StateSystemFullHistoryTest {
}
@Test
+ public void testGetQuarks_begin() {
+ List<Integer> list = shs.getQuarks("*", "1577", "Exec_name");
+
+ assertEquals(1, list.size());
+ assertEquals(Integer.valueOf(479), list.get(0));
+ }
+
+ @Test
+ public void testGetQuarks_middle() {
+ List<Integer> list = shs.getQuarks("Threads", "*", "Exec_name");
+
+ assertEquals(Integer.valueOf(36), list.get(4));
+ assertEquals(Integer.valueOf(100), list.get(10));
+ assertEquals(Integer.valueOf(116), list.get(12));
+ }
+
+ @Test
+ public void testGetQuarks_end() {
+ List<Integer> list = shs.getQuarks("Threads", "1577", "*");
+
+ assertEquals(3, list.size());
+ assertEquals(Integer.valueOf(479), list.get(1));
+ }
+
+ @Test
public void testDebugPrinting() throws FileNotFoundException {
shs.debugPrint(new PrintWriter(new File("/dev/null")));
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java
index 6ed9428..71baede 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java
@@ -207,11 +207,15 @@ final class AttributeTree {
*/
int getQuarkDontAdd(int startingNodeQuark, String... subPath)
throws AttributeNotFoundException {
- assert (subPath != null && subPath.length > 0);
assert (startingNodeQuark >= -1);
Attribute prevNode;
+ /* If subPath is empty, simply return the starting quark */
+ if (subPath == null || subPath.length == 0) {
+ return startingNodeQuark;
+ }
+
/* Get the "starting node" */
if (startingNodeQuark == -1) {
prevNode = attributeTreeRoot;