From 362278afdeb995fec9244a195a7d97aa7d5b81ce Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Fri, 27 Nov 2015 13:43:13 -0500 Subject: [PATCH] control: add test for correct command line for adding context for UST Change-Id: Idbd428f88dda62730a29d088c7852770ebe54c11 Signed-off-by: Bernd Hufmann Reviewed-on: https://git.eclipse.org/r/61492 Reviewed-by: Hudson CI Reviewed-by: Patrick Tasse Tested-by: Patrick Tasse --- .../TraceControlUstSessionTests.java | 53 +++++++++ .../testfiles/CreateTreeTest.cfg | 107 ++++++++++++++++++ 2 files changed, 160 insertions(+) diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/model/component/TraceControlUstSessionTests.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/model/component/TraceControlUstSessionTests.java index c6e0d98d9a..d2677010a8 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/model/component/TraceControlUstSessionTests.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/model/component/TraceControlUstSessionTests.java @@ -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 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 // ------------------------------------------------------------------------ diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/CreateTreeTest.cfg b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/CreateTreeTest.cfg index 056077c442..fad28ea04b 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/CreateTreeTest.cfg +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/CreateTreeTest.cfg @@ -2008,6 +2008,113 @@ Channels: + +lttng add-context -h + + +0 + + +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 + + + + +lttng list mysession + + +0 + + +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 + + + + +lttng add-context -s mysession -c mychannel -u -t procname -t vtid + + +0 + + +kernel context procname added to all events channel mychannel +kernel context vtid added to all events channel mychannel + + lttng enable-channel mychannel2 -u -s mysession --subbuf-size 32768 --num-subbuf 2 --switch-timer 100 --read-timer 200 -- 2.34.1