From 54f2dcc078f9df4a7b48cb629ca517d960a67c51 Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Mon, 26 May 2014 16:18:07 -0400 Subject: [PATCH] lttng-control: Fix parsing and display of loglevels (bug 429193) Change-Id: If42746ae361c4e9fe6210c2e1c9f1b253060f58e Signed-off-by: Bernd Hufmann Reviewed-on: https://git.eclipse.org/r/27310 Tested-by: Hudson CI Tested-by: Marc-Andre Laperle Reviewed-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/27409 --- .../tests/model/impl/ChannelInfoTest.java | 2 +- .../core/tests/model/impl/DomainInfoTest.java | 2 +- .../core/tests/model/impl/EventInfoTest.java | 45 ++++++++++++++++++- .../tests/model/impl/ModelImplFactory.java | 6 ++- .../tests/model/impl/ProbeEventInfoTest.java | 4 +- .../tests/model/impl/SessionInfoTest.java | 4 +- .../lttng2/control/core/model/IEventInfo.java | 20 ++++++++- .../control/core/model/LogLevelType.java | 39 ++++++++++++++-- .../core/model/impl/BaseEventInfo.java | 2 + .../control/core/model/impl/EventInfo.java | 36 ++++++++++++++- .../component/TraceControlPropertiesTest.java | 18 ++++++++ .../component/TraceControlTreeModelTest.java | 23 +++++++++- .../testfiles/CreateTreeTest.cfg | 14 +++--- .../testfiles/ListInfoTest.cfg | 4 +- .../views/model/impl/TraceEventComponent.java | 17 +++++++ .../property/TraceEventPropertySource.java | 8 +++- .../ui/views/service/LTTngControlService.java | 9 ++-- .../service/LTTngControlServiceConstants.java | 2 +- 18 files changed, 224 insertions(+), 31 deletions(-) diff --git a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ChannelInfoTest.java b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ChannelInfoTest.java index b8cae40663..6dc8b9436e 100644 --- a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ChannelInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ChannelInfoTest.java @@ -302,7 +302,7 @@ public class ChannelInfoTest { String result = fChannelInfo1.toString(); // add additional test code here - assertEquals("[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])]", result); + assertEquals("[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED,levelType=LOGLEVEL_ONLY)])]", result); } // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/DomainInfoTest.java b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/DomainInfoTest.java index e85c258f5e..ff6fba5cf0 100644 --- a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/DomainInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/DomainInfoTest.java @@ -147,7 +147,7 @@ public class DomainInfoTest { public void testToString_2() { String result = fDomainInfo1.toString(); - assertEquals("[DomainInfo([TraceInfo(Name=test1)],Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])],isKernel=false)]", result); + assertEquals("[DomainInfo([TraceInfo(Name=test1)],Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED,levelType=LOGLEVEL_ONLY)])],isKernel=false)]", result); } // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/EventInfoTest.java b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/EventInfoTest.java index be5400a686..2affb71d16 100644 --- a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/EventInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/EventInfoTest.java @@ -19,6 +19,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import org.eclipse.linuxtools.internal.lttng2.control.core.model.IEventInfo; +import org.eclipse.linuxtools.internal.lttng2.control.core.model.LogLevelType; import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEnablement; import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEventType; import org.eclipse.linuxtools.internal.lttng2.control.core.model.impl.EventInfo; @@ -57,7 +58,7 @@ public class EventInfoTest { // ------------------------------------------------------------------------ /** - * Run the BaseEventInfo() constructor test. + * Run the EventInfo() constructor test. */ @Test public void testBaseEventInfo() { @@ -78,6 +79,13 @@ public class EventInfoTest { assertEquals("DISABLED", state.toString()); assertEquals(0, state.ordinal()); + LogLevelType logType = fixture.getLogLevelType(); + assertEquals("", logType.getShortName()); + assertEquals("LOGLEVEL_NONE", logType.name()); + assertEquals("LOGLEVEL_NONE", logType.toString()); + assertEquals(0, state.ordinal()); + + } /** @@ -90,6 +98,7 @@ public class EventInfoTest { assertEquals(fEventInfo1.getName(), info.getName()); assertEquals(fEventInfo1.getEventType(), info.getEventType()); assertEquals(fEventInfo1.getState(), info.getState()); + assertEquals(fEventInfo1.getLogLevelType(), info.getLogLevelType()); } /** @@ -187,6 +196,22 @@ public class EventInfoTest { assertEquals("ENABLED", state.name()); assertEquals("ENABLED", state.toString()); assertEquals(1, state.ordinal()); + + fixture.setLogLevelType("=="); + assertEquals("LOGLEVEL_ONLY", fixture.getLogLevelType().name()); + assertEquals("==", fixture.getLogLevelType().getShortName()); + + fixture.setLogLevelType("<="); + assertEquals("LOGLEVEL", fixture.getLogLevelType().name()); + assertEquals("<=", fixture.getLogLevelType().getShortName()); + + fixture.setLogLevelType(""); + assertEquals("LOGLEVEL_NONE", fixture.getLogLevelType().name()); + assertEquals("", fixture.getLogLevelType().getShortName()); + + fixture.setLogLevelType(LogLevelType.LOGLEVEL_ONLY); + assertEquals("LOGLEVEL_ONLY", fixture.getLogLevelType().name()); + assertEquals("==", fixture.getLogLevelType().getShortName()); } /** @@ -201,7 +226,23 @@ public class EventInfoTest { String result = fixture.toString(); // add additional test code here - assertEquals("[EventInfo([BaseEventInfo([TraceInfo(Name=testName)],type=TRACEPOINT,level=TRACE_DEBUG)],State=DISABLED)]", result); + assertEquals("[EventInfo([BaseEventInfo([TraceInfo(Name=testName)],type=TRACEPOINT,level=TRACE_DEBUG)],State=DISABLED,levelType=LOGLEVEL_NONE)]", result); + } + + /** + * Run the String toString() method test. + */ + @Test + public void testToString_2() { + EventInfo fixture = new EventInfo("event"); + fixture.setName("testName"); + fixture.setEventType(TraceEventType.TRACEPOINT); + fixture.setLogLevelType(LogLevelType.LOGLEVEL_ONLY); + + String result = fixture.toString(); + + // add additional test code here + assertEquals("[EventInfo([BaseEventInfo([TraceInfo(Name=testName)],type=TRACEPOINT,level=TRACE_DEBUG)],State=DISABLED,levelType=LOGLEVEL_ONLY)]", result); } // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ModelImplFactory.java b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ModelImplFactory.java index 22c8e004c3..569f961007 100644 --- a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ModelImplFactory.java +++ b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ModelImplFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Ericsson + * Copyright (c) 2012, 2014 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -81,9 +81,13 @@ public class ModelImplFactory { fEventInfo1 = new EventInfo("event1"); fEventInfo1.setEventType(TraceEventType.TRACEPOINT); + fEventInfo1.setLogLevelType("=="); + fEventInfo1.setLogLevel(TraceLogLevel.TRACE_DEBUG); fEventInfo1.setState(TraceEnablement.ENABLED); fEventInfo2 = new EventInfo("event2"); + fEventInfo2.setLogLevelType("<="); + fEventInfo2.setLogLevel(TraceLogLevel.TRACE_INFO); fEventInfo2.setEventType(TraceEventType.UNKNOWN); fEventInfo2.setState(TraceEnablement.DISABLED); diff --git a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ProbeEventInfoTest.java b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ProbeEventInfoTest.java index a3d6c42383..5d046f5b84 100644 --- a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ProbeEventInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/ProbeEventInfoTest.java @@ -140,8 +140,8 @@ public class ProbeEventInfoTest { */ @Test public void testToString_1() { - assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)],fAddress=0xc1231234)]", fEventInfo1.toString()); - assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent2)],type=FUNCTION,level=TRACE_DEBUG)],State=DISABLED)],fOffset=0x100,fSymbol=init_post)]", fEventInfo2.toString()); + assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED,levelType=LOGLEVEL_NONE)],fAddress=0xc1231234)]", fEventInfo1.toString()); + assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent2)],type=FUNCTION,level=TRACE_DEBUG)],State=DISABLED,levelType=LOGLEVEL_NONE)],fOffset=0x100,fSymbol=init_post)]", fEventInfo2.toString()); } // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/SessionInfoTest.java b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/SessionInfoTest.java index 694c6d69d4..5ff8cff71d 100644 --- a/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/SessionInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.control.core.tests/src/org/eclipse/linuxtools/lttng2/control/core/tests/model/impl/SessionInfoTest.java @@ -212,7 +212,7 @@ public class SessionInfoTest { + "[SnapshotInfo([TraceInfo(Name=snapshot-1)],snapshotPath=/home/user/lttng-trace/mysession/,ID=1,isStreamedSnapshot=false)]," + "Domains=[DomainInfo([TraceInfo(Name=test1)]," + "Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice()," - + "Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])]," + + "Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED,levelType=LOGLEVEL_ONLY)])]," + "isKernel=false)],NetworkUrl=null,ControlUrl=null,DataUrl=null)]", result); } @@ -232,7 +232,7 @@ public class SessionInfoTest { assertEquals("[SessionInfo([TraceInfo(Name=session1)],Path=/home/user/lttng-trace/mysession/,State=ACTIVE,isStreamedTrace=false,isSnapshot=false," + "Domains=[DomainInfo([TraceInfo(Name=test1)]," + "Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice()," - + "Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])]," + + "Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED,levelType=LOGLEVEL_ONLY)])]," + "isKernel=false)],NetworkUrl=null,ControlUrl=null,DataUrl=null)]", result); } diff --git a/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/IEventInfo.java b/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/IEventInfo.java index 4fc5033fa6..cd11e82b10 100644 --- a/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/IEventInfo.java +++ b/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/IEventInfo.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012, 2013 Ericsson + * Copyright (c) 2012, 2014 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -37,4 +37,22 @@ public interface IEventInfo extends IBaseEventInfo { */ void setState(String stateName); + /** + * Returns the log level type. + * @return log level type. + */ + LogLevelType getLogLevelType(); + + /** + * Sets the LogLevelType. + * @param type - log level type + */ + void setLogLevelType(LogLevelType type); + + /** + * Sets the LogLevelType based on given short name. + * @param shortName - short name of type + */ + void setLogLevelType(String shortName); + } diff --git a/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/LogLevelType.java b/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/LogLevelType.java index 5ca363789f..ab0c405f56 100644 --- a/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/LogLevelType.java +++ b/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/LogLevelType.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2014 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -24,11 +24,42 @@ public enum LogLevelType { // Enum definition // ------------------------------------------------------------------------ /** range of log levels [0,logLevel] */ - LOGLEVEL, + LOGLEVEL("<="), //$NON-NLS-1$ /** single log level */ - LOGLEVEL_ONLY, + LOGLEVEL_ONLY("=="), //$NON-NLS-1$ /** no log level */ - LOGLEVEL_NONE; + LOGLEVEL_NONE(""); //$NON-NLS-1$ + + // ------------------------------------------------------------------------ + // Constuctors + // ------------------------------------------------------------------------ + + /** + * Private constructor + * @param name the name of state + */ + private LogLevelType(String shortName) { + fShortName = shortName; + } + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + /** + * Name of enum. + */ + private final String fShortName; + + // ------------------------------------------------------------------------ + // Accessors + // ------------------------------------------------------------------------ + /** + * @return short string + */ + public String getShortName() { + return fShortName; + } + } diff --git a/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/BaseEventInfo.java b/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/BaseEventInfo.java index a2a2e0769b..3b05baf9b6 100644 --- a/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/BaseEventInfo.java +++ b/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/BaseEventInfo.java @@ -68,6 +68,7 @@ public class BaseEventInfo extends TraceInfo implements IBaseEventInfo { public BaseEventInfo(BaseEventInfo other) { super(other); fEventType = other.fEventType; + fLogLevel = other.fLogLevel; for (Iterator iterator = other.fFields.iterator(); iterator.hasNext();) { IFieldInfo field = iterator.next(); if (field instanceof FieldInfo) { @@ -252,4 +253,5 @@ public class BaseEventInfo extends TraceInfo implements IBaseEventInfo { output.append(")]"); return output.toString(); } + } diff --git a/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/EventInfo.java b/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/EventInfo.java index abfb5e14c1..ffc84d2146 100644 --- a/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/EventInfo.java +++ b/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/EventInfo.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012, 2013 Ericsson + * Copyright (c) 2012, 2014 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -12,6 +12,7 @@ package org.eclipse.linuxtools.internal.lttng2.control.core.model.impl; import org.eclipse.linuxtools.internal.lttng2.control.core.model.IEventInfo; +import org.eclipse.linuxtools.internal.lttng2.control.core.model.LogLevelType; import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEnablement; /** @@ -31,6 +32,10 @@ public class EventInfo extends BaseEventInfo implements IEventInfo { * The enable state of the event. */ private TraceEnablement fState = TraceEnablement.DISABLED; + /** + * The log level type. + */ + private LogLevelType fLogLevelType = LogLevelType.LOGLEVEL_NONE; // ------------------------------------------------------------------------ // Constructors @@ -50,6 +55,7 @@ public class EventInfo extends BaseEventInfo implements IEventInfo { public EventInfo(EventInfo other) { super(other); fState = other.fState; + fLogLevelType = other.fLogLevelType; } // ------------------------------------------------------------------------ @@ -76,11 +82,34 @@ public class EventInfo extends BaseEventInfo implements IEventInfo { } } + @Override + public LogLevelType getLogLevelType() { + return fLogLevelType; + } + + @Override + public void setLogLevelType(LogLevelType type) { + fLogLevelType = type; + } + + @Override + public void setLogLevelType(String shortName) { + if (LogLevelType.LOGLEVEL.getShortName().equals(shortName)) { + fLogLevelType = LogLevelType.LOGLEVEL; + } else if (LogLevelType.LOGLEVEL_ONLY.getShortName().equals(shortName)) { + fLogLevelType = LogLevelType.LOGLEVEL_ONLY; + } else { + fLogLevelType= LogLevelType.LOGLEVEL_NONE; + } + } + + @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1)); + result = prime * result + ((fLogLevelType == null) ? 0 : fLogLevelType.hashCode()); return result; } @@ -99,6 +128,9 @@ public class EventInfo extends BaseEventInfo implements IEventInfo { if (fState != other.fState) { return false; } + if (fLogLevelType != other.fLogLevelType) { + return false; + } return true; } @@ -110,6 +142,8 @@ public class EventInfo extends BaseEventInfo implements IEventInfo { output.append(super.toString()); output.append(",State="); output.append(fState); + output.append(",levelType="); + output.append(fLogLevelType); output.append(")]"); return output.toString(); } diff --git a/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlPropertiesTest.java b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlPropertiesTest.java index c09c490b90..12e41ce3be 100644 --- a/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlPropertiesTest.java +++ b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlPropertiesTest.java @@ -333,6 +333,24 @@ public class TraceControlPropertiesTest { adapter = event.getAdapter(IPropertySource.class); assertEquals("with filter", event.getFilterExpression()); + //------------------------------------------------------------------------- + // Verify Log Level Type of UST events (> LTTng 2.4) + //------------------------------------------------------------------------- + event = (TraceEventComponent) domains[1].getChildren()[1].getChildren()[0]; + adapter = event.getAdapter(IPropertySource.class); + eventSource = (TraceEventPropertySource) adapter; + assertEquals("== TRACE_DEBUG_LINE", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID)); + + event = (TraceEventComponent) domains[1].getChildren()[1].getChildren()[1]; + adapter = event.getAdapter(IPropertySource.class); + eventSource = (TraceEventPropertySource) adapter; + assertEquals("<= TRACE_INFO", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID)); + + event = (TraceEventComponent) domains[1].getChildren()[1].getChildren()[2]; + adapter = event.getAdapter(IPropertySource.class); + eventSource = (TraceEventPropertySource) adapter; + assertEquals("TRACE_DEBUG_SYSTEM", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID)); + //------------------------------------------------------------------------- // Delete node //------------------------------------------------------------------------- diff --git a/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlTreeModelTest.java b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlTreeModelTest.java index 22086fb0d7..ac0b810833 100644 --- a/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlTreeModelTest.java +++ b/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/model/component/TraceControlTreeModelTest.java @@ -26,6 +26,7 @@ import java.net.URL; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.internal.lttng2.control.stubs.service.TestRemoteSystemProxy; +import org.eclipse.linuxtools.internal.lttng2.control.core.model.LogLevelType; import org.eclipse.linuxtools.internal.lttng2.control.core.model.TargetNodeState; import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEnablement; import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEventType; @@ -420,16 +421,34 @@ public class TraceControlTreeModelTest { // Verify event info (UST global, channel0) // ------------------------------------------------------------------------ ustEvents = channel.getChildren(); - assertEquals(2, ustEvents.length); + assertEquals(4, ustEvents.length); event = (TraceEventComponent) ustEvents[0]; assertEquals("ust_tests_hello:tptest_sighandler", event.getName()); assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel()); + assertEquals(LogLevelType.LOGLEVEL_ONLY, event.getLogLevelType()); + assertEquals(LogLevelType.LOGLEVEL_ONLY.getShortName(), event.getLogLevelType().getShortName()); assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); assertEquals(TraceEnablement.DISABLED, event.getState()); event = (TraceEventComponent) ustEvents[1]; - assertEquals("*", ustEvents[1].getName()); + assertEquals("ust_tests_hello:tptest_sighandler1", event.getName()); + assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel()); + assertEquals(LogLevelType.LOGLEVEL, event.getLogLevelType()); + assertEquals(LogLevelType.LOGLEVEL.getShortName(), event.getLogLevelType().getShortName()); + assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); + assertEquals(TraceEnablement.DISABLED, event.getState()); + + event = (TraceEventComponent) ustEvents[2]; + assertEquals("ust_tests_hello:tptest_sighandler2", event.getName()); + assertEquals(TraceLogLevel.TRACE_DEBUG_SYSTEM, event.getLogLevel()); + assertEquals(LogLevelType.LOGLEVEL_NONE, event.getLogLevelType()); + assertEquals(LogLevelType.LOGLEVEL_NONE.getShortName(), event.getLogLevelType().getShortName()); + assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); + assertEquals(TraceEnablement.DISABLED, event.getState()); + + event = (TraceEventComponent) ustEvents[3]; + assertEquals("*", event.getName()); assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); assertEquals(TraceEnablement.ENABLED, event.getState()); diff --git a/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateTreeTest.cfg b/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateTreeTest.cfg index 635a546f2b..f3cc92d8f0 100644 --- a/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateTreeTest.cfg +++ b/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateTreeTest.cfg @@ -1,5 +1,5 @@ #################################################################### -# Copyright (c) 2012, 2013 Ericsson +# Copyright (c) 2012, 2014 Ericsson # # All rights reserved. This program and the accompanying materials are # made available under the terms of the Eclipse Public License v1.0 which @@ -2520,7 +2520,7 @@ Channels: output: splice() Events: - myevent1 (loglevel: TRACE_WARNING (4)) (type: tracepoint) [enabled] + myevent1 (loglevel <= TRACE_WARNING (4)) (type: tracepoint) [enabled] u* (type: tracepoint) [enabled] ust* (type: tracepoint) [enabled] ust_tests_hello:tptest_sighandler (type: tracepoint) [enabled] @@ -2589,8 +2589,8 @@ Channels: output: splice() Events: - myevent2 (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint) [enabled] - myevent1 (loglevel: TRACE_WARNING (4)) (type: loglevel) [enabled] + myevent2 (loglevel == TRACE_DEBUG_FUNCTION (12)) (type: tracepoint) [enabled] + myevent1 (loglevel <= TRACE_WARNING (4)) (type: loglevel) [enabled] u* (type: tracepoint) [enabled] ust* (type: tracepoint) [enabled] ust_tests_hello:tptest_sighandler (type: tracepoint) [enabled] @@ -2633,7 +2633,7 @@ Channels: output: mmap() Events: - myevent0 (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint) [enabled] + myevent0 (loglevel <= TRACE_DEBUG_FUNCTION (12)) (type: tracepoint) [enabled] ust* (type: tracepoint) [enabled] - mychannel2: [enabled] @@ -2660,8 +2660,8 @@ Channels: output: splice() Events: - myevent2 (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint) [enabled] - myevent1 (loglevel: TRACE_WARNING (4)) (type: loglevel) [enabled] + myevent2 (loglevel <= TRACE_DEBUG_FUNCTION (12)) (type: tracepoint) [enabled] + myevent1 (loglevel == TRACE_WARNING (4)) (type: loglevel) [enabled] u* (type: tracepoint) [enabled] ust* (type: tracepoint) [enabled] ust_tests_hello:tptest_sighandler (type: tracepoint) [enabled] diff --git a/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/ListInfoTest.cfg b/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/ListInfoTest.cfg index 19cbd15533..e7abfcd912 100644 --- a/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/ListInfoTest.cfg +++ b/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/ListInfoTest.cfg @@ -117,7 +117,9 @@ Channels: output: mmap() Events: - ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled] [with filter] + ust_tests_hello:tptest_sighandler (loglevel == TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled] [with filter] + ust_tests_hello:tptest_sighandler1 (loglevel <= TRACE_INFO (7)) (type: tracepoint) [disabled] [with filter] + ust_tests_hello:tptest_sighandler2 (loglevel: TRACE_DEBUG_SYSTEM (8)) (type: tracepoint) [disabled] [with filter] * (type: tracepoint) [enabled] diff --git a/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceEventComponent.java b/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceEventComponent.java index 9916d5d4bc..531a507cb0 100644 --- a/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceEventComponent.java +++ b/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceEventComponent.java @@ -17,6 +17,7 @@ import java.util.List; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.linuxtools.internal.lttng2.control.core.model.IEventInfo; +import org.eclipse.linuxtools.internal.lttng2.control.core.model.LogLevelType; import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEnablement; import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEventType; import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceLogLevel; @@ -182,6 +183,22 @@ public class TraceEventComponent extends TraceControlComponent { fEventInfo.setFilterExpression(filter); } + /** + * Returns the log level type + * @return event log level type + */ + public LogLevelType getLogLevelType() { + return fEventInfo.getLogLevelType(); + } + + /** + * Sets the trace event log level type to the given level type + * @param levelType - event log level type to set + */ + public void setLogLevelType(LogLevelType levelType) { + fEventInfo.setLogLevelType(levelType); + } + @Override public Object getAdapter(Class adapter) { if (adapter == IPropertySource.class) { diff --git a/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/property/TraceEventPropertySource.java b/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/property/TraceEventPropertySource.java index f7eca901d1..e7cc8f5889 100644 --- a/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/property/TraceEventPropertySource.java +++ b/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/property/TraceEventPropertySource.java @@ -15,6 +15,7 @@ package org.eclipse.linuxtools.internal.lttng2.control.ui.views.property; import java.util.ArrayList; import java.util.List; +import org.eclipse.linuxtools.internal.lttng2.control.core.model.LogLevelType; import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceLogLevel; import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages; import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceEventComponent; @@ -124,7 +125,12 @@ public class TraceEventPropertySource extends BasePropertySource { return fEvent.getEventType().name(); } if (TRACE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) { - return fEvent.getLogLevel().name(); + StringBuffer buffer = new StringBuffer(); + if (fEvent.getLogLevelType() != LogLevelType.LOGLEVEL_NONE) { + buffer.append(fEvent.getLogLevelType().getShortName()).append(' '); + } + buffer.append(fEvent.getLogLevel().name()); + return buffer.toString(); } if (TRACE_EVENT_STATE_PROPERTY_ID.equals(id)) { return fEvent.getState().name(); diff --git a/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java b/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java index 32998ebd1f..92a8b25f17 100644 --- a/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java +++ b/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java @@ -1215,10 +1215,11 @@ public class LTTngControlService implements ILttngControlService { if (matcher.matches()) { IEventInfo eventInfo = new EventInfo(matcher.group(1).trim()); - eventInfo.setLogLevel(matcher.group(2).trim()); - eventInfo.setEventType(matcher.group(3).trim()); - eventInfo.setState(matcher.group(4)); - String filter = matcher.group(5); + eventInfo.setLogLevelType(matcher.group(2).trim()); + eventInfo.setLogLevel(matcher.group(3).trim()); + eventInfo.setEventType(matcher.group(4).trim()); + eventInfo.setState(matcher.group(5)); + String filter = matcher.group(6); if (filter != null) { filter = filter.substring(1, filter.length() - 1); // remove '[' and ']' eventInfo.setFilterExpression(filter); diff --git a/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java b/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java index 4fe28bbdbf..f30d5fb8d0 100644 --- a/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java +++ b/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java @@ -323,7 +323,7 @@ public interface LTTngControlServiceConstants { /** * Pattern to match for event information (lttng list ) */ - static final Pattern EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\]\\s*(\\[.*\\]){0,1}.*"); //$NON-NLS-1$ + static final Pattern EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(loglevel\\s*(:|<=|==)\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\]\\s*(\\[.*\\]){0,1}.*"); //$NON-NLS-1$ /** * Pattern to match a wildcarded event information (lttng list ) */ -- 2.34.1