From 65e13b73449f43f0dd80848eca67f731a18e8c92 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 23 Dec 2014 11:33:29 -0500 Subject: [PATCH] debug tests: Adapt thread name test for platforms that don't support them gdb only started reporting thread names at version 7.3. On Windows, they are never reported. If somebody wants to enhance the check for MAC OS X, feel free to do it! Change-Id: I9d028b24930b632678941682da65cd51da9e88dd Signed-off-by: Simon Marchi Reviewed-on: https://git.eclipse.org/r/38728 Reviewed-by: Marc Khouzam Tested-by: Marc Khouzam --- .../tests/dsf/gdb/tests/GDBProcessesTest.java | 20 +++++++++++++++---- .../tests/tests_7_3/GDBProcessesTest_7_3.java | 11 +++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBProcessesTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBProcessesTest.java index 58772e108fe..22eca349e66 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBProcessesTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBProcessesTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson and others. + * Copyright (c) 2009, 2014 Ericsson and others. * 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 @@ -7,6 +7,7 @@ * * Contributors: * Ericsson AB - Initial implementation of Test cases + * Simon Marchi (Ericsson) - Check for thread name support. *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests; @@ -135,7 +136,16 @@ public class GDBProcessesTest extends BaseTestCase { Assert.assertTrue("Process data should be executable name " + EXEC_NAME + "but we got " + processData.getName(), processData.getName().contains(EXEC_NAME)); } - + + /* + * Return whether thread names are reported by the debugger. + * + * This defaults to false, and is overridden for specific versions of gdb. + */ + protected boolean threadNamesSupported() { + return false; + } + /* * getThreadData() for multiple threads */ @@ -175,9 +185,11 @@ public class GDBProcessesTest extends BaseTestCase { Pattern pattern = Pattern.compile("\\d*", Pattern.MULTILINE); //$NON-NLS-1$ Matcher matcher = pattern.matcher(threadData.getId()); assertTrue("Thread ID is a series of number", matcher.find()); + // Check thread name - assertEquals("main thread's name is the name of the executable", EXEC_NAME, threadData.getName()); - + String expectedThreadName = threadNamesSupported() ? EXEC_NAME : ""; + assertEquals("main thread's name is wrong", expectedThreadName, threadData.getName()); + fWait.waitReset(); } } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/GDBProcessesTest_7_3.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/GDBProcessesTest_7_3.java index e05cfe101da..2135125cc51 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/GDBProcessesTest_7_3.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/GDBProcessesTest_7_3.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Ericsson and others. + * Copyright (c) 2011, 2014 Ericsson and others. * 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 @@ -7,6 +7,7 @@ * * Contributors: * Ericsson AB - Initial implementation of Test cases + * Simon Marchi (Ericsson) - Check for thread name support. *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3; @@ -21,4 +22,12 @@ public class GDBProcessesTest_7_3 extends GDBProcessesTest_7_2 { protected void setGdbVersion() { setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_3); } + + /* + * Thread names are reported starting with gdb 7.3, except on Windows. + */ + @Override + protected boolean threadNamesSupported() { + return !runningOnWindows(); + } } \ No newline at end of file