os.tests: Add a kernel stub trace class and use that in unit tests
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core.tests / src / org / eclipse / tracecompass / analysis / os / linux / core / tests / kernelanalysis / KernelStateProviderTest.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2015 Ericsson
3 * Copyright (c) 2010, 2011 École Polytechnique de Montréal
4 * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
5 *
6 * All rights reserved. This program and the accompanying materials are
7 * made available under the terms of the Eclipse Public License v1.0 which
8 * accompanies this distribution, and is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 *
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.analysis.os.linux.core.tests.kernelanalysis;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.fail;
17
18 import org.eclipse.core.runtime.IPath;
19 import org.eclipse.core.runtime.IStatus;
20 import org.eclipse.jdt.annotation.NonNull;
21 import org.eclipse.tracecompass.analysis.os.linux.core.tests.Activator;
22 import org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub;
23 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
24 import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.KernelStateProvider;
25 import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
26 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
27 import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
31
32 /**
33 * Tests for the {@link KernelStateProvider}
34 *
35 * @author Alexandre Montplaisir
36 */
37 public class KernelStateProviderTest {
38
39 private static final @NonNull String LTTNG_KERNEL_FILE = "testfiles/lttng_kernel_analysis.xml";
40
41 private IKernelTrace fTrace;
42 private ITmfStateProvider fInput;
43
44 /**
45 * Set-up.
46 */
47 @Before
48 public void initialize() {
49 IKernelTrace thetrace = new TmfXmlKernelTraceStub();
50 IPath filePath = Activator.getAbsoluteFilePath(LTTNG_KERNEL_FILE);
51 IStatus status = thetrace.validate(null, filePath.toOSString());
52 if (!status.isOK()) {
53 fail(status.getException().getMessage());
54 }
55 try {
56 thetrace.initTrace(null, filePath.toOSString(), TmfEvent.class);
57 } catch (TmfTraceException e) {
58 fail(e.getMessage());
59 }
60
61 fTrace = thetrace;
62 fInput = new KernelStateProvider(thetrace, thetrace.getKernelEventLayout());
63 }
64
65 /**
66 * Class teardown
67 */
68 @After
69 public void classTeardown() {
70 if (fTrace != null) {
71 fTrace.dispose();
72 }
73 }
74
75 /**
76 * Test loading the state provider.
77 */
78 @Test
79 public void testOpening() {
80 long testStartTime;
81 testStartTime = fInput.getStartTime();
82 /* Expected start time of the trace */
83 assertEquals(testStartTime, 1L);
84 }
85
86 }
This page took 0.033204 seconds and 5 git commands to generate.