Search in sources :

Example 41 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.

the class SignalTest method testSegfaultHandle.

@Test
public void testSegfaultHandle() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testSegfault");
    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    IValgrindMessage[] messages = view.getMessages();
    assertTrue(messages.length > 0);
    // $NON-NLS-1$
    assertTrue(messages[0].getText().contains("SIGSEGV"));
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) Test(org.junit.Test)

Example 42 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.

the class AbstractValgrindTest method tearDown.

@After
public void tearDown() throws CoreException {
    ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
    if (launches.size() > 0) {
        lm.removeLaunches(launches.toArray(new ILaunch[launches.size()]));
        launches.clear();
    }
    // Delete the Launch Configurations
    ILaunchConfiguration[] configs = lm.getLaunchConfigurations();
    for (ILaunchConfiguration config : configs) {
        config.delete();
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunch(org.eclipse.debug.core.ILaunch) ILaunchManager(org.eclipse.debug.core.ILaunchManager) After(org.junit.After)

Example 43 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.

the class WrongDeallocationResolutionTest method prep.

@Before
public void prep() throws Exception {
    // $NON-NLS-1$
    proj = createProjectAndBuild("wrongDeallocTest");
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "wrongDeallocTest");
    document = new Document();
    InputStream fileInputStream = proj.getProject().getFile("wrongDealloc.cpp").getContents();
    try (Scanner scanner = new Scanner(fileInputStream)) {
        // $NON-NLS-1$
        scanner.useDelimiter("\\A");
        String content;
        if (scanner.hasNext()) {
            content = scanner.next();
        } else {
            content = EMPTY_STRING;
        }
        document.set(content);
    }
    markers = proj.getProject().findMarkers(VALGRIND_MARKER_TYPE, true, 1);
    Arrays.sort(markers, new MarkerComparator());
}
Also used : Scanner(java.util.Scanner) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) InputStream(java.io.InputStream) Document(org.eclipse.jface.text.Document) Before(org.junit.Before)

Example 44 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldUpdateLaunchConfigurationWhenConnectionNameChanged.

@Test
public void shouldUpdateLaunchConfigurationWhenConnectionNameChanged() throws CoreException {
    // given
    final IDockerConnection connection = configureTCPConnection("Test");
    final String buildImageLaunchConfigurationName = configureBuildImageLaunchConfiguration(connection);
    final ILaunchConfiguration buildDockerImageLaunchConfig = LaunchConfigurationUtils.getLaunchConfigurationByName(IBuildDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, buildImageLaunchConfigurationName);
    assertThat(buildDockerImageLaunchConfig).isNotNull();
    assertThat(buildDockerImageLaunchConfig.getAttribute(IDockerImageBuildOptions.DOCKER_CONNECTION, "")).isEqualTo("Test");
    final String runImageLaunchConfigurationName = configureRunImageLaunchConfiguration(connection, "bridge");
    final ILaunchConfiguration runDockerImageLaunchConfig = LaunchConfigurationUtils.getLaunchConfigurationByName(IRunDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, runImageLaunchConfigurationName);
    assertThat(runDockerImageLaunchConfig).isNotNull();
    assertThat(runDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.CONNECTION_NAME, "")).isEqualTo("Test");
    assertThat(runDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.NETWORK_MODE, "")).isEqualTo("bridge");
    // when
    openConnectionEditionWizard("Test");
    bot.text(0).setText("foo");
    getFinishButton().click();
    // then
    final ILaunchConfiguration updatedBuildDockerImageLaunchConfig = LaunchConfigurationUtils.getLaunchConfigurationByName(IBuildDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, buildImageLaunchConfigurationName);
    assertThat(updatedBuildDockerImageLaunchConfig).isNotNull();
    assertThat(updatedBuildDockerImageLaunchConfig.getAttribute(IDockerImageBuildOptions.DOCKER_CONNECTION, "")).isEqualTo("foo");
    final ILaunchConfiguration updatedRunDockerImageLaunchConfig = LaunchConfigurationUtils.getLaunchConfigurationByName(IRunDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, runImageLaunchConfigurationName);
    assertThat(updatedRunDockerImageLaunchConfig).isNotNull();
    assertThat(updatedRunDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.CONNECTION_NAME, "")).isEqualTo("foo");
    assertThat(updatedRunDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.NETWORK_MODE, "")).isEqualTo("bridge");
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) Test(org.junit.Test)

