+ long time1 = interestingTimestamp1;
+ long time2 = time1 + 1L * CtfTestFiles.NANOSECS_PER_SEC;
+ int quark;
+ List<ITmfStateInterval> intervals;
+
+ quark = ssq.getQuarkAbsolute(Attributes.CPUS, "0", Attributes.CURRENT_THREAD);
+ intervals = ssq.queryHistoryRange(quark, time1, time2);
+ assertEquals(487, intervals.size()); /* Number of context switches! */
+ assertEquals(1685, intervals.get(100).getStateValue().unboxInt());
+ assertEquals(1331668248427681372L, intervals.get(205).getEndTime());
+ }
+
+ /**
+ * Range query, but with a t2 far off the end of the trace.
+ * The result should still be valid.
+ */
+ @Test
+ public void testRangeQuery2() throws TimeRangeException,
+ AttributeNotFoundException {
+
+ List<ITmfStateInterval> intervals;
+
+ int quark = ssq.getQuarkAbsolute(Attributes.RESOURCES, Attributes.IRQS, "1");
+ long ts1 = ssq.getStartTime(); /* start of the trace */
+ long ts2 = CtfTestFiles.startTime + 20L * CtfTestFiles.NANOSECS_PER_SEC; /* invalid, but ignored */
+
+ intervals = ssq.queryHistoryRange(quark, ts1, ts2);
+
+ /* Activity of IRQ 1 over the whole trace */
+ assertEquals(65, intervals.size());
+ }
+
+ /**
+ * Test a range query with a resolution
+ */
+ @Test
+ public void testRangeQuery3() throws AttributeNotFoundException,
+ TimeRangeException, StateValueTypeException {
+
+ long time1 = interestingTimestamp1;
+ long time2 = time1 + 1L * CtfTestFiles.NANOSECS_PER_SEC;
+ long resolution = 1000000; /* One query every millisecond */