29aa3ad59d49b5475af189fb7640fad070444f04
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.kernel.core.tests / src / org / eclipse / tracecompass / lttng2 / kernel / core / tests / event / matchandsync / MatchAndSyncTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
3 *
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
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.lttng2.kernel.core.tests.event.matchandsync;
14
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;
19
20 import java.lang.reflect.InvocationTargetException;
21 import java.lang.reflect.Method;
22 import java.util.LinkedList;
23 import java.util.List;
24
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.trace.ITmfTrace;
30 import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
31 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
32 import org.junit.Test;
33
34 /**
35 * Tests for {@link TcpEventMatching}
36 *
37 * @author Geneviève Bastien
38 */
39 @SuppressWarnings("nls")
40 public class MatchAndSyncTest {
41
42 /**
43 * Testing the packet matching
44 */
45 @Test
46 public void testMatching() {
47 assumeTrue(CtfTmfTestTrace.SYNC_SRC.exists());
48 assumeTrue(CtfTmfTestTrace.SYNC_DEST.exists());
49 try (CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
50 CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();) {
51
52 List<ITmfTrace> tracearr = new LinkedList<>();
53 tracearr.add(trace1);
54 tracearr.add(trace2);
55
56 TmfEventMatching.registerMatchObject(new TcpEventMatching());
57 TmfEventMatching.registerMatchObject(new TcpLttngEventMatching());
58
59 TmfEventMatching twoTraceMatch = new TmfEventMatching(tracearr);
60 assertTrue(twoTraceMatch.matchEvents());
61
62 /* Set method and fields accessible to make sure the counts are ok */
63 try {
64 /* Verify number of matches */
65 Method method = TmfEventMatching.class.getDeclaredMethod("getProcessingUnit");
66 method.setAccessible(true);
67 IMatchProcessingUnit procUnit = (IMatchProcessingUnit) method.invoke(twoTraceMatch);
68 assertEquals(46, procUnit.countMatches());
69
70 } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
71 fail(e.getMessage());
72 }
73
74 }
75 }
76
77 }
This page took 0.04243 seconds and 4 git commands to generate.