diff options
author | Alexander Kurtakov | 2016-01-26 08:30:59 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2016-01-26 10:36:21 +0000 |
commit | 4d13c66f2ae2c1b3fbad83a0cd7d0565122d8079 (patch) | |
tree | c45224ffaa1c2650f26df7f9b71231109d730a27 /valgrind | |
parent | c15594a8654e98aab279a8d704edbd8042233ced (diff) | |
download | org.eclipse.linuxtools-4d13c66f2ae2c1b3fbad83a0cd7d0565122d8079.tar.gz org.eclipse.linuxtools-4d13c66f2ae2c1b3fbad83a0cd7d0565122d8079.tar.xz org.eclipse.linuxtools-4d13c66f2ae2c1b3fbad83a0cd7d0565122d8079.zip |
valgrind: Tests cleanup.
* Remove eclipse.valgrind.tests.runValgrind property as unused now.
* Other unused properties.
* Hide some methods.
* Enable format save action.
Change-Id: Ifc153bc65ded784b90df5cdb10cbe37b2153989f
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Reviewed-on: https://git.eclipse.org/r/65160
Tested-by: Hudson CI
Diffstat (limited to 'valgrind')
5 files changed, 215 insertions, 259 deletions
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.tests/.settings/org.eclipse.jdt.core.prefs b/valgrind/org.eclipse.linuxtools.valgrind.tests/.settings/org.eclipse.jdt.core.prefs index 7ce4ae8ef2..3931296f6b 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.tests/.settings/org.eclipse.jdt.core.prefs +++ b/valgrind/org.eclipse.linuxtools.valgrind.tests/.settings/org.eclipse.jdt.core.prefs @@ -2,10 +2,14 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 @@ -84,16 +88,17 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.8 diff --git a/valgrind/org.eclipse.linuxtools.valgrind.tests/.settings/org.eclipse.jdt.ui.prefs b/valgrind/org.eclipse.linuxtools.valgrind.tests/.settings/org.eclipse.jdt.ui.prefs index 9795a6f906..e8e47bc5f9 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.tests/.settings/org.eclipse.jdt.ui.prefs +++ b/valgrind/org.eclipse.linuxtools.valgrind.tests/.settings/org.eclipse.jdt.ui.prefs @@ -13,10 +13,12 @@ sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false -sp_cleanup.format_source_code=false +sp_cleanup.format_source_code=true sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false sp_cleanup.make_private_fields_final=true @@ -32,6 +34,7 @@ sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class= sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_type_arguments=false sp_cleanup.remove_trailing_whitespaces=true sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false @@ -45,10 +48,13 @@ sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false sp_cleanup.use_blocks=false sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=false sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=false sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true sp_cleanup.use_this_for_non_static_method_access=false sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_type_arguments=false diff --git a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/AbstractValgrindTest.java b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/AbstractValgrindTest.java index 49f0720db7..aaaa04ca00 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/AbstractValgrindTest.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/AbstractValgrindTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. + * Copyright (c) 2009, 2016 Red Hat, Inc. * 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 @@ -48,169 +48,144 @@ import org.osgi.framework.FrameworkUtil; public abstract class AbstractValgrindTest extends AbstractTest { - private static final String TEMPLATE_PREFIX = "template_"; //$NON-NLS-1$ - private static final FileFilter TEMPLATE_FILTER = new FileFilter() { - @Override - public boolean accept(File pathname) { - return pathname.getName().startsWith(TEMPLATE_PREFIX) - && !pathname.isHidden(); - } - }; - private static final FileFilter NOT_TEMPLATE_FILTER = new FileFilter() { - @Override - public boolean accept(File pathname) { - return !pathname.getName().startsWith(TEMPLATE_PREFIX) - && !pathname.isHidden(); - } - }; - - private static final String SEARCH_STRING_WS = "XXXXXXXXXXXX"; //$NON-NLS-1$ - private static final String SEARCH_STRING_BL = "YYYYYYYYYYYY"; //$NON-NLS-1$ - - private List<ILaunch> launches; - - @Before - public void setUp() { - launches = new ArrayList<>(); - - // Substitute Valgrind command line interaction - ValgrindLaunchPlugin.getDefault().setValgrindCommand( - getValgrindCommand()); - } - - @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(); - } - } - - @Override - protected ILaunchConfigurationType getLaunchConfigType() { - return getLaunchManager().getLaunchConfigurationType( - ValgrindLaunchPlugin.LAUNCH_ID); - } - - protected ILaunch doLaunch(ILaunchConfiguration config, String testName) - throws URISyntaxException, IOException, CoreException { - ILaunch launch; - IPath pathToFiles = getPathToFiles(testName); - - if (!ValgrindTestsPlugin.RUN_VALGRIND) { - bindLocation(pathToFiles); - } - - ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); - wc.setAttribute(LaunchConfigurationConstants.ATTR_INTERNAL_OUTPUT_DIR, - pathToFiles.toOSString()); - wc.doSave(); - - ValgrindTestLaunchDelegate delegate = new ValgrindTestLaunchDelegate(); - launch = new Launch(config, ILaunchManager.PROFILE_MODE, null); - - DebugPlugin.getDefault().getLaunchManager().addLaunch(launch); - launches.add(launch); - delegate.launch(config, ILaunchManager.PROFILE_MODE, launch, null); - - if (ValgrindTestsPlugin.GENERATE_FILES - && ValgrindTestsPlugin.versionSupported()) { - unbindLocation(pathToFiles); - } - return launch; - } - - protected IPath getPathToFiles(String testName) throws URISyntaxException, - IOException { - URL location = FileLocator.find(getBundle(), - new Path("valgrindFiles"), null); //$NON-NLS-1$ - File file = new File(FileLocator.toFileURL(location).toURI()); - IPath pathToFiles = new Path(file.getCanonicalPath()).append(testName); - return pathToFiles; - } - - private void unbindLocation(IPath pathToFiles) throws IOException { - String bundleLoc = FileLocator.getBundleFile(getBundle()) - .getCanonicalPath(); - String workspaceLoc = ResourcesPlugin.getWorkspace().getRoot() - .getLocation().toOSString(); - File testDir = pathToFiles.toFile(); - for (File log : testDir.listFiles(NOT_TEMPLATE_FILTER)) { - File template = new File(testDir, TEMPLATE_PREFIX + log.getName()); - replaceLocation(log, template, new String[] { bundleLoc, - workspaceLoc }, new String[] { SEARCH_STRING_BL, - SEARCH_STRING_WS }); - } - } - - private void bindLocation(IPath pathToFiles) throws IOException { - String bundleLoc = FileLocator.getBundleFile(getBundle()) - .getCanonicalPath(); - String workspaceLoc = ResourcesPlugin.getWorkspace().getRoot() - .getLocation().toOSString(); - File testDir = pathToFiles.toFile(); - for (File template : testDir.listFiles(TEMPLATE_FILTER)) { - String name = template.getName().replace(TEMPLATE_PREFIX, ""); //$NON-NLS-1$ - File log = new File(testDir, name.substring(name - .indexOf(TEMPLATE_PREFIX) + 1)); - replaceLocation(template, log, new String[] { SEARCH_STRING_BL, - SEARCH_STRING_WS }, - new String[] { bundleLoc, workspaceLoc }); - } - } - - private void replaceLocation(File oldFile, File newFile, String[] from, - String[] to) { - if (oldFile.isFile()) { - try (BufferedReader br = new BufferedReader(new FileReader(oldFile)); - PrintWriter pw = new PrintWriter(new FileWriter(newFile))) { - String line; - while ((line = br.readLine()) != null) { - for (int i = 0; i < from.length; i++) { - line = line.replaceAll(from[i], to[i]); - } - pw.println(line); - } - - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - @Override - protected void setProfileAttributes(ILaunchConfigurationWorkingCopy wc) - throws CoreException { - ILaunchConfigurationTab tab = new ValgrindOptionsTab(); - tab.setDefaults(wc); - tab = ValgrindLaunchPlugin.getDefault().getToolPage(getToolID()); - tab.setDefaults(wc); - wc.setAttribute(LaunchConfigurationConstants.ATTR_TOOL, getToolID()); - wc.setAttribute(LaunchConfigurationConstants.ATTR_FULLPATH_AFTER, false); - } - - protected ICProject createProjectAndBuild(String projname) throws Exception { - return createProjectAndBuild(getBundle(), projname); - } - - protected Bundle getBundle() { - return FrameworkUtil.getBundle(this.getClass()); - } - - protected abstract String getToolID(); - - private ValgrindCommand getValgrindCommand() { - if (!ValgrindTestsPlugin.RUN_VALGRIND) { - return new ValgrindStubCommand(); - } else { - return new ValgrindCommand(); - } - } + private static final String TEMPLATE_PREFIX = "template_"; //$NON-NLS-1$ + private static final FileFilter TEMPLATE_FILTER = pathname -> pathname.getName().startsWith(TEMPLATE_PREFIX) + && !pathname.isHidden(); + private static final FileFilter NOT_TEMPLATE_FILTER = pathname -> !pathname.getName().startsWith(TEMPLATE_PREFIX) + && !pathname.isHidden(); + + private static final String SEARCH_STRING_WS = "XXXXXXXXXXXX"; //$NON-NLS-1$ + private static final String SEARCH_STRING_BL = "YYYYYYYYYYYY"; //$NON-NLS-1$ + + private List<ILaunch> launches; + + @Before + public void setUp() { + launches = new ArrayList<>(); + + // Substitute Valgrind command line interaction + ValgrindLaunchPlugin.getDefault().setValgrindCommand(getValgrindCommand()); + } + + @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(); + } + } + + @Override + protected ILaunchConfigurationType getLaunchConfigType() { + return getLaunchManager().getLaunchConfigurationType(ValgrindLaunchPlugin.LAUNCH_ID); + } + + protected ILaunch doLaunch(ILaunchConfiguration config, String testName) + throws URISyntaxException, IOException, CoreException { + ILaunch launch; + IPath pathToFiles = getPathToFiles(testName); + + if (!ValgrindTestsPlugin.RUN_VALGRIND) { + bindLocation(pathToFiles); + } + + ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); + wc.setAttribute(LaunchConfigurationConstants.ATTR_INTERNAL_OUTPUT_DIR, pathToFiles.toOSString()); + wc.doSave(); + + ValgrindTestLaunchDelegate delegate = new ValgrindTestLaunchDelegate(); + launch = new Launch(config, ILaunchManager.PROFILE_MODE, null); + + DebugPlugin.getDefault().getLaunchManager().addLaunch(launch); + launches.add(launch); + delegate.launch(config, ILaunchManager.PROFILE_MODE, launch, null); + + if (ValgrindTestsPlugin.RUN_VALGRIND) { + unbindLocation(pathToFiles); + } + return launch; + } + + private IPath getPathToFiles(String testName) throws URISyntaxException, IOException { + URL location = FileLocator.find(getBundle(), new Path("valgrindFiles"), null); //$NON-NLS-1$ + File file = new File(FileLocator.toFileURL(location).toURI()); + IPath pathToFiles = new Path(file.getCanonicalPath()).append(testName); + return pathToFiles; + } + + private void unbindLocation(IPath pathToFiles) throws IOException { + String bundleLoc = FileLocator.getBundleFile(getBundle()).getCanonicalPath(); + String workspaceLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString(); + File testDir = pathToFiles.toFile(); + for (File log : testDir.listFiles(NOT_TEMPLATE_FILTER)) { + File template = new File(testDir, TEMPLATE_PREFIX + log.getName()); + replaceLocation(log, template, new String[] { bundleLoc, workspaceLoc }, + new String[] { SEARCH_STRING_BL, SEARCH_STRING_WS }); + } + } + + private void bindLocation(IPath pathToFiles) throws IOException { + String bundleLoc = FileLocator.getBundleFile(getBundle()).getCanonicalPath(); + String workspaceLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString(); + File testDir = pathToFiles.toFile(); + for (File template : testDir.listFiles(TEMPLATE_FILTER)) { + String name = template.getName().replace(TEMPLATE_PREFIX, ""); //$NON-NLS-1$ + File log = new File(testDir, name.substring(name.indexOf(TEMPLATE_PREFIX) + 1)); + replaceLocation(template, log, new String[] { SEARCH_STRING_BL, SEARCH_STRING_WS }, + new String[] { bundleLoc, workspaceLoc }); + } + } + + private void replaceLocation(File oldFile, File newFile, String[] from, String[] to) { + if (oldFile.isFile()) { + try (BufferedReader br = new BufferedReader(new FileReader(oldFile)); + PrintWriter pw = new PrintWriter(new FileWriter(newFile))) { + String line; + while ((line = br.readLine()) != null) { + for (int i = 0; i < from.length; i++) { + line = line.replaceAll(from[i], to[i]); + } + pw.println(line); + } + + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + @Override + protected void setProfileAttributes(ILaunchConfigurationWorkingCopy wc) throws CoreException { + ILaunchConfigurationTab tab = new ValgrindOptionsTab(); + tab.setDefaults(wc); + tab = ValgrindLaunchPlugin.getDefault().getToolPage(getToolID()); + tab.setDefaults(wc); + wc.setAttribute(LaunchConfigurationConstants.ATTR_TOOL, getToolID()); + wc.setAttribute(LaunchConfigurationConstants.ATTR_FULLPATH_AFTER, false); + } + + protected ICProject createProjectAndBuild(String projname) throws Exception { + return createProjectAndBuild(getBundle(), projname); + } + + protected Bundle getBundle() { + return FrameworkUtil.getBundle(this.getClass()); + } + + protected abstract String getToolID(); + + private ValgrindCommand getValgrindCommand() { + if (!ValgrindTestsPlugin.RUN_VALGRIND) { + return new ValgrindStubCommand(); + } else { + return new ValgrindCommand(); + } + } }
\ No newline at end of file diff --git a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestLaunchDelegate.java b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestLaunchDelegate.java index f305426e3b..090a2904c7 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestLaunchDelegate.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestLaunchDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. + * Copyright (c) 2009, 2016 Red Hat, Inc. * 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 @@ -20,45 +20,40 @@ import org.eclipse.debug.core.model.IProcess; import org.eclipse.linuxtools.internal.valgrind.core.ValgrindCommand; import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchConfigurationDelegate; -public class ValgrindTestLaunchDelegate extends - ValgrindLaunchConfigurationDelegate { - - @Override - protected ValgrindCommand getValgrindCommand() { - if (!ValgrindTestsPlugin.RUN_VALGRIND) { - return new ValgrindStubCommand(); - } else { - return super.getValgrindCommand(); - } - } - - @Override - protected void createDirectory(IPath path) throws IOException { - if (ValgrindTestsPlugin.RUN_VALGRIND) { - super.createDirectory(path); - } - } - - @Override - protected IProcess createNewProcess(ILaunch launch, Process systemProcess, - String programName) { - IProcess process; - if (ValgrindTestsPlugin.RUN_VALGRIND) { - process = super - .createNewProcess(launch, systemProcess, programName); - } else { - process = new ValgrindStubProcess(launch, programName); - } - return process; - } - - @Override - protected void setOutputPath(ILaunchConfiguration config, IPath outputPath) - throws CoreException { - if (!ValgrindTestsPlugin.GENERATE_FILES - && ValgrindTestsPlugin.RUN_VALGRIND) { - super.setOutputPath(config, outputPath); - } - } +public class ValgrindTestLaunchDelegate extends ValgrindLaunchConfigurationDelegate { + + @Override + protected ValgrindCommand getValgrindCommand() { + if (!ValgrindTestsPlugin.RUN_VALGRIND) { + return new ValgrindStubCommand(); + } else { + return super.getValgrindCommand(); + } + } + + @Override + protected void createDirectory(IPath path) throws IOException { + if (ValgrindTestsPlugin.RUN_VALGRIND) { + super.createDirectory(path); + } + } + + @Override + protected IProcess createNewProcess(ILaunch launch, Process systemProcess, String programName) { + IProcess process; + if (ValgrindTestsPlugin.RUN_VALGRIND) { + process = super.createNewProcess(launch, systemProcess, programName); + } else { + process = new ValgrindStubProcess(launch, programName); + } + return process; + } + + @Override + protected void setOutputPath(ILaunchConfiguration config, IPath outputPath) throws CoreException { + if (ValgrindTestsPlugin.RUN_VALGRIND) { + super.setOutputPath(config, outputPath); + } + } } diff --git a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestsPlugin.java b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestsPlugin.java index 3c2bd9fd94..a2b87b9afe 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestsPlugin.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestsPlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. + * Copyright (c) 2009, 2016 Red Hat, Inc. * 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 @@ -14,54 +14,29 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchPlugin; import org.osgi.framework.Version; - public class ValgrindTestsPlugin { - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.linuxtools.valgrind.tests"; //$NON-NLS-1$ - - // The minimum valgrind version supported for testing - private static final Version MIN_TEST_VER = new Version(3, 7, 0); - - // Java Runtime System Properties - /** - * usage: -Declipse.valgrind.tests.generateFiles=<yes|no> [default: no] - * if yes, will run Valgrind and store its output files for each test under - * <plugin root>/valgrindFiles - * no, will use default output directory for valgrind's output - */ - public static final String SYSTEM_PROPERTY_GENERATE_FILES = "eclipse.valgrind.tests.generateFiles"; //$NON-NLS-1$ - public static final boolean GENERATE_FILES = System.getProperty(SYSTEM_PROPERTY_GENERATE_FILES, "no").equals("yes"); //$NON-NLS-1$ //$NON-NLS-2$ - - /** - * usage: -Declipse.valgrind.tests.runValgrind=<yes|no> [default: yes] - * if yes, will run Valgrind as in a normal launch - * no, will simulate Valgrind execution with pregenerated log files - */ - public static final String SYSTEM_PROPERTY_RUN_VALGRIND = "eclipse.valgrind.tests.runValgrind"; //$NON-NLS-1$ - // generateFiles implies runValgrind - public static final boolean RUN_VALGRIND = (GENERATE_FILES || System.getProperty(SYSTEM_PROPERTY_RUN_VALGRIND, "yes").equals("yes")) //$NON-NLS-1$ //$NON-NLS-2$ - && versionSupported(); - - // Launch config attribute to mock valgrind's exit code - public static final String ATTR_MOCK_EXIT_CODE = PLUGIN_ID + ".MOCK_EXIT_CODE"; //$NON-NLS-1$ - - /** - * Compare currently available Valgrind version against the minimum - * supported testing version. - * - * @return <code>true</code> if the current valgrind version is greater than - * or equal to the minimum supported test version, and - * <code>false</code> otherwise. - */ - public static boolean versionSupported() { - Version valgrindVersion = new Version(0, 0, 0); - try { - valgrindVersion = ValgrindLaunchPlugin.getDefault() - .getValgrindVersion(null); - } catch (CoreException e) { - return false; - } - return valgrindVersion.compareTo(MIN_TEST_VER) >= 0; - } + // The minimum valgrind version supported for testing + private static final Version MIN_TEST_VER = new Version(3, 7, 0); + + // generateFiles implies runValgrind + public static final boolean RUN_VALGRIND = versionSupported(); + + /** + * Compare currently available Valgrind version against the minimum + * supported testing version. + * + * @return <code>true</code> if the current valgrind version is greater than + * or equal to the minimum supported test version, and + * <code>false</code> otherwise. + */ + private static boolean versionSupported() { + Version valgrindVersion = new Version(0, 0, 0); + try { + valgrindVersion = ValgrindLaunchPlugin.getDefault().getValgrindVersion(null); + } catch (CoreException e) { + return false; + } + return valgrindVersion.compareTo(MIN_TEST_VER) >= 0; + } } |