1 /*******************************************************************************
2 * Copyright (c) 2014 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 * Vincent Perot - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.pcap
.core
.tests
.shared
;
15 import org
.eclipse
.jdt
.annotation
.NonNull
;
16 import org
.eclipse
.jdt
.annotation
.NonNullByDefault
;
17 import org
.eclipse
.jdt
.annotation
.Nullable
;
18 import org
.eclipse
.linuxtools
.internal
.tmf
.pcap
.core
.event
.PcapEvent
;
19 import org
.eclipse
.linuxtools
.internal
.tmf
.pcap
.core
.trace
.PcapTrace
;
20 import org
.eclipse
.linuxtools
.pcap
.core
.tests
.shared
.PcapTestTrace
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
22 import org
.eclipse
.linuxtools
.tmf
.pcap
.core
.tests
.stubs
.PcapTmfTraceStub
;
25 * Available Pcap TMF test traces. Kind-of-extends {@link PcapTestTrace}.
27 * To run tests using these, you first need to run the "get-traces.[xml|sh]"
28 * script located under lttng/org.eclipse.linuxtools.pcap.core.tests/rsc/ .
30 * @author Vincent Perot
33 public enum PcapTmfTestTrace
{
34 /** A bad pcap file. */
37 /** A Valid Pcap that is empty. */
40 /** A Pcap that mostly contains TCP packets. */
43 /** A Pcap that mostly contains UDP packets. */
46 /** A big-endian trace that contains two packets. */
49 /** A little-endian trace that contains two packets. */
52 /** A trace used for benchmarking. */
55 /** A Kernel trace directory. */
58 /** A Kernel trace file. */
61 private final String fPath
;
62 private @Nullable PcapTmfTraceStub fTrace
= null;
64 private PcapTmfTestTrace() {
65 @SuppressWarnings("null")
66 @NonNull String path
= PcapTestTrace
.valueOf(this.name()).getPath().toString();
71 * @return The path of this trace
73 public String
getPath() {
78 * Return a PcapTmfTraceStub object of this test trace. It will be already
81 * Make sure you call {@link #exists()} before calling this!
83 * After being used by unit tests, traces must be properly disposed of by
84 * calling the {@link PcapTmfTestTrace#dispose()} method.
86 * @return A PcapTmfTrace reference to this trace
88 public synchronized PcapTrace
getTrace() {
89 PcapTmfTraceStub trace
= fTrace
;
93 trace
= new PcapTmfTraceStub();
95 trace
.initTrace(null, fPath
, PcapEvent
.class);
96 } catch (TmfTraceException e
) {
97 /* Should not happen if tracesExist() passed */
98 throw new RuntimeException(e
);
105 * Check if the trace actually exists on disk or not.
107 * @return If the trace is present
109 public boolean exists() {
110 return PcapTestTrace
.valueOf(this.name()).exists();
114 * Dispose of the trace
116 public void dispose() {
117 if (fTrace
!= null) {
This page took 0.03307 seconds and 5 git commands to generate.