1 /*******************************************************************************
2 * Copyright (c) 2013 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are made
5 * 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 * Geneviève Bastien - Initial implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.lttng2
.kernel
.core
.tests
.event
.matchandsync
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.assertTrue
;
17 import static org
.junit
.Assume
.assumeTrue
;
19 import java
.util
.LinkedList
;
20 import java
.util
.List
;
22 import org
.eclipse
.tracecompass
.lttng2
.kernel
.core
.event
.matching
.TcpEventMatching
;
23 import org
.eclipse
.tracecompass
.lttng2
.kernel
.core
.event
.matching
.TcpLttngEventMatching
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.event
.matching
.TmfEventMatching
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.event
.matching
.TmfNetworkEventMatching
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
27 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.CtfTmfTrace
;
28 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTrace
;
29 import org
.junit
.Test
;
32 * Tests for {@link TcpEventMatching}
34 * @author Geneviève Bastien
36 @SuppressWarnings("nls")
37 public class MatchAndSyncTest
{
40 * Testing the packet matching
43 public void testMatching() {
44 final String cr
= System
.getProperty("line.separator");
45 assumeTrue(CtfTmfTestTrace
.SYNC_SRC
.exists());
46 assumeTrue(CtfTmfTestTrace
.SYNC_DEST
.exists());
47 try (CtfTmfTrace trace1
= CtfTmfTestTrace
.SYNC_SRC
.getTrace();
48 CtfTmfTrace trace2
= CtfTmfTestTrace
.SYNC_DEST
.getTrace();) {
50 List
<ITmfTrace
> tracearr
= new LinkedList
<>();
54 TmfEventMatching
.registerMatchObject(new TcpEventMatching());
55 TmfEventMatching
.registerMatchObject(new TcpLttngEventMatching());
57 TmfNetworkEventMatching twoTraceMatch
= new TmfNetworkEventMatching(tracearr
);
58 assertTrue(twoTraceMatch
.matchEvents());
60 String stats
= twoTraceMatch
.toString();
61 assertEquals("TmfEventMatches [ Number of matches found: 46 ]" +
63 " 3 unmatched incoming events" + cr
+
64 " 2 unmatched outgoing events" + cr
+
66 " 2 unmatched incoming events" + cr
+
67 " 1 unmatched outgoing events" + cr
, stats
);