control: add test for correct command line for adding context for UST
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Fri, 27 Nov 2015 18:43:13 +0000 (13:43 -0500)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Mon, 30 Nov 2015 19:47:16 +0000 (14:47 -0500)
Change-Id: Idbd428f88dda62730a29d088c7852770ebe54c11
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/61492
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/model/component/TraceControlUstSessionTests.java
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/CreateTreeTest.cfg

index c6e0d98d9af31bf0107372ee5cd77730f2a29677..d2677010a8508e3a4d54ac07e7e77a7b258a0fee 100644 (file)
@@ -16,6 +16,7 @@ package org.eclipse.tracecompass.lttng2.control.ui.tests.model.component;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -24,6 +25,8 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.ILogListener;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.remote.core.IRemoteConnection;
@@ -36,12 +39,14 @@ import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.BufferType;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.ChannelInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.AddContextDialogStub;
 import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.CreateSessionDialogStub;
 import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.DestroyConfirmDialogStub;
 import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.EnableChannelDialogStub;
 import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.EnableEventsDialogStub;
 import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.GetEventInfoDialogStub;
 import org.eclipse.tracecompass.internal.lttng2.control.stubs.service.TestRemoteSystemProxy;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.TraceControlDialogFactory;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
@@ -190,6 +195,54 @@ public class TraceControlUstSessionTests {
         assertEquals(16384, channel.getSubBufferSize());
         assertEquals(100, channel.getSwitchTimer());
 
+        // ------------------------------------------------------------------------
+        // Add context on channel
+        // ------------------------------------------------------------------------
+        AddContextDialogStub addContextStub = new AddContextDialogStub();
+        List<String> contexts = new ArrayList<>();
+        contexts.add("procname");
+        contexts.add("vtid");
+        addContextStub.setContexts(contexts);
+        TraceControlDialogFactory.getInstance().setAddContextDialog(addContextStub);
+
+        /*
+         * Currently there is nothing to verify because the list commands don't
+         * show any context information. However, the execution of the command
+         * makes sure that the correct service command line is built and
+         * executed.
+         *
+         * There was a bug in the control where the add context command was
+         * called with -k option instead of -u. Sending the -k option would
+         * cause that the command string is not found in the scenario. When a
+         * command string is not found then it is logged in the error log.
+         *
+         * Check the error log here to verify that the command was successful.
+         */
+        final IStatus[] statusToCheck = new IStatus[1];
+        ILogListener listener = new ILogListener() {
+            @Override
+            public void logging(IStatus status, String plugin) {
+                if (plugin.contentEquals(Activator.PLUGIN_ID)  && (!status.isOK())) {
+                    statusToCheck[0] = status;
+                }
+            }
+        };
+        Activator.getDefault().getLog().addLogListener(listener);
+
+        fFacility.executeCommand(channels[0], "addContextOnChannel");
+
+        // check that no error status was created
+        assertNull(statusToCheck[0]);
+
+        Activator.getDefault().getLog().removeLogListener(listener);
+
+        fFacility.delay(10000);
+
+        // Get Kernel domain component instance
+        domains = session.getChildren();
+        assertNotNull(domains);
+        assertEquals(1, domains.length);
+
         // ------------------------------------------------------------------------
         // Enable channel on domain
         // ------------------------------------------------------------------------
index 056077c44206afe9025d9893b08d8c7dd7023a72..fad28ea04b501699312085d44dd54ec4349f7e05 100644 (file)
@@ -2008,6 +2008,113 @@ Channels:
 
 </COMMAND_OUTPUT>
 
+<COMMAND_INPUT>
+lttng add-context -h
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+usage: lttng add-context -t TYPE
+
+If no channel and no event is given (-c/-e), the context
+will be added to all events and all channels.
+Otherwise the context will be added only to the channel (-c)
+and/or event (-e) indicated.
+Exactly one domain (-k/--kernel or -u/--userspace) must be specified.
+
+Options:
+  -h, --help               Show this help
+      --list-options       Simple listing of options
+  -s, --session NAME       Apply to session name
+  -c, --channel NAME       Apply to channel
+  -e, --event NAME         Apply to event
+  -k, --kernel             Apply to the kernel tracer
+  -u, --userspace          Apply to the user-space tracer
+  -t, --type TYPE          Context type. You can repeat that option on
+                           the command line to specify multiple contexts at once.
+                           (--kernel preempts --userspace)
+                           TYPE can be one of the strings below:
+                               pid, procname, prio, nice, vpid, tid, pthread_id,
+                               vtid, ppid, vppid, perf:cpu-cycles, perf:cycles,
+                               perf:stalled-cycles-frontend,
+                               perf:idle-cycles-frontend,
+                               perf:stalled-cycles-backend,
+                               perf:idle-cycles-backend, perf:instructions,
+                               perf:cache-references, perf:cache-misses,
+                               perf:branch-instructions, perf:branches,
+                               perf:branch-misses, perf:bus-cycles,
+                               perf:L1-dcache-loads, perf:L1-dcache-load-misses,
+                               perf:L1-dcache-stores,
+                               perf:L1-dcache-store-misses,
+                               perf:L1-dcache-prefetches,
+                               perf:L1-dcache-prefetch-misses,
+                               perf:L1-icache-loads, perf:L1-icache-load-misses,
+                               perf:L1-icache-stores,
+                               perf:L1-icache-store-misses,
+                               perf:L1-icache-prefetches,
+                               perf:L1-icache-prefetch-misses, perf:LLC-loads,
+                               perf:LLC-load-misses, perf:LLC-stores,
+                               perf:LLC-store-misses, perf:LLC-prefetches,
+                               perf:LLC-prefetch-misses, perf:dTLB-loads,
+                               perf:dTLB-load-misses, perf:dTLB-stores,
+                               perf:dTLB-store-misses, perf:dTLB-prefetches,
+                               perf:dTLB-prefetch-misses, perf:iTLB-loads,
+                               perf:iTLB-load-misses, perf:branch-loads,
+                               perf:branch-load-misses, perf:cpu-clock,
+                               perf:task-clock, perf:page-fault, perf:faults,
+                               perf:major-faults, perf:minor-faults,
+                               perf:context-switches, perf:cs,
+                               perf:cpu-migrations, perf:migrations,
+                               perf:alignment-faults, perf:emulation-faults
+Example:
+This command will add the context information 'prio' and two perf
+counters (hardware branch misses and cache misses), to all events
+in the trace data output:
+# lttng add-context -k -t prio -t perf:branch-misses -t perf:cache-misses
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive]
+    Trace path: /home/user/lttng-traces/mysession-20120314-132824
+
+=== Domain: UST global ===
+
+Channels:
+-------------
+- mychannel: [enabled]
+
+    Attributes:
+      overwrite mode: 1
+      subbufers size: 16384
+      number of subbufers: 4
+      switch timer interval: 100
+      read timer interval: 200
+      output: mmap()
+
+    Events:
+      None
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng add-context -s mysession -c mychannel -u -t procname -t vtid
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel context procname added to all events channel mychannel
+kernel context vtid added to all events channel mychannel
+</COMMAND_OUTPUT>
+
 <COMMAND_INPUT>
 lttng enable-channel mychannel2 -u -s mysession --subbuf-size 32768 --num-subbuf 2 --switch-timer 100 --read-timer 200
 </COMMAND_INPUT>
This page took 0.029379 seconds and 5 git commands to generate.