1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.core
.tests
.trace
;
16 import java
.io
.IOException
;
17 import java
.net
.URISyntaxException
;
20 import junit
.framework
.TestCase
;
22 import org
.eclipse
.core
.runtime
.FileLocator
;
23 import org
.eclipse
.core
.runtime
.Path
;
24 import org
.eclipse
.linuxtools
.lttng
.core
.event
.LttngEvent
;
25 import org
.eclipse
.linuxtools
.lttng
.core
.tests
.LTTngCoreTestPlugin
;
26 import org
.eclipse
.linuxtools
.lttng
.core
.trace
.LTTngTrace
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimeRange
;
28 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimestamp
;
29 import org
.eclipse
.linuxtools
.tmf
.core
.experiment
.TmfExperiment
;
30 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
33 * <b><u>TmfExperimentTest</u></b>
35 * TODO: Implement me. Please.
37 @SuppressWarnings("nls")
38 public class LTTngExperimentTest
extends TestCase
{
40 private static final String DIRECTORY
= "traceset";
41 private static final String TEST_STREAM
= "trace-15316events_nolost_newformat";
42 private static final String EXPERIMENT
= "MyExperiment";
43 private static int NB_EVENTS
= 15316;
45 // Note: Start/end times are for the LTTng *trace*, not the actual events
46 private static final TmfTimestamp fStartTime
= new TmfTimestamp(13589759412128L, (byte) -9);
47 private static final TmfTimestamp fEndTime
= new TmfTimestamp(13589907059242L, (byte) -9);
49 private static ITmfTrace
<LttngEvent
>[] fTraces
;
50 private static TmfExperiment
<LttngEvent
> fExperiment
;
52 // ------------------------------------------------------------------------
54 // ------------------------------------------------------------------------
56 @SuppressWarnings("unchecked")
57 private synchronized static ITmfTrace
<LttngEvent
>[] setupTrace(String path
) {
58 if (fTraces
== null) {
59 fTraces
= new ITmfTrace
[1];
61 URL location
= FileLocator
.find(LTTngCoreTestPlugin
.getPlugin().getBundle(), new Path(path
), null);
62 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
63 LTTngTrace trace
= new LTTngTrace(testfile
.getPath(), false);
65 } catch (URISyntaxException e
) {
67 } catch (IOException e
) {
69 } catch (Exception e
) {
76 private synchronized static void setupExperiment() {
77 if (fExperiment
== null) {
78 fExperiment
= new TmfExperiment
<LttngEvent
>(LttngEvent
.class, EXPERIMENT
, fTraces
, TmfTimestamp
.Zero
, 1000, true);
82 public LTTngExperimentTest(String name
) throws Exception
{
87 protected void setUp() throws Exception
{
89 setupTrace(DIRECTORY
+ File
.separator
+ TEST_STREAM
);
94 protected void tearDown() throws Exception
{
98 // ------------------------------------------------------------------------
100 // ------------------------------------------------------------------------
102 public void testBasicTmfExperimentConstructor() {
104 assertEquals("GetId", EXPERIMENT
, fExperiment
.getName());
105 assertEquals("GetEpoch", TmfTimestamp
.Zero
, fExperiment
.getEpoch());
106 assertEquals("GetNbEvents", NB_EVENTS
, fExperiment
.getNbEvents());
108 long nbTraceEvents
= fExperiment
.getTraces()[0].getNbEvents();
109 assertEquals("GetNbEvents", NB_EVENTS
, nbTraceEvents
);
111 TmfTimeRange timeRange
= fExperiment
.getTimeRange();
112 assertTrue("getStartTime", fStartTime
.equals(timeRange
.getStartTime()));
113 assertTrue("getEndTime", fEndTime
.equals(timeRange
.getEndTime()));
This page took 0.034505 seconds and 5 git commands to generate.