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;
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;
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;
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
// ------------------------------------------------------------------------
</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>