Example 45 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.

the class ImageRunSWTBotTest method shouldCreateLaunchConfigurationWhenRunningNamedContainer.

@Test
public void shouldCreateLaunchConfigurationWhenRunningNamedContainer() throws InterruptedException, DockerException, CoreException {
    // images to use
    final String imageName = "foo/bar:latest";
    final Image image = MockImageFactory.id("1a2b3c4d5e6f7g").name(imageName).build();
    final ImageInfo imageInfo = MockImageInfoFactory.volume("/foo/bar").command(Arrays.asList("the", "command")).entrypoint(Arrays.asList("the", "entrypoint")).build();
    // container to be created
    final String containerName = "foo_bar";
    final Container createdContainer = MockContainerFactory.id("MockContainer").name(containerName).imageName("1a2b3c4d5e6f7g").status("Started 1 second ago").build();
    final ContainerInfo containerInfo = MockContainerInfoFactory.build();
    final DockerClient client = MockDockerClientFactory.image(image, imageInfo).build();
    // expected response when creating the container
    final ContainerCreation containerCreation = Mockito.mock(ContainerCreation.class);
    Mockito.when(containerCreation.id()).thenReturn("MockContainer");
    Mockito.when(client.createContainer(Matchers.any(), Matchers.any())).thenReturn(containerCreation);
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    // configure the Connection Manager
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // when select images and click on run to open the wizard
    SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images", "foo/bar").select();
    dockerExplorerViewBot.bot().tree().contextMenu("Run...").click();
    // $NON-NLS-1$
    bot.waitUntil(Conditions.shellIsActive("Run a Docker Image"), TimeUnit.SECONDS.toMillis(1));
    // configure container
    bot.text(0).setText(containerName);
    // bot.button("Next >").click();
    // update the client to make sure the container exists once the call to "Finish" is done
    MockDockerClientFactory.addContainer(client, createdContainer, containerInfo);
    bot.button("Finish").click();
    // wait for background job to complete
    SWTUtils.waitForJobsToComplete();
    // then
    // check that the client was called
    Mockito.verify(client).createContainer(Matchers.any(), Matchers.eq(containerName));
    // check that a launch configuration was created
    final ILaunchConfiguration launchConfiguration = LaunchConfigurationUtils.getLaunchConfigurationByName(IRunDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, "foo_bar_latest");
    assertThat(launchConfiguration).isNotNull();
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) ContainerCreation(com.spotify.docker.client.messages.ContainerCreation) Container(com.spotify.docker.client.messages.Container) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) DockerClient(com.spotify.docker.client.DockerClient) ContainerInfo(com.spotify.docker.client.messages.ContainerInfo) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) Image(com.spotify.docker.client.messages.Image) ImageInfo(com.spotify.docker.client.messages.ImageInfo) Test(org.junit.Test)

Aggregations

ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)266 CoreException (org.eclipse.core.runtime.CoreException)96 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)76 Test (org.junit.Test)72 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)50 ILaunchManager (org.eclipse.debug.core.ILaunchManager)40 ArrayList (java.util.ArrayList)37 ILaunch (org.eclipse.debug.core.ILaunch)35 IProject (org.eclipse.core.resources.IProject)20 IPath (org.eclipse.core.runtime.IPath)20 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)16 IEditorPart (org.eclipse.ui.IEditorPart)15 IStatus (org.eclipse.core.runtime.IStatus)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 IFile (org.eclipse.core.resources.IFile)13 IProcess (org.eclipse.debug.core.model.IProcess)13 CachegrindViewPart (org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart)13 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)11 Shell (org.eclipse.swt.widgets.Shell)10 ElementListSelectionDialog (org.eclipse.ui.dialogs.ElementListSelectionDialog)10