X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=org.eclipse.linuxtools.tmf.core.tests%2Fsrc%2Forg%2Feclipse%2Flinuxtools%2Ftmf%2Fcore%2Ftests%2Fctfadaptor%2FCtfTmfTraceTest.java;h=602551c5767440c00f910c4f2b7414d9797854c8;hb=e693075df9ab61d18493abaf9db9726efc254c17;hp=519810cf58815f757c625e33ae9ef901841fb528;hpb=61759503a35af46ddb0f8d54a351c620e9aeb605;p=deliverable%2Ftracecompass.git diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java index 519810cf58..602551c576 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.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 @@ -14,6 +14,7 @@ package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -21,6 +22,7 @@ import static org.junit.Assume.assumeTrue; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IStatus; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; @@ -30,7 +32,7 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfSignal; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; @@ -48,8 +50,7 @@ import org.junit.Test; */ public class CtfTmfTraceTest { - private static final int TRACE_INDEX = 0; - private static final String PATH = CtfTmfTestTraces.getTestTracePath(TRACE_INDEX); + private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL; private CtfTmfTrace fixture; @@ -61,9 +62,9 @@ public class CtfTmfTraceTest { */ @Before public void setUp() throws TmfTraceException { - assumeTrue(CtfTmfTestTraces.tracesExist()); + assumeTrue(testTrace.exists()); fixture = new CtfTmfTrace(); - fixture.initTrace((IResource) null, PATH, CtfTmfEvent.class); + fixture.initTrace((IResource) null, testTrace.getPath(), CtfTmfEvent.class); } /** @@ -89,7 +90,6 @@ public class CtfTmfTraceTest { assertEquals(0L, result.getNbEvents()); assertEquals(0L, result.getStreamingInterval()); assertNull(result.getResource()); - assertEquals(1000, result.getQueueSize()); assertNull(result.getType()); } @@ -174,22 +174,13 @@ public class CtfTmfTraceTest { } /** - * Run the String[] getEnvNames() method test. - */ - @Test - public void testGetEnvNames() { - String[] result = fixture.getEnvNames(); - assertNotNull(result); - } - - /** - * Run the String getEnvValue(String) method test. + * Run the String getEnvironment method test. */ @Test public void testGetEnvValue() { - String key = "tracer_name"; //$NON-NLS-1$ - String result = fixture.getEnvValue(key); - assertEquals("\"lttng-modules\"",result); //$NON-NLS-1$ + String key = "tracer_name"; + String result = fixture.getTraceProperties().get(key); + assertEquals("\"lttng-modules\"",result); } /** @@ -197,7 +188,7 @@ public class CtfTmfTraceTest { */ @Test public void testGetEventType() { - Class result = fixture.getEventType(); + Class result = fixture.getEventType(); assertNotNull(result); } @@ -227,7 +218,7 @@ public class CtfTmfTraceTest { */ @Test public void testGetNbEnvVars() { - int result = fixture.getNbEnvVars(); + int result = fixture.getTraceProperties().size(); assertEquals(8, result); } @@ -352,8 +343,32 @@ public class CtfTmfTraceTest { @Test public void testValidate() { IProject project = null; - String path = PATH; - boolean result = fixture.validate(project, path); - assertTrue(result); + IStatus result = fixture.validate(project, testTrace.getPath()); + assertTrue(result.isOK()); } + + /** + * Run the boolean hasEvent(final String) method test + */ + @Test + public void testEventLookup() { + assertTrue(fixture.hasEvent("sched_switch")); + assertFalse(fixture.hasEvent("Sched_switch")); + String[] events = { "sched_switch", "sched_wakeup", "timer_init" }; + assertTrue(fixture.hasAllEvents(events)); + assertTrue(fixture.hasAtLeastOneOfEvents(events)); + String[] names = { "inexistent", "sched_switch", "SomeThing" }; + assertTrue(fixture.hasAtLeastOneOfEvents(names)); + assertFalse(fixture.hasAllEvents(names)); + } + + /** + * Run the String getHostId() method test + */ + @Test + public void testCtfHostId() { + String a = fixture.getHostId(); + assertEquals("\"84db105b-b3f4-4821-b662-efc51455106a\"", a); + } + }