os.linux: Remove latency table view and use the one from timing
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests / src / org / eclipse / tracecompass / analysis / os / linux / ui / swtbot / tests / latency / SystemCallLatencyTableAnalysisTest.java
CommitLineData
b70c55af 1/*******************************************************************************
edded5c1 2 * Copyright (c) 2015, 2016 Ericsson
b70c55af
MK
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made 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 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests.latency;
14
b6fddb83
MK
15import static org.junit.Assert.assertEquals;
16import static org.junit.Assert.assertNotNull;
b6fddb83
MK
17import static org.junit.Assert.assertTrue;
18import static org.junit.Assert.fail;
b70c55af 19
973f89f2 20import java.io.IOException;
94d1ce7d 21
973f89f2 22import org.eclipse.core.runtime.FileLocator;
94d1ce7d
MK
23import org.eclipse.jdt.annotation.NonNull;
24import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
25import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
26import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
b70c55af 27import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
94d1ce7d 28import org.eclipse.swtbot.swt.finder.results.Result;
94d1ce7d 29import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
101bcc65
MK
30import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider;
31import org.eclipse.tracecompass.analysis.timing.ui.swtbot.tests.table.SegmentTableTest;
37b7faba 32import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.AbstractSegmentStoreTableView;
edded5c1 33import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.AbstractSegmentStoreTableViewer;
43439230 34import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.SegmentStoreTableView;
101bcc65
MK
35import org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.SystemCall;
36import org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.SystemCallLatencyAnalysis;
101bcc65 37import org.eclipse.tracecompass.segmentstore.core.ISegment;
973f89f2 38import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
94d1ce7d
MK
39import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
40import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
f0beeb4a 41import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils;
94d1ce7d
MK
42import org.eclipse.ui.IViewPart;
43import org.eclipse.ui.IViewReference;
94d1ce7d 44import org.junit.BeforeClass;
b70c55af
MK
45import org.junit.Test;
46import org.junit.runner.RunWith;
47
48/**
101bcc65
MK
49 * SystemCall Latency Table Test. This adds specific tests for the system call
50 * name for the TSV export and adds a column test.
94d1ce7d 51 *
b70c55af
MK
52 * @author Matthew Khouzam
53 */
54@RunWith(SWTBotJunit4ClassRunner.class)
101bcc65 55public class SystemCallLatencyTableAnalysisTest extends SegmentTableTest {
b70c55af 56
973f89f2
MK
57 private static final String TRACE_TYPE = "org.eclipse.linuxtools.lttng2.kernel.tracetype";
58 private static final String PROJECT_NAME = "test";
43439230
GB
59
60 private static final String PRIMARY_VIEW_ID = SegmentStoreTableView.ID;
61 private static final String SECONDARY_VIEW_ID = SystemCallLatencyAnalysis.ID;
101bcc65 62 private static final SystemCallLatencyAnalysis fSystemCallLatencyAnalysis = new SystemCallLatencyAnalysis();
94d1ce7d 63
101bcc65
MK
64 @Override
65 protected ISegmentStoreProvider getSegStoreProvider() {
66 return fSystemCallLatencyAnalysis;
67 }
94d1ce7d
MK
68
69 /**
70 * Things to setup
71 */
72 @BeforeClass
73 public static void beforeClass() {
101bcc65 74 SegmentTableTest.beforeClass();
94d1ce7d
MK
75 }
76
101bcc65
MK
77 @Override
78 protected AbstractSegmentStoreTableView openTable() {
94d1ce7d
MK
79 /*
80 * Open latency view
81 */
43439230 82 SWTBotUtils.openView(PRIMARY_VIEW_ID, SECONDARY_VIEW_ID);
94d1ce7d 83 SWTWorkbenchBot bot = new SWTWorkbenchBot();
43439230 84 SWTBotView viewBot = bot.viewById(PRIMARY_VIEW_ID);
94d1ce7d
MK
85 final IViewReference viewReference = viewBot.getViewReference();
86 IViewPart viewPart = UIThreadRunnable.syncExec(new Result<IViewPart>() {
87 @Override
88 public IViewPart run() {
89 return viewReference.getView(true);
90 }
91 });
92 assertNotNull(viewPart);
43439230 93 if (!(viewPart instanceof SegmentStoreTableView)) {
94d1ce7d
MK
94 fail("Could not instanciate view");
95 }
43439230 96 return (SegmentStoreTableView) viewPart;
94d1ce7d
MK
97 }
98
101bcc65
MK
99 @Override
100 protected @NonNull ISegment createSegment(long start, long end) {
101 // Notice the string is interned, that saves a lot of ram.
102 return new SystemCall(new SystemCall.InitialInfo(start, start % 3 == 0 ? "rightpad" : "leftpad"), end);
94d1ce7d
MK
103 }
104
94d1ce7d 105 @Test
101bcc65 106 @Override
94d1ce7d 107 public void climbTest() {
101bcc65
MK
108 super.climbTest();
109 SWTWorkbenchBot bot = new SWTWorkbenchBot();
110 SWTBotTable tableBot = new SWTBotTable(getTable().getTableViewer().getTable());
111 tableBot.header("System Call").click();
112 // this is an assert in the sense that it will timeout if it is not true
113 // FIXME: The first one should be leftpad, but because of preceding
114 // sorts, it first sort descending in this case
115 bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "rightpad", 0, 3));
116 tableBot.header("System Call").click();
117 bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "leftpad", 0, 3));
118 // Test that duration still works after having tested System Call
94d1ce7d 119 tableBot.header("Duration").click();
e92fbda6 120 bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
94d1ce7d 121 tableBot.header("Duration").click();
e92fbda6 122 bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "99", 0, 2));
101bcc65
MK
123 tableBot.header("Start Time").click();
124 bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "99", 0, 2));
37b7faba
MK
125 }
126
973f89f2
MK
127 /**
128 * Test with an actual trace, this is more of an integration test than a
129 * unit test. This test is a slow one too. If some analyses are not well
130 * configured, this test will also generates null pointer exceptions. These
131 * are will be logged.
132 *
133 * @throws IOException
134 * trace not found?
135 */
136 @Test
137 public void testWithTrace() throws IOException {
138 String tracePath;
139 tracePath = FileLocator.toFileURL(CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL()).getPath();
140 SWTWorkbenchBot bot = new SWTWorkbenchBot();
43439230 141 SWTBotView view = bot.viewById(PRIMARY_VIEW_ID);
973f89f2
MK
142 view.close();
143 bot.waitUntil(ConditionHelpers.ViewIsClosed(view));
144 SWTBotUtils.createProject(PROJECT_NAME);
145 SWTBotUtils.openTrace(PROJECT_NAME, tracePath, TRACE_TYPE);
f0beeb4a 146 WaitUtils.waitForJobs();
101bcc65
MK
147 AbstractSegmentStoreTableView tableView = openTable();
148 setTableView(tableView);
149 AbstractSegmentStoreTableViewer table = tableView.getSegmentStoreViewer();
150 assertNotNull(table);
151 setTable(table);
f0beeb4a 152 WaitUtils.waitForJobs();
101bcc65 153 SWTBotTable tableBot = new SWTBotTable(table.getTableViewer().getTable());
ef47abba 154 bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "24,100", 0, 2));
973f89f2 155 tableBot.header("Duration").click();
ef47abba 156 bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "1,000", 0, 2));
973f89f2 157 tableBot.header("Duration").click();
ef47abba 158 bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "5,904,091,700", 0, 2));
973f89f2
MK
159 bot.closeAllEditors();
160 SWTBotUtils.deleteProject(PROJECT_NAME, bot);
161 }
101bcc65
MK
162
163 @Override
164 protected void testTsv(String[] lines) {
165 assertNotNull(lines);
166 assertEquals("number of lines", 21, lines.length);
167 assertEquals("header", "Start Time\tEnd Time\tDuration\tSystem Call", lines[0]);
168 // not a straight up string compare due to time zones. Kathmandu and
169 // Eucla have 15 minute time zones.
170 assertTrue("line 1 : " + lines[1], lines[1].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s001\\t\\d\\d:\\d\\d:00.000 000 002\\t1\\tleftpad"));
171 assertTrue("line 2 : " + lines[2], lines[2].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s002\\t\\d\\d:\\d\\d:00.000 000 006\\t4\\tleftpad"));
172 assertTrue("line 3 : " + lines[3], lines[3].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s003\\t\\d\\d:\\d\\d:00.000 000 012\\t9\\trightpad"));
173 assertTrue("line 4 : " + lines[4], lines[4].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s004\\t\\d\\d:\\d\\d:00.000 000 020\\t16\\tleftpad"));
174 assertTrue("line 5 : " + lines[5], lines[5].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s005\\t\\d\\d:\\d\\d:00.000 000 030\\t25\\tleftpad"));
175 assertTrue("line 6 : " + lines[6], lines[6].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s006\\t\\d\\d:\\d\\d:00.000 000 042\\t36\\trightpad"));
176 assertTrue("line 7 : " + lines[7], lines[7].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s007\\t\\d\\d:\\d\\d:00.000 000 056\\t49\\tleftpad"));
177 assertTrue("line 8 : " + lines[8], lines[8].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s008\\t\\d\\d:\\d\\d:00.000 000 072\\t64\\tleftpad"));
178 assertTrue("line 9 : " + lines[9], lines[9].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s009\\t\\d\\d:\\d\\d:00.000 000 090\\t81\\trightpad"));
179 assertTrue("line 10 : " + lines[10], lines[10].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s010\\t\\d\\d:\\d\\d:00.000 000 110\\t100\\tleftpad"));
180 assertTrue("line 11 : " + lines[11], lines[11].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s011\\t\\d\\d:\\d\\d:00.000 000 132\\t121\\tleftpad"));
181 assertTrue("line 12 : " + lines[12], lines[12].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s012\\t\\d\\d:\\d\\d:00.000 000 156\\t144\\trightpad"));
182 assertTrue("line 13 : " + lines[13], lines[13].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s013\\t\\d\\d:\\d\\d:00.000 000 182\\t169\\tleftpad"));
183 assertTrue("line 14 : " + lines[14], lines[14].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s014\\t\\d\\d:\\d\\d:00.000 000 210\\t196\\tleftpad"));
184 assertTrue("line 15 : " + lines[15], lines[15].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s015\\t\\d\\d:\\d\\d:00.000 000 240\\t225\\trightpad"));
185 assertTrue("line 16 : " + lines[16], lines[16].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s016\\t\\d\\d:\\d\\d:00.000 000 272\\t256\\tleftpad"));
186 assertTrue("line 17 : " + lines[17], lines[17].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s017\\t\\d\\d:\\d\\d:00.000 000 306\\t289\\tleftpad"));
187 assertTrue("line 18 : " + lines[18], lines[18].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s018\\t\\d\\d:\\d\\d:00.000 000 342\\t324\\trightpad"));
188 assertTrue("line 19 : " + lines[19], lines[19].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s019\\t\\d\\d:\\d\\d:00.000 000 380\\t361\\tleftpad"));
189 assertTrue("line 20 : " + lines[20], lines[20].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s020\\t\\d\\d:\\d\\d:00.000 000 420\\t400\\tleftpad"));
190 }
b70c55af 191}
This page took 0.045524 seconds and 5 git commands to generate.