1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 É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
.Assert
.fail
;
18 import static org
.junit
.Assume
.assumeTrue
;
20 import java
.lang
.reflect
.InvocationTargetException
;
21 import java
.lang
.reflect
.Method
;
22 import java
.util
.LinkedList
;
23 import java
.util
.List
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.kernel
.core
.event
.matching
.TcpEventMatching
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.kernel
.core
.event
.matching
.TcpLttngEventMatching
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.event
.matching
.IMatchProcessingUnit
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.event
.matching
.TmfEventMatching
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.event
.matching
.TmfNetworkEventMatching
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
31 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTrace
;
32 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTmfTrace
;
33 import org
.junit
.Test
;
36 * Tests for {@link TcpEventMatching}
38 * @author Geneviève Bastien
40 @SuppressWarnings("nls")
41 public class MatchAndSyncTest
{
44 * Testing the packet matching
47 public void testMatching() {
48 assumeTrue(CtfTmfTestTrace
.SYNC_SRC
.exists());
49 assumeTrue(CtfTmfTestTrace
.SYNC_DEST
.exists());
50 try (CtfTmfTrace trace1
= CtfTmfTestTrace
.SYNC_SRC
.getTrace();
51 CtfTmfTrace trace2
= CtfTmfTestTrace
.SYNC_DEST
.getTrace();) {
53 List
<ITmfTrace
> tracearr
= new LinkedList
<>();
57 TmfEventMatching
.registerMatchObject(new TcpEventMatching());
58 TmfEventMatching
.registerMatchObject(new TcpLttngEventMatching());
60 TmfNetworkEventMatching twoTraceMatch
= new TmfNetworkEventMatching(tracearr
);
61 assertTrue(twoTraceMatch
.matchEvents());
63 /* Set method and fields accessible to make sure the counts are ok */
65 /* Verify number of matches */
66 Method method
= TmfEventMatching
.class.getDeclaredMethod("getProcessingUnit");
67 method
.setAccessible(true);
68 IMatchProcessingUnit procUnit
= (IMatchProcessingUnit
) method
.invoke(twoTraceMatch
);
69 assertEquals(46, procUnit
.countMatches());
71 } catch (NoSuchMethodException
| SecurityException
| IllegalAccessException
| IllegalArgumentException
| InvocationTargetException e
) {