diff options
author | Alexandre Montplaisir | 2012-03-23 17:26:25 +0000 |
---|---|---|
committer | Francois Chouinard | 2012-03-27 17:52:24 +0000 |
commit | 5dea65a54b20bdf792e4a5a901e3bf67c9eac34f (patch) | |
tree | d7b45f34ad9e029e025425d594749278302a7e91 | |
parent | 3b64b4e3caac38ab55a5fd20a8daed92e3ca5c74 (diff) | |
download | org.eclipse.linuxtools-5dea65a54b20bdf792e4a5a901e3bf67c9eac34f.tar.gz org.eclipse.linuxtools-5dea65a54b20bdf792e4a5a901e3bf67c9eac34f.tar.xz org.eclipse.linuxtools-5dea65a54b20bdf792e4a5a901e3bf67c9eac34f.zip |
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>
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 6ef8494114..1c0be2755c 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 6ed942816d..71baedee45 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; |