+ assertTrue(LttngSessionControl.setupSession(SESSION_NAME, DOMAIN,
+ EVENT_NAME_A, EVENT_NAME_C, EVENT_NAME_D));
+
+ send10Events(loggerA);
+ send10Events(loggerB);
+ send10Events(loggerC);
+ send10Events(loggerD);
+
+ assertTrue(LttngSessionControl.stopSession(SESSION_NAME));
+
+ List<String> output = LttngSessionControl.viewSession(SESSION_NAME);
+ assertNotNull(output);
+ assertEquals(20, output.size());
+
+ assertTrue(LttngSessionControl.destroySession(SESSION_NAME));
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(0, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ }
+
+ /**
+ * Test with all events enabled (-a), plus some other events added manually.
+ * Events should still be retained, but there should be no duplicates.
+ */
+ @Test
+ public void testAllEventsAndSome() {
+ assertTrue(LttngSessionControl.setupSessionAllEvents(SESSION_NAME, DOMAIN));
+ assertTrue(LttngSessionControl.enableEvents(SESSION_NAME, DOMAIN,
+ EVENT_NAME_A, EVENT_NAME_B));
+
+ send10Events(loggerA);
+ send10Events(loggerB);
+ send10Events(loggerC);
+ send10Events(loggerD);
+
+ assertTrue(LttngSessionControl.stopSession(SESSION_NAME));
+
+ List<String> output = LttngSessionControl.viewSession(SESSION_NAME);
+ assertNotNull(output);
+ assertEquals(30, output.size());
+
+ assertTrue(LttngSessionControl.destroySession(SESSION_NAME));
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ }
+
+ /**
+ * Same as {@link #testSomeEvents()}, but some events were enabled first,
+ * then disabled. Makes sure the enabled-event refcounting works properly.
+ */
+ @Test
+ public void testSomeEventsAfterDisabling() {
+ assertTrue(LttngSessionControl.setupSession(SESSION_NAME, DOMAIN,
+ EVENT_NAME_A, EVENT_NAME_C, EVENT_NAME_D));
+
+ assertTrue(LttngSessionControl.disableEvents(SESSION_NAME, DOMAIN,
+ EVENT_NAME_C));
+
+ send10Events(loggerA);
+ send10Events(loggerB);
+ send10Events(loggerC);
+ send10Events(loggerD);
+
+ assertTrue(LttngSessionControl.stopSession(SESSION_NAME));
+
+ List<String> output = LttngSessionControl.viewSession(SESSION_NAME);
+ assertNotNull(output);
+ assertEquals(10, output.size());
+
+ assertTrue(LttngSessionControl.destroySession(SESSION_NAME));
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(0, handlerB.getEventCount());
+ assertEquals(0, handlerC.getEventCount());
+ }
+
+ /**
+ * Test enabling an event prefix, which means an event name ending with a *,
+ * to match all events starting with this name.
+ */
+ @Test
+ public void testEventPrefix() {
+ assertTrue(LttngSessionControl.setupSession(SESSION_NAME, DOMAIN,
+ "EventAB*")); // should match event/loggers B and C, but not A.
+
+ send10Events(loggerA);
+ send10Events(loggerB);
+ send10Events(loggerC);
+ send10Events(loggerD);
+
+ assertTrue(LttngSessionControl.stopSession(SESSION_NAME));
+
+ List<String> output = LttngSessionControl.viewSession(SESSION_NAME);
+ assertNotNull(output);
+ assertEquals(20, output.size());
+
+ assertTrue(LttngSessionControl.destroySession(SESSION_NAME));
+
+ assertEquals(0, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ }
+
+ /**
+ * Same as {@link #testEventPrefix()}, but with multiple prefixes that
+ * overlap. There should not be any duplicate events in the trace or in the
+ * handlers.
+ */
+ @Test
+ public void testEventPrefixOverlapping() {
+ assertTrue(LttngSessionControl.setupSession(SESSION_NAME, DOMAIN,
+ "EventAB*", "EventABC*")); // should still match B and C