Commit | Line | Data |
---|---|---|
e73a4ba5 | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2013, 2014 École Polytechnique de Montréal |
e73a4ba5 GB |
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 | ||
9bc60be7 | 13 | package org.eclipse.tracecompass.lttng2.kernel.core.tests.event.matchandsync; |
e73a4ba5 GB |
14 | |
15 | import static org.junit.Assert.assertEquals; | |
16 | import static org.junit.Assert.assertTrue; | |
4d2a4a2c | 17 | import static org.junit.Assert.fail; |
75b7c1bc | 18 | import static org.junit.Assume.assumeTrue; |
e73a4ba5 | 19 | |
4d2a4a2c GB |
20 | import java.lang.reflect.InvocationTargetException; |
21 | import java.lang.reflect.Method; | |
27213c57 AM |
22 | import java.util.LinkedList; |
23 | import java.util.List; | |
24 | ||
dc327459 GB |
25 | import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpEventMatching; |
26 | import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpLttngEventMatching; | |
4d2a4a2c | 27 | import org.eclipse.tracecompass.tmf.core.event.matching.IMatchProcessingUnit; |
2bdf0193 | 28 | import org.eclipse.tracecompass.tmf.core.event.matching.TmfEventMatching; |
2bdf0193 | 29 | import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; |
2bdf0193 | 30 | import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace; |
9722e5d7 | 31 | import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; |
e73a4ba5 GB |
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() { | |
75b7c1bc GB |
47 | assumeTrue(CtfTmfTestTrace.SYNC_SRC.exists()); |
48 | assumeTrue(CtfTmfTestTrace.SYNC_DEST.exists()); | |
0ff9e595 AM |
49 | CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace(); |
50 | CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace(); | |
e73a4ba5 | 51 | |
0ff9e595 AM |
52 | List<ITmfTrace> tracearr = new LinkedList<>(); |
53 | tracearr.add(trace1); | |
54 | tracearr.add(trace2); | |
e73a4ba5 | 55 | |
0ff9e595 AM |
56 | TmfEventMatching.registerMatchObject(new TcpEventMatching()); |
57 | TmfEventMatching.registerMatchObject(new TcpLttngEventMatching()); | |
e73a4ba5 | 58 | |
0ff9e595 AM |
59 | TmfEventMatching twoTraceMatch = new TmfEventMatching(tracearr); |
60 | assertTrue(twoTraceMatch.matchEvents()); | |
e73a4ba5 | 61 | |
0ff9e595 AM |
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()); | |
75b7c1bc | 69 | |
0ff9e595 AM |
70 | } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { |
71 | fail(e.getMessage()); | |
72 | } finally { | |
73 | trace1.dispose(); | |
74 | trace2.dispose(); | |
090c006e | 75 | } |
e73a4ba5 GB |
76 | } |
77 | ||
78 | } |