1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*******************************************************************************
* Copyright (c) 2013 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - Rodrigo Fraxino De Araujo <rfaraujo@br.ibm.com>
*******************************************************************************/
package org.eclipse.linuxtools.internal.perf.tests;
import java.util.ArrayList;
import java.util.Collections;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.Launch;
import org.eclipse.linuxtools.internal.perf.PerfPlugin;
import org.eclipse.linuxtools.internal.perf.launch.PerfEventsTab;
import org.eclipse.linuxtools.internal.perf.launch.PerfLaunchConfigDelegate;
import org.eclipse.linuxtools.internal.perf.remote.launch.PerfOptionsTab;
import org.eclipse.linuxtools.profiling.tests.AbstractRemoteTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class LaunchRemoteTest extends AbstractRemoteTest {
private ILaunchConfiguration config;
private PerfLaunchConfigDelegate delegate;
private ILaunch launch;
private ILaunchConfigurationWorkingCopy wc;
private IProject project;
private final String CONNECTION_DIR = "/tmp/eclipse-perf-ext_project_test/"; //$NON-NLS-1$
@Before
public void setUp() throws Exception {
if ((!(AbstractRemoteTest.USERNAME.isEmpty()))) {
project = null;
config = createConfiguration(project);
delegate = new PerfLaunchConfigDelegate();
launch = new Launch(config, ILaunchManager.PROFILE_MODE, null);
wc = config.getWorkingCopy();
setProfileAttributes(wc);
}
}
@After
public void tearDown() {
if (!(AbstractRemoteTest.USERNAME.isEmpty())) {
deleteResource(CONNECTION_DIR);
}
}
@Override
protected ILaunchConfigurationType getLaunchConfigType() {
return getLaunchManager().getLaunchConfigurationType(PerfPlugin.LAUNCHCONF_ID);
}
@Override
protected void setProfileAttributes(ILaunchConfigurationWorkingCopy wc) {
PerfEventsTab eventsTab = new PerfEventsTab();
PerfOptionsTab optionsTab = new PerfOptionsTab();
wc.setAttribute(PerfPlugin.ATTR_SourceLineNumbers, false);
eventsTab.setDefaults(wc);
optionsTab.setDefaults(wc);
}
@Test
public void testDefaultRun() throws CoreException {
if (!(AbstractRemoteTest.USERNAME.isEmpty())) {
delegate.launch(wc, ILaunchManager.PROFILE_MODE, launch, null);
}
}
@Test
public void testClockEventRun() throws CoreException {
if (!(AbstractRemoteTest.USERNAME.isEmpty())) {
ArrayList<String> list = new ArrayList<>();
Collections.addAll(list, "cpu-clock", "task-clock", "cycles");
wc.setAttribute(PerfPlugin.ATTR_DefaultEvent, false);
wc.setAttribute(PerfPlugin.ATTR_SelectedEvents, list);
delegate.launch(wc, ILaunchManager.PROFILE_MODE, launch, null);
}
}
}
|