Commit | Line | Data |
---|---|---|
e73a4ba5 GB |
1 | /******************************************************************************* |
2 | * Copyright (c) 2013 É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.linuxtools.lttng2.kernel.core.tests.event.matchandsync; | |
14 | ||
15 | import static org.junit.Assert.assertEquals; | |
16 | import static org.junit.Assert.assertTrue; | |
17 | ||
18 | import org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpEventMatching; | |
19 | import org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpLttngEventMatching; | |
20 | import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; | |
21 | import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatching; | |
22 | import org.eclipse.linuxtools.tmf.core.event.matching.TmfNetworkEventMatching; | |
23 | import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; | |
24 | import org.junit.Test; | |
25 | ||
26 | /** | |
27 | * Tests for {@link TcpEventMatching} | |
28 | * | |
29 | * @author Geneviève Bastien | |
30 | */ | |
31 | @SuppressWarnings("nls") | |
32 | public class MatchAndSyncTest { | |
33 | ||
34 | /** | |
35 | * Testing the packet matching | |
36 | */ | |
37 | @Test | |
38 | public void testMatching() { | |
39 | final String cr = System.getProperty("line.separator"); | |
40 | CtfTmfTrace trace1 = CtfTmfTestTraces.getTestTrace(3); | |
41 | CtfTmfTrace trace2 = CtfTmfTestTraces.getTestTrace(4); | |
42 | ||
43 | CtfTmfTrace[] tracearr = new CtfTmfTrace[2]; | |
44 | tracearr[0] = trace1; | |
45 | tracearr[1] = trace2; | |
46 | ||
47 | TmfEventMatching.registerMatchObject(new TcpEventMatching()); | |
48 | TmfEventMatching.registerMatchObject(new TcpLttngEventMatching()); | |
49 | ||
50 | TmfNetworkEventMatching twoTraceMatch = new TmfNetworkEventMatching(tracearr); | |
51 | assertTrue(twoTraceMatch.matchEvents()); | |
52 | ||
53 | String stats = twoTraceMatch.toString(); | |
54 | assertEquals("TmfEventMatches [ Number of matches found: 46 ]" + | |
55 | "Trace 0:" + cr + | |
56 | " 3 unmatched incoming events" + cr + | |
57 | " 2 unmatched outgoing events" + cr + | |
58 | "Trace 1:" + cr + | |
59 | " 2 unmatched incoming events" + cr + | |
60 | " 1 unmatched outgoing events" + cr, stats); | |
61 | } | |
62 | ||
63 | } |