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
.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
.tests
.LTTngCoreTestPlugin
;
25 import org
.eclipse
.linuxtools
.lttng
.trace
.LTTngExperiment
;
26 import org
.eclipse
.linuxtools
.lttng
.trace
.LTTngTrace
;
27 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
28 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
29 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimestamp
;
30 import org
.eclipse
.linuxtools
.tmf
.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
[] fTraces
;
50 private static LTTngExperiment
<TmfEvent
> fExperiment
;
52 // ------------------------------------------------------------------------
54 // ------------------------------------------------------------------------
56 private synchronized static ITmfTrace
[] setupTrace(String path
) {
57 if (fTraces
== null) {
58 fTraces
= new ITmfTrace
[1];
60 URL location
= FileLocator
.find(LTTngCoreTestPlugin
.getPlugin().getBundle(), new Path(path
), null);
61 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
62 LTTngTrace trace
= new LTTngTrace(testfile
.getPath());
64 } catch (URISyntaxException e
) {
66 } catch (IOException e
) {
68 } catch (Exception e
) {
75 private synchronized static void setupExperiment() {
76 if (fExperiment
== null) {
77 fExperiment
= new LTTngExperiment
<TmfEvent
>(TmfEvent
.class, EXPERIMENT
, fTraces
, TmfTimestamp
.Zero
, 1000, true);
81 public LTTngExperimentTest(String name
) throws Exception
{
86 protected void setUp() throws Exception
{
88 setupTrace(DIRECTORY
+ File
.separator
+ TEST_STREAM
);
93 protected void tearDown() throws Exception
{
97 // ------------------------------------------------------------------------
99 // ------------------------------------------------------------------------
101 public void testBasicTmfExperimentConstructor() {
103 assertEquals("GetId", EXPERIMENT
, fExperiment
.getName());
104 assertEquals("GetEpoch", TmfTimestamp
.Zero
, fExperiment
.getEpoch());
105 assertEquals("GetNbEvents", NB_EVENTS
, fExperiment
.getNbEvents());
107 long nbTraceEvents
= fExperiment
.getTraces()[0].getNbEvents();
108 assertEquals("GetNbEvents", NB_EVENTS
, nbTraceEvents
);
110 TmfTimeRange timeRange
= fExperiment
.getTimeRange();
111 assertTrue("getStartTime", fStartTime
.equals(timeRange
.getStartTime()));
112 assertTrue("getEndTime", fEndTime
.equals(timeRange
.getEndTime()));
This page took 0.035444 seconds and 6 git commands to generate.