1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Vincent Perot - Initial API and implementation
10 *******************************************************************************/
12 package org
.eclipse
.tracecompass
.pcap
.core
.tests
.shared
;
14 import java
.io
.IOException
;
15 import java
.nio
.file
.FileSystems
;
16 import java
.nio
.file
.Files
;
17 import java
.nio
.file
.Path
;
19 import org
.eclipse
.jdt
.annotation
.NonNull
;
20 import org
.eclipse
.tracecompass
.internal
.pcap
.core
.trace
.BadPcapFileException
;
21 import org
.eclipse
.tracecompass
.internal
.pcap
.core
.trace
.PcapFile
;
24 * Here is the list of the available test traces for the Pcap parser.
26 * @author Vincent Perot
28 public enum PcapTestTrace
{
30 /** A bad pcap file. */
31 BAD_PCAPFILE("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "BadPcapFile.pcap"),
33 /** A Valid Pcap that is empty. */
34 EMPTY_PCAP("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "EmptyPcap.pcap"),
36 /** A Pcap that mostly contains TCP packets. */
37 MOSTLY_TCP("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "mostlyTCP.pcap"),
39 /** A Pcap that mostly contains UDP packets. */
40 MOSTLY_UDP("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "mostlyUDP.pcap"),
42 /** A big-endian trace that contains two packets. */
43 SHORT_BIG_ENDIAN("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "Short_BigEndian.pcap"),
45 /** A little-endian trace that contains two packets. */
46 SHORT_LITTLE_ENDIAN("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "Short_LittleEndian.pcap"),
48 /** A large trace for benchmarking. */
49 BENCHMARK_TRACE("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "benchmarkTrace.pcap"),
51 /** A Kernel trace directory. */
52 KERNEL_DIRECTORY("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "kernel"),
54 /** A Kernel trace file. */
55 KERNEL_TRACE("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "kernel", "channel0_0");
57 private final @NonNull Path fPath
;
59 private PcapTestTrace(@NonNull String first
, String
... more
) {
60 @SuppressWarnings("null")
61 @NonNull Path path
= FileSystems
.getDefault().getPath(first
, more
);
65 /** @return The path to the test trace */
66 public @NonNull Path
getPath() {
71 * Get a Pcap Trace instance of a test trace. Make sure to call
72 * {@link #exists()} before calling this!
74 * @return The PcapFile object
76 * Thrown when some IO error occurs.
77 * @throws BadPcapFileException
78 * Thrown when the file is not a valid Pcap File.
80 public PcapFile
getTrace() throws BadPcapFileException
, IOException
{
81 return new PcapFile(fPath
);
85 * Check if this test trace actually exists on disk.
87 * @return If the trace exists
89 public boolean exists() {
90 if (Files
.notExists(fPath
)) {
This page took 0.068774 seconds and 5 git commands to generate.