diff options
author | HyungKyu Song <hk76.song@samsung.com> | 2013-02-16 00:58:36 +0900 |
---|---|---|
committer | HyungKyu Song <hk76.song@samsung.com> | 2013-02-16 00:58:36 +0900 |
commit | 25b26f6ed69014262fc536f6cadd1add400bff20 (patch) | |
tree | b8d2e7f35889963c81c5120c372c4b4ae53b1382 /org.eclipse.linuxtools.gcov.test | |
parent | b46fd4f6e8283f5da6795b12ecf77adcf49525fe (diff) | |
download | codecoverage-eplugin-tizen_2.0.tar.gz codecoverage-eplugin-tizen_2.0.tar.bz2 codecoverage-eplugin-tizen_2.0.zip |
Tizen 2.0 Releasesubmit/tizen_2.0/20130215.192339tizen_2.0
Diffstat (limited to 'org.eclipse.linuxtools.gcov.test')
46 files changed, 1283 insertions, 0 deletions
diff --git a/org.eclipse.linuxtools.gcov.test/.classpath b/org.eclipse.linuxtools.gcov.test/.classpath new file mode 100644 index 0000000..1ca8caa --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/org.eclipse.linuxtools.gcov.test/.project b/org.eclipse.linuxtools.gcov.test/.project new file mode 100644 index 0000000..ea8b6fd --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.linuxtools.gcov.test</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.linuxtools.gcov.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.linuxtools.gcov.test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..4ec9559 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +#Fri Jan 16 09:19:58 CET 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.eclipse.linuxtools.gcov.test/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.gcov.test/META-INF/MANIFEST.MF new file mode 100644 index 0000000..7340221 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %bundleName +Bundle-SymbolicName: org.eclipse.linuxtools.gcov.test +Bundle-Version: 4.1.1.qualifier +Bundle-Vendor: %bundleProvider +Fragment-Host: org.eclipse.linuxtools.gcov +Require-Bundle: org.junit +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/org.eclipse.linuxtools.gcov.test/about.html b/org.eclipse.linuxtools.gcov.test/about.html new file mode 100644 index 0000000..0c6525d --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/about.html @@ -0,0 +1,33 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<head> +<title>About</title> +<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1"> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>24th October, 2008</p> +<h3>License</h3> +<p>The Eclipse Software Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, "Program" will mean the Content.</p> + +<h3>Contributions</h3> + +<p>If this Content is licensed to you under the terms and conditions of the EPL, any Contributions, as defined in the EPL, uploaded, submitted, or otherwise +made available to the Eclipse Foundation, its members and/or the host of the Eclipse Foundation web site, by you that relate to such +Content are provided under the terms and conditions of the <a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a> +for the Eclipse Foundation web site and can be made available to others under the terms of the licenses as set out in the +<a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>.</p> + +<p>If this Content is licensed to you under license terms and conditions other than the EPL ("Other License"), any modifications, enhancements and/or +other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to the Eclipse Foundation, its members and/or the +host of the Eclipse Foundation web site, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available +to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also +providing the Modifications under the terms and conditions of the <a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a> +for the Eclipse Foundation web site and such Modifications can be made available to others under the terms of the licenses as set out in the +<a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>.</p> + +</body> +</html>
\ No newline at end of file diff --git a/org.eclipse.linuxtools.gcov.test/build.properties b/org.eclipse.linuxtools.gcov.test/build.properties new file mode 100644 index 0000000..e70eafa --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/build.properties @@ -0,0 +1,9 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ test.xml,\
+ plugin.properties,\
+ test_c/,\
+ test_cpp/,\
+ about.html
diff --git a/org.eclipse.linuxtools.gcov.test/plugin.properties b/org.eclipse.linuxtools.gcov.test/plugin.properties new file mode 100644 index 0000000..cec757f --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/plugin.properties @@ -0,0 +1,12 @@ +#****************************************************************************** +# Copyright (c) 2009 STMicroelectronics. +# 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: +# Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation +#******************************************************************************* +bundleProvider = Eclipse Linux Tools +bundleName = Gcov Test Plug-in (Incubation)
\ No newline at end of file diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/AllGcovTests.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/AllGcovTests.java new file mode 100755 index 0000000..b44f96a --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/AllGcovTests.java @@ -0,0 +1,29 @@ +/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllGcovTests {
+
+ public static Test suite() {
+ TestSuite ats = new TestSuite("Tests for org.eclipse.linuxtools.gcov.test");
+ //$JUnit-BEGIN$
+ ats.addTest(GcovGCDARetrieverTest.suite());
+ ats.addTest(GcovParserTest.suite());
+// Comment out until we fix bug #299995
+// ats.addTest(GcovViewTest.suite());
+ //$JUnit-END$
+ return ats;
+ }
+
+}
\ No newline at end of file diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovGCDARetrieverTest.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovGCDARetrieverTest.java new file mode 100755 index 0000000..92f2ee1 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovGCDARetrieverTest.java @@ -0,0 +1,68 @@ +/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.test;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.parser.CovManager;
+
+public class GcovGCDARetrieverTest extends TestCase {
+
+ public GcovGCDARetrieverTest() {
+ }
+
+ public static Test suite() {
+ TestSuite ats = new TestSuite("Gcov:GCDA_Retriever");
+ File[] testDirs = STJunitUtils.getTestDirs(Activator.PLUGIN_ID + ".test", "test.*");
+ for (File testDir : testDirs) {
+ final String[] covFiles = GcovTestUtils.getGCDANames(testDir);
+ final File binaryFile = GcovTestUtils.getBinary(testDir);
+ ats.addTest(
+ new TestCase(testDir.getName() + ":GCDA_Retriever") {
+ public void runTest() throws Throwable {
+ testGcdaRetriever(binaryFile, covFiles);
+ }
+ }
+ );
+ }
+ return ats;
+ }
+
+
+ public static void testGcdaRetriever(
+ File binaryFile, String[] covFilesPaths)
+ throws Exception {
+ CovManager covManager = new CovManager(binaryFile.getAbsolutePath());
+ List<String> list = covManager.getGCDALocations();
+ String[] generatedCovFilesPath = new String[list.size()];
+ int index = 0;
+ for (String string : list) {
+ int i = string.lastIndexOf('/');
+ string = string.substring(i+1);
+ i = string.lastIndexOf('\\');
+ string = string.substring(i+1);
+ generatedCovFilesPath[index] = string;
+ index++;
+ }
+ Arrays.sort(generatedCovFilesPath);
+ boolean b = Arrays.equals(generatedCovFilesPath, covFilesPaths);
+ Assert.assertEquals("May be normal if binary not complied with gcov options", true, b);
+ }
+
+}
\ No newline at end of file diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovParserTest.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovParserTest.java new file mode 100755 index 0000000..1c0b5c6 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovParserTest.java @@ -0,0 +1,59 @@ +/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.test;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.parser.CovManager;
+
+public class GcovParserTest extends TestCase {
+
+ public GcovParserTest() {
+ }
+
+
+ public static Test suite() {
+ TestSuite ats = new TestSuite("Gcov:Parser");
+ File[] testDirs = STJunitUtils.getTestDirs(Activator.PLUGIN_ID + ".test", "test.*");
+ for (File testDir : testDirs) {
+ final List<String> covPaths = GcovTestUtils.getGCDAPath(testDir);
+ final File binaryFile = GcovTestUtils.getBinary(testDir);
+ final File parserRefFile = new File(testDir, "testProcessCovFiles.ref");
+ final File parserDumpFile = new File(testDir, "testProcessCovFiles.dump");
+ ats.addTest(
+ new TestCase(testDir.getName() + ":Parser") {
+ public void runTest() throws Throwable {
+ testGcovParsing(binaryFile, covPaths, parserRefFile, parserDumpFile);
+ }
+ }
+ );
+ }
+ return ats;
+ }
+
+ public static void testGcovParsing(
+ File binaryFile, List<String> covFilesPaths,
+ File parserRefFile, File parserDumpFile)
+ throws Exception {
+ CovManager covManager = new CovManager(binaryFile.getAbsolutePath());
+ covManager.processCovFiles(covFilesPaths);
+ covManager.dumpProcessCovFilesResult(new PrintStream(parserDumpFile));
+ STJunitUtils.compareIgnoreEOL(parserDumpFile.getAbsolutePath(), parserRefFile.getAbsolutePath(), true);
+ }
+
+}
\ No newline at end of file diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovTestUtils.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovTestUtils.java new file mode 100755 index 0000000..bd128bd --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovTestUtils.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2009 STMicroelectronics. + * 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: + * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.gcov.test; + +import java.io.File; +import java.io.FileFilter; +import java.io.FilenameFilter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import junit.framework.Assert; + +public class GcovTestUtils { + public static final String GCOV_FILE_SUFFIX = ".gcda"; + public static final String GCOV_BINARY_FILE_SUFFIX = ".out"; + public static final String GCOV_DIRECTORY_SUFFIX = "_gcov_input"; + + public static String[] getGCDANames(File directory) { + String[] covFiles = directory.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith(GCOV_FILE_SUFFIX); + } + }); + Arrays.sort(covFiles); + return covFiles; + } + + public static File[] getGCDA(File directory) { + File[] covFiles = directory.listFiles(new FileFilter() { + public boolean accept(File arg0) { + return ( arg0.isDirectory() == false && arg0.getName().endsWith(GCOV_FILE_SUFFIX)); + } + }); + Arrays.sort(covFiles); + return covFiles; + } + + public static List<String> getGCDAPath(File directory) { + File[] covFiles = getGCDA(directory); + final List<String> covPaths = new ArrayList<String>(covFiles.length); + for (File file : covFiles) { + covPaths.add(file.getAbsolutePath()); + } + return covPaths; + } + + public static File getBinary(File directory) { + File[] binaries = directory.listFiles(new FileFilter() { + public boolean accept(File arg1) { + return ( !arg1.isDirectory() && arg1.getName().endsWith(GCOV_BINARY_FILE_SUFFIX)); + } + }); + Assert.assertEquals(1, binaries.length); + return binaries[0]; + } + +} diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovViewTest.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovViewTest.java new file mode 100755 index 0000000..a49fcd1 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovViewTest.java @@ -0,0 +1,111 @@ +/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.test;
+
+import java.io.File;
+import java.util.List;
+import java.util.Locale;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.action.SwitchContentProviderAction;
+import org.eclipse.linuxtools.gcov.parser.CovManager;
+import org.eclipse.linuxtools.gcov.view.CovFileContentProvider;
+import org.eclipse.linuxtools.gcov.view.CovFolderContentProvider;
+import org.eclipse.linuxtools.gcov.view.CovFunctionContentProvider;
+import org.eclipse.linuxtools.gcov.view.CovView;
+
+public class GcovViewTest extends TestCase {
+
+ public GcovViewTest() {
+ }
+
+ public static Test suite() {
+ TestSuite emptyTestSuite = new TestSuite();
+ return emptyTestSuite;
+// Comment out until we fix bug #299995
+// TestSuite ats = new TestSuite("GCov:View");
+// File[] testDirs = STJunitUtils.getTestDirs(Activator.PLUGIN_ID + ".test", "test.*");
+//
+// for (File testDir : testDirs) {
+// final List<String> covFilesPaths = GcovTestUtils.getGCDAPath(testDir);
+// final File binary = GcovTestUtils.getBinary(testDir);
+// final File folderRefFile = new File(testDir, "testViewFolder.ref");
+// final File folderDumpFile = new File(testDir, "testViewFolder.dump");
+// final File fileRefFile = new File(testDir, "testView.ref");
+// final File fileDumpFile = new File(testDir, "testView.dump");
+// final File functionRefFile = new File(testDir, "testViewFunction.ref");
+// final File functionDumpFile = new File(testDir, "testViewFunction.dump");
+// ats.addTest(
+// new TestCase(testDir.getName() + ":CSV-DIRECTORY") {
+// public void runTest() throws Throwable {
+// testView(
+// covFilesPaths, binary,
+// CovFolderContentProvider.sharedInstance,
+// folderRefFile, folderDumpFile
+// );
+// }
+// }
+// );
+// ats.addTest(
+// new TestCase(testDir.getName() + ":CSV-FILE") {
+// public void runTest() throws Throwable {
+// testView(
+// covFilesPaths, binary,
+// CovFileContentProvider.sharedInstance,
+// fileRefFile, fileDumpFile
+// );
+// }
+// }
+// );
+// ats.addTest(
+// new TestCase(testDir.getName() + ":CSV-FUNCTION") {
+// public void runTest() throws Throwable {
+// testView(
+// covFilesPaths, binary,
+// CovFunctionContentProvider.sharedInstance,
+// functionRefFile, functionDumpFile
+// );
+// }
+// }
+// );
+// }
+// return ats;
+ }
+
+
+ public static void testView(
+ List<String> covFilesPaths, File binaryFile,
+ ITreeContentProvider provider,
+ File refFile, File dumpFile) throws Exception {
+ Locale.setDefault( Locale.US );
+ CovManager cvrgeMnger = new CovManager(binaryFile.getAbsolutePath());
+ cvrgeMnger.processCovFiles(covFilesPaths);
+ // generate model for view
+ cvrgeMnger.fillGcovView();
+ //load an Eclipse view
+ CovView cvrgeView = CovView.displayCovResults(cvrgeMnger);
+
+ SwitchContentProviderAction action = new SwitchContentProviderAction(
+ "test", "icons/directory_obj.gif",
+ cvrgeView.getSTViewer().getViewer(),
+ provider
+ );
+ action.run();
+ STJunitUtils.testCSVExport(cvrgeView, dumpFile.getAbsolutePath(), refFile.getAbsolutePath());
+
+ }
+
+}
\ No newline at end of file diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/STJunitUtils.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/STJunitUtils.java new file mode 100755 index 0000000..39cdeee --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/STJunitUtils.java @@ -0,0 +1,267 @@ +/******************************************************************************* + * Copyright (c) 2009 STMicroelectronics. + * 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: + * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.gcov.test; + +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.LineNumberReader; +import java.net.URL; + +import junit.framework.Assert; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataView; +import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersCSVExporter; +import org.osgi.framework.Bundle; + + +/** + * This class only contains some tools to facilitate tests + * (compare) + * @author Xavier Raynaud <xavier.raynaud@st.com> + */ +public class STJunitUtils { + + + /** + * Test CSV export of the given view + * @param view + * @param dumpFullFileName + * @param refFullFileName + */ + public static void testCSVExport(AbstractSTDataView view, String dumpFullFileName, String refFullFileName) { + STDataViewersCSVExporter exporter = new STDataViewersCSVExporter(view.getSTViewer()); + exporter.exportTo(dumpFullFileName, new NullProgressMonitor()); + // compare with ref + compareCSVIgnoreEOL(dumpFullFileName, refFullFileName, true); + } + + /** + * Utility method to compare files + * @param dumpFile + * @param refFile + */ + public static boolean compare(String dumpFile, String refFile, boolean deleteDumpFileIfOk) { + String message = "Comparing ref file ("+refFile+ ")and dump file (" + + dumpFile+")"; + boolean equals = false; + System.out.println(message); + try { + InputStream is1 = new FileInputStream(dumpFile); + InputStream is2 = new FileInputStream(refFile); + equals = compare(is1, is2); + if (!equals) { + System.out.println(message + "... FAILED"); + junit.framework.Assert.assertEquals(message + ": not correspond ", true, false); + } + else { + System.out.println(message + "... successful"); + } + // delete dump only for successful tests + if (equals && deleteDumpFileIfOk) + new File(dumpFile).delete(); + }catch (FileNotFoundException _) { + message += "... FAILED: One of these files may not exist"; + System.out.println(message); + junit.framework.Assert.assertNull(message, _); + } + catch (Exception _) { + message += ": exception raised ... FAILED"; + System.out.println(message); + junit.framework.Assert.assertNull(message, _); + } + return equals; + } + + /** + * Utility method to compare files + * @param dumpFile + * @param refFile + * @return + */ + public static boolean compareIgnoreEOL(String dumpFile, String refFile, boolean deleteDumpFileIfOk) { + String message = "Comparing ref file ("+refFile+ ")and dump file (" + + dumpFile+")"; + boolean equals = false; + try { + LineNumberReader is1 = new LineNumberReader(new FileReader(dumpFile)); + LineNumberReader is2 = new LineNumberReader(new FileReader(refFile)); + do { + String line1 = is1.readLine(); + String line2 = is2.readLine(); + if (line1 == null) { + if (line2 == null) { + equals = true; + } + break; + } else if (line2 == null || !line1.equals(line2)) { + break; + } + } while (true); + + if (!equals) { + junit.framework.Assert.assertEquals(message + ": not correspond ", true, false); + } + + is1.close(); + is2.close(); + // delete dump only for successful tests + if (equals && deleteDumpFileIfOk) { + new File(dumpFile).delete(); + } + }catch (FileNotFoundException _) { + message += "... FAILED: One of these files may not exist"; + junit.framework.Assert.assertNull(message, _); + } + catch (Exception _) { + message += ": exception raised ... FAILED"; + junit.framework.Assert.assertNull(message, _); + } + return equals; + } + + /** + * Utility method to compare exported CSV files + * @param dumpFile + * @param refFile + * @return + */ + public static boolean compareCSVIgnoreEOL(String dumpFile, String refFile, boolean deleteDumpFileIfOk) { + String message = "Comparing ref file ("+refFile+ ")and dump file (" + + dumpFile+")"; + boolean equals = false; + String str = "[in-charge]"; // this string can be dumped according to binutils version installed on local machine + + try { + LineNumberReader is1 = new LineNumberReader(new FileReader(dumpFile)); + LineNumberReader is2 = new LineNumberReader(new FileReader(refFile)); + do { + String line1 = is1.readLine(); + String line2 = is2.readLine(); + int length = str.length(); + if (line1 == null) { + if (line2 == null) { + equals = true; + } + break; + } else if (line1.contains(str)){ + int idx = line1.indexOf("[in-charge]"); + char c = line1.charAt(idx -1); + if (c == ' ' ){ + idx--; + length++; + } + line1 = line1.substring(0, idx) + line1.substring(idx+length, line1.length()); + if (!line1.equals(line2)) + break; + } else if (line2 == null || !line1.equals(line2)) { + break; + } + } while (true); + + if (!equals) { + junit.framework.Assert.assertEquals(message + ": not correspond ", true, false); + } + + is1.close(); + is2.close(); + // delete dump only for successful tests + if (equals && deleteDumpFileIfOk) { + new File(dumpFile).delete(); + } + }catch (FileNotFoundException _) { + message += "... FAILED: One of these files may not exist"; + junit.framework.Assert.assertNull(message, _); + } + catch (Exception _) { + message += ": exception raised ... FAILED"; + junit.framework.Assert.assertNull(message, _); + } + return equals; + } + + /** + * Utility method to compare Input streams + * @param ISdump + * @param ISref + * @return + * @throws IOException + */ + public static boolean compare(InputStream ISdump, InputStream ISref) throws IOException { + try { + boolean equals = false; + do { + int char1 = ISdump.read(); + int char2 = ISref.read(); + if (char1 != char2) + break; + if (char1 == -1) { + equals = true; + break; + } + } while (true); + return equals; + } finally { + ISdump.close(); + ISref.close(); + } + } + + /** + * Gets the absolute path of a resource in the given plugin + * @param pluginId + * @param relativeName + * @return an absolute path to a file + */ + public static String getAbsolutePath(String pluginId, String relativeName) { + Bundle b = Platform.getBundle(pluginId); + URL url = FileLocator.find(b, new Path(relativeName), null); + try { + url = FileLocator.toFileURL(url); + } catch (IOException e) { + Assert.assertNotNull("Problem locating " + relativeName + " in" + pluginId,e); + } + String filename = url.getFile(); + return filename; + } + + /** + * Utility method + * @param pluginDirectory: the plugin where to look for directories + * @param regexp: the regexp used for matching directories + * @return the list of directories that belong to the pluginDirectory and + * ends with the given extensionSuffix + */ + public static File[] getTestDirs(String pluginDirectory, final String regexp) { + // load directories containing tests + String filename = getAbsolutePath(pluginDirectory, "."); + File dir = new File(filename); + File[] testDirs = dir.listFiles( + new FileFilter() { + public boolean accept(File arg0) { + return (arg0.isDirectory() && arg0.getName().matches(regexp)); + } + } + ); + + // test if there is any directory samples + Assert.assertNotNull("No project files to test",testDirs); + return testDirs; + } +} diff --git a/org.eclipse.linuxtools.gcov.test/test.xml b/org.eclipse.linuxtools.gcov.test/test.xml new file mode 100755 index 0000000..0d6d7f8 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?>
+
+<project name="testsuite" default="run" basedir=".">
+ <property name="classname" value="org.eclipse.linuxtools.gcov.test.AllGcovTests" />
+ <property name="plugin-name" value="org.eclipse.linuxtools.gcov.test" />
+
+ <!-- The property ${eclipse-home} should be passed into this script -->
+ <!-- Set a meaningful default value for when it is not. -->
+ <property name="eclipse-home" value="${basedir}/../../" />
+
+ <property name="library-file" value="${eclipse-home}/dropins/${subProjectName2}/plugins/org.eclipse.test/library.xml" />
+
+ <!-- This target holds all initialization code that needs to be done for -->
+ <!-- all tests that are to be run. Initialization for individual tests -->
+ <!-- should be done within the body of the suite target. -->
+ <target name="init">
+ <tstamp />
+ <delete>
+ <fileset dir="${eclipse-home}" includes="org*.xml" />
+ </delete>
+ </target>
+
+ <!-- This target defines the tests that need to be run. -->
+ <target name="gcov_suite">
+ <property name="gcov-folder" value="${eclipse-home}/gcov_folder" />
+ <delete dir="${gcov-folder}" quiet="true" />
+ <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="data-dir" value="${gcov-folder}" />
+ <property name="plugin-name" value="${plugin-name}" />
+ <property name="classname" value="${classname}" />
+ </ant>
+ </target>
+
+ <!-- This target holds code to cleanup the testing environment after -->
+ <!-- all of the tests have been run. You can use this target to -->
+ <!-- delete temporary files that have been created. -->
+ <target name="cleanup">
+ <mkdir dir="${results}/consolelogs" />
+ <copy failonerror="false" file="${eclipse-home}/results/${classname}.txt" tofile="${results}/consolelogs/${classname}_${platform}.metadata.log.txt" />
+ </target>
+
+ <!-- This target runs the test suite. Any actions that need to happen -->
+ <!-- after all the tests have been run should go here. -->
+ <target name="run" depends="init,gcov_suite,cleanup">
+ <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="includes" value="org*.xml" />
+ <property name="output-file" value="${plugin-name}.xml" />
+ </ant>
+ </target>
+
+ <target name="all" depends="run" description="Dummy target to run all tests">
+ </target>
+
+</project>
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/Makefile b/org.eclipse.linuxtools.gcov.test/test_c/Makefile new file mode 100644 index 0000000..9771c05 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/Makefile @@ -0,0 +1,8 @@ +build a.out: + gcc -fprofile-arcs -ftest-coverage *.c + +all: a.out + ./$< 1 2 3 4 5 6 + +clean: + rm -f *.o a.out *.gcno *.gcda diff --git a/org.eclipse.linuxtools.gcov.test/test_c/a.out b/org.eclipse.linuxtools.gcov.test/test_c/a.out Binary files differnew file mode 100755 index 0000000..baebd86 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/a.out diff --git a/org.eclipse.linuxtools.gcov.test/test_c/fact.c b/org.eclipse.linuxtools.gcov.test/test_c/fact.c new file mode 100644 index 0000000..f37737a --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/fact.c @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2009 STMicroelectronics. + * 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: + * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation + *******************************************************************************/ +long mult(long val1, long val2); + +long fact(long val) +{ + int k = 100; + for (; k-->0;); + if (val == 1) return 1; + return mult(val,fact(val-1)); +} diff --git a/org.eclipse.linuxtools.gcov.test/test_c/fact.gcda b/org.eclipse.linuxtools.gcov.test/test_c/fact.gcda Binary files differnew file mode 100644 index 0000000..0515b5e --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/fact.gcda diff --git a/org.eclipse.linuxtools.gcov.test/test_c/fact.gcno b/org.eclipse.linuxtools.gcov.test/test_c/fact.gcno Binary files differnew file mode 100644 index 0000000..d9242a8 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/fact.gcno diff --git a/org.eclipse.linuxtools.gcov.test/test_c/main.c b/org.eclipse.linuxtools.gcov.test/test_c/main.c new file mode 100644 index 0000000..6065d93 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/main.c @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2009 STMicroelectronics. + * 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: + * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation + *******************************************************************************/ +#include <stdio.h> +#include <stdlib.h> + +long fact(long val); + +int main(int argc, char** argv) +{ + int i = 1; + for (; i<argc; i++) + { + unsigned long val = strtol(argv[i],NULL,10); + unsigned long res = fact(val); + int k = 1000; + for (; k-->0;); + printf("%li! = %li\n", val, res); + } + return 0; +} diff --git a/org.eclipse.linuxtools.gcov.test/test_c/main.gcda b/org.eclipse.linuxtools.gcov.test/test_c/main.gcda Binary files differnew file mode 100644 index 0000000..bcbaaac --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/main.gcda diff --git a/org.eclipse.linuxtools.gcov.test/test_c/main.gcno b/org.eclipse.linuxtools.gcov.test/test_c/main.gcno Binary files differnew file mode 100644 index 0000000..3581c98 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/main.gcno diff --git a/org.eclipse.linuxtools.gcov.test/test_c/mult.c b/org.eclipse.linuxtools.gcov.test/test_c/mult.c new file mode 100644 index 0000000..62abaa9 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/mult.c @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2009 STMicroelectronics. + * 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: + * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation + *******************************************************************************/ +long mult(long val1, long val2) +{ + int k = 50; + long res = 0; + for (; k-->0;); + while(val2-->0) + { + res += val1; + } + return res; +} diff --git a/org.eclipse.linuxtools.gcov.test/test_c/mult.gcda b/org.eclipse.linuxtools.gcov.test/test_c/mult.gcda Binary files differnew file mode 100644 index 0000000..12b1038 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/mult.gcda diff --git a/org.eclipse.linuxtools.gcov.test/test_c/mult.gcno b/org.eclipse.linuxtools.gcov.test/test_c/mult.gcno Binary files differnew file mode 100644 index 0000000..d7b49a8 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/mult.gcno diff --git a/org.eclipse.linuxtools.gcov.test/test_c/testProcessCovFiles.ref b/org.eclipse.linuxtools.gcov.test/test_c/testProcessCovFiles.ref new file mode 100644 index 0000000..bdb5e51 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/testProcessCovFiles.ref @@ -0,0 +1,30 @@ +Parse gcda and gcno files done, resolve graph algorithm executed, now display results +- PRINT FUNCTIONS ARRAY : +-- FUNCTION 0 + name = fact + instrumentd lines = 5 + executed lines = 5 +-- FUNCTION 1 + name = main + instrumentd lines = 9 + executed lines = 9 +-- FUNCTION 2 + name = mult + instrumentd lines = 7 + executed lines = 7 +- PRINT SRCS ARRAY : +-- FILE 0 + name = fact.c + total lines = 19 + instrumentd lines = 5 + executed lines = 5 +-- FILE 1 + name = main.c + total lines = 28 + instrumentd lines = 9 + executed lines = 9 +-- FILE 2 + name = mult.c + total lines = 21 + instrumentd lines = 7 + executed lines = 7 diff --git a/org.eclipse.linuxtools.gcov.test/test_c/testView.ref b/org.eclipse.linuxtools.gcov.test/test_c/testView.ref new file mode 100644 index 0000000..2dc8ff6 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/testView.ref @@ -0,0 +1,8 @@ +Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage % ++-;Summary;68;21;21;100.0 + +-;fact.c;19;5;5;100.0 + | +-;fact;;5;5;100.0 + +-;main.c;28;9;9;100.0 + | +-;main;;9;9;100.0 + +-;mult.c;21;7;7;100.0 + +-;mult;;7;7;100.0 diff --git a/org.eclipse.linuxtools.gcov.test/test_c/testViewFolder.ref b/org.eclipse.linuxtools.gcov.test/test_c/testViewFolder.ref new file mode 100644 index 0000000..2f8156b --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/testViewFolder.ref @@ -0,0 +1,9 @@ +Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage % ++-;Summary;68;21;21;100.0 + +-;?;68;21;21;100.0 + +-;fact.c;19;5;5;100.0 + | +-;fact;;5;5;100.0 + +-;main.c;28;9;9;100.0 + | +-;main;;9;9;100.0 + +-;mult.c;21;7;7;100.0 + +-;mult;;7;7;100.0 diff --git a/org.eclipse.linuxtools.gcov.test/test_c/testViewFunction.ref b/org.eclipse.linuxtools.gcov.test/test_c/testViewFunction.ref new file mode 100644 index 0000000..c24b616 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_c/testViewFunction.ref @@ -0,0 +1,5 @@ +Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage % ++-;Summary;68;21;21;100.0 + +-;fact;;5;5;100.0 + +-;main;;9;9;100.0 + +-;mult;;7;7;100.0 diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/Makefile b/org.eclipse.linuxtools.gcov.test/test_cpp/Makefile new file mode 100644 index 0000000..e3c2b86 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/Makefile @@ -0,0 +1,8 @@ +build a.out: + g++ -fprofile-arcs -ftest-coverage *.cpp + +all: a.out + ./$< 1 2 3 4 5 6 + +clean: + rm -f *.o a.out *.gcno *.gcda diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/a.out b/org.eclipse.linuxtools.gcov.test/test_cpp/a.out Binary files differnew file mode 100755 index 0000000..794f7f9 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/a.out diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/fact.cpp b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.cpp new file mode 100644 index 0000000..cb1e7c8 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.cpp @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2009 STMicroelectronics. + * 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: + * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation + *******************************************************************************/ +#include "fact.hpp" +#include "mult.hpp" + +namespace F +{ + +fact::fact() {}; + +fact::~fact() {}; + +long fact::f(long val) +{ + for (int k = 100; k-->0;); + if (val == 1) return 1; + M::mult m; + return m.multiply(val,f(val-1)); +} +} + + + diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcda b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcda Binary files differnew file mode 100644 index 0000000..042f39b --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcda diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcno b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcno Binary files differnew file mode 100644 index 0000000..be33eb2 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcno diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/fact.hpp b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.hpp new file mode 100644 index 0000000..32a9296 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.hpp @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2009 STMicroelectronics. + * 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: + * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation + *******************************************************************************/ + +namespace F +{ + + class fact + { + public: + fact(); + ~fact(); + long f(long val); + }; + +} + + + diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/main.cpp b/org.eclipse.linuxtools.gcov.test/test_cpp/main.cpp new file mode 100644 index 0000000..d3c4e21 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/main.cpp @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2009 STMicroelectronics. + * 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: + * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation + *******************************************************************************/ +#include <iostream> +#include <stdlib.h> +#include "fact.hpp" + + +int main(int argc, char** argv) +{ + int i = 1; + for (; i<argc; i++) + { + for (int k = 1000; k-->0;); + unsigned long val = strtol(argv[i],NULL,10); + F::fact f; + unsigned long res = f.f(val); + std::cout << val + << "! = " + << res + << std::endl; + } +} diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcda b/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcda Binary files differnew file mode 100644 index 0000000..073c23e --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcda diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcno b/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcno Binary files differnew file mode 100644 index 0000000..4f642e7 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcno diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/mult.cpp b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.cpp new file mode 100644 index 0000000..bd55274 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.cpp @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2009 STMicroelectronics. + * 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: + * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation + *******************************************************************************/ +#include "mult.hpp" + +namespace M +{ +mult::mult() {}; + +mult::~mult() {}; + +long mult::multiply(long val1, long val2) +{ + for (int k = 50; k-->0;); + long res = 0; + while(val2-->0) + { + res += val1; + } + return res; +}; +} diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcda b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcda Binary files differnew file mode 100644 index 0000000..e2821df --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcda diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcno b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcno Binary files differnew file mode 100644 index 0000000..b5f1fcd --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcno diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/mult.hpp b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.hpp new file mode 100644 index 0000000..3d3f147 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.hpp @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2009 STMicroelectronics. + * 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: + * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation + *******************************************************************************/ +namespace M +{ + class mult + { + public: + mult(); + + ~mult(); + + long multiply(long val1, long val2); + }; +} diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/testProcessCovFiles.ref b/org.eclipse.linuxtools.gcov.test/test_cpp/testProcessCovFiles.ref new file mode 100644 index 0000000..10a2316 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/testProcessCovFiles.ref @@ -0,0 +1,148 @@ +Parse gcda and gcno files done, resolve graph algorithm executed, now display results +- PRINT FUNCTIONS ARRAY : +-- FUNCTION 0 + name = _ZN1F4factC2Ev + instrumentd lines = 1 + executed lines = 0 +-- FUNCTION 1 + name = _ZN1F4factC1Ev + instrumentd lines = 0 + executed lines = 1 +-- FUNCTION 2 + name = _ZN1F4factD2Ev + instrumentd lines = 1 + executed lines = 0 +-- FUNCTION 3 + name = _ZN1F4factD1Ev + instrumentd lines = 0 + executed lines = 1 +-- FUNCTION 4 + name = _ZN1F4fact1fEl + instrumentd lines = 5 + executed lines = 5 +-- FUNCTION 5 + name = _ZStorSt12_Ios_IostateS_ + instrumentd lines = 2 + executed lines = 0 +-- FUNCTION 6 + name = _ZNSolsEPFRSoS_E + instrumentd lines = 2 + executed lines = 0 +-- FUNCTION 7 + name = _ZNKSt9basic_iosIcSt11char_traitsIcEE7rdstateEv + instrumentd lines = 2 + executed lines = 0 +-- FUNCTION 8 + name = _Z41__static_initialization_and_destruction_0ii + instrumentd lines = 2 + executed lines = 2 +-- FUNCTION 9 + name = _GLOBAL__I_main + instrumentd lines = 0 + executed lines = 0 +-- FUNCTION 10 + name = _ZNSt9basic_iosIcSt11char_traitsIcEE8setstateESt12_Ios_Iostate + instrumentd lines = 2 + executed lines = 0 +-- FUNCTION 11 + name = _ZNSt11char_traitsIcE6lengthEPKc + instrumentd lines = 2 + executed lines = 0 +-- FUNCTION 12 + name = _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc + instrumentd lines = 5 + executed lines = 0 +-- FUNCTION 13 + name = _ZNSolsEm + instrumentd lines = 2 + executed lines = 0 +-- FUNCTION 14 + name = main + instrumentd lines = 8 + executed lines = 8 +-- FUNCTION 15 + name = _ZSt13__check_facetISt5ctypeIcEERKT_PS3_ + instrumentd lines = 4 + executed lines = 0 +-- FUNCTION 16 + name = _ZNKSt5ctypeIcE5widenEc + instrumentd lines = 5 + executed lines = 0 +-- FUNCTION 17 + name = _ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc + instrumentd lines = 2 + executed lines = 0 +-- FUNCTION 18 + name = _ZSt5flushIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ + instrumentd lines = 2 + executed lines = 0 +-- FUNCTION 19 + name = _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ + instrumentd lines = 2 + executed lines = 0 +-- FUNCTION 20 + name = _ZN1M4multC2Ev + instrumentd lines = 1 + executed lines = 0 +-- FUNCTION 21 + name = _ZN1M4multC1Ev + instrumentd lines = 0 + executed lines = 1 +-- FUNCTION 22 + name = _ZN1M4multD2Ev + instrumentd lines = 1 + executed lines = 0 +-- FUNCTION 23 + name = _ZN1M4multD1Ev + instrumentd lines = 0 + executed lines = 1 +-- FUNCTION 24 + name = _ZN1M4mult8multiplyEll + instrumentd lines = 6 + executed lines = 6 +- PRINT SRCS ARRAY : +-- FILE 0 + name = fact.cpp + total lines = 27 + instrumentd lines = 7 + executed lines = 7 +-- FILE 1 + name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/bits/ios_base.h + total lines = 168 + instrumentd lines = 2 + executed lines = 0 +-- FILE 2 + name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/ostream + total lines = 561 + instrumentd lines = 13 + executed lines = 0 +-- FILE 3 + name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/bits/basic_ios.h + total lines = 441 + instrumentd lines = 10 + executed lines = 0 +-- FILE 4 + name = main.cpp + total lines = 31 + instrumentd lines = 9 + executed lines = 9 +-- FILE 5 + name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/iostream + total lines = 73 + instrumentd lines = 1 + executed lines = 1 +-- FILE 6 + name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/bits/char_traits.h + total lines = 264 + instrumentd lines = 2 + executed lines = 0 +-- FILE 7 + name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/bits/locale_facets.h + total lines = 871 + instrumentd lines = 5 + executed lines = 0 +-- FILE 8 + name = mult.cpp + total lines = 28 + instrumentd lines = 8 + executed lines = 8 diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/testView.ref b/org.eclipse.linuxtools.gcov.test/test_cpp/testView.ref new file mode 100644 index 0000000..af0eefb --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/testView.ref @@ -0,0 +1,36 @@ +Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage % ++-;Summary;2464;57;25;43.86 + +-;basic_ios.h;441;10;0;0.0 + | +-;std::basic_ios<char, std::char_traits<char> >::rdstate() const;;2;0;0.0 + | +-;std::basic_ios<char, std::char_traits<char> >::setstate(std::_Ios_Iostate);;2;0;0.0 + | +-;std::basic_ios<char, std::char_traits<char> >::widen(char) const;;2;0;0.0 + | +-;std::ctype<char> const& std::__check_facet<std::ctype<char> >(std::ctype<char> const*);;4;0;0.0 + +-;char_traits.h;264;2;0;0.0 + | +-;std::char_traits<char>::length(char const*);;2;0;0.0 + +-;fact.cpp;27;7;7;100.0 + | +-;F::fact::f(long);;5;5;100.0 + | +-;F::fact::fact();;0;1;0.0 + | +-;F::fact::fact();;1;0;0.0 + | +-;F::fact::~fact();;0;1;0.0 + | +-;F::fact::~fact();;1;0;0.0 + +-;ios_base.h;168;2;0;0.0 + | +-;std::operator|(std::_Ios_Iostate, std::_Ios_Iostate);;2;0;0.0 + +-;iostream;73;1;1;100.0 + +-;locale_facets.h;871;5;0;0.0 + | +-;std::ctype<char>::widen(char) const;;5;0;0.0 + +-;main.cpp;31;9;9;100.0 + | +-;__static_initialization_and_destruction_0(int, int);;2;2;100.0 + | +-;global constructors keyed to main;;0;0;0.0 + | +-;main;;8;8;100.0 + +-;mult.cpp;28;8;8;100.0 + | +-;M::mult::mult();;0;1;0.0 + | +-;M::mult::mult();;1;0;0.0 + | +-;M::mult::multiply(long, long);;6;6;100.0 + | +-;M::mult::~mult();;0;1;0.0 + | +-;M::mult::~mult();;1;0;0.0 + +-;ostream;561;13;0;0.0 + +-;std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0 + +-;std::basic_ostream<char, std::char_traits<char> >& std::flush<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0 + +-;std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*);;5;0;0.0 + +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&));;2;0;0.0 + +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned long);;2;0;0.0 diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFolder.ref b/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFolder.ref new file mode 100644 index 0000000..ef35963 --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFolder.ref @@ -0,0 +1,39 @@ +Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage % ++-;Summary;2464;57;25;43.86 + +-;4.4.1;634;14;1;7.14 + | +-;iostream;73;1;1;100.0 + | +-;ostream;561;13;0;0.0 + | +-;std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0 + | +-;std::basic_ostream<char, std::char_traits<char> >& std::flush<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0 + | +-;std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*);;5;0;0.0 + | +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&));;2;0;0.0 + | +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned long);;2;0;0.0 + +-;?;86;24;24;100.0 + | +-;fact.cpp;27;7;7;100.0 + | | +-;F::fact::f(long);;5;5;100.0 + | | +-;F::fact::fact();;0;1;0.0 + | | +-;F::fact::fact();;1;0;0.0 + | | +-;F::fact::~fact();;0;1;0.0 + | | +-;F::fact::~fact();;1;0;0.0 + | +-;main.cpp;31;9;9;100.0 + | | +-;__static_initialization_and_destruction_0(int, int);;2;2;100.0 + | | +-;global constructors keyed to main;;0;0;0.0 + | | +-;main;;8;8;100.0 + | +-;mult.cpp;28;8;8;100.0 + | +-;M::mult::mult();;0;1;0.0 + | +-;M::mult::mult();;1;0;0.0 + | +-;M::mult::multiply(long, long);;6;6;100.0 + | +-;M::mult::~mult();;0;1;0.0 + | +-;M::mult::~mult();;1;0;0.0 + +-;bits;1744;19;0;0.0 + +-;basic_ios.h;441;10;0;0.0 + | +-;std::basic_ios<char, std::char_traits<char> >::rdstate() const;;2;0;0.0 + | +-;std::basic_ios<char, std::char_traits<char> >::setstate(std::_Ios_Iostate);;2;0;0.0 + | +-;std::basic_ios<char, std::char_traits<char> >::widen(char) const;;2;0;0.0 + | +-;std::ctype<char> const& std::__check_facet<std::ctype<char> >(std::ctype<char> const*);;4;0;0.0 + +-;char_traits.h;264;2;0;0.0 + | +-;std::char_traits<char>::length(char const*);;2;0;0.0 + +-;ios_base.h;168;2;0;0.0 + | +-;std::operator|(std::_Ios_Iostate, std::_Ios_Iostate);;2;0;0.0 + +-;locale_facets.h;871;5;0;0.0 + +-;std::ctype<char>::widen(char) const;;5;0;0.0 diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFunction.ref b/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFunction.ref new file mode 100644 index 0000000..e8a0cbb --- /dev/null +++ b/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFunction.ref @@ -0,0 +1,27 @@ +Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage % ++-;Summary;2464;57;25;43.86 + +-;F::fact::f(long);;5;5;100.0 + +-;F::fact::fact();;0;1;0.0 + +-;F::fact::fact();;1;0;0.0 + +-;F::fact::~fact();;0;1;0.0 + +-;F::fact::~fact();;1;0;0.0 + +-;M::mult::mult();;0;1;0.0 + +-;M::mult::mult();;1;0;0.0 + +-;M::mult::multiply(long, long);;6;6;100.0 + +-;M::mult::~mult();;0;1;0.0 + +-;M::mult::~mult();;1;0;0.0 + +-;__static_initialization_and_destruction_0(int, int);;2;2;100.0 + +-;global constructors keyed to main;;0;0;0.0 + +-;main;;8;8;100.0 + +-;std::basic_ios<char, std::char_traits<char> >::rdstate() const;;2;0;0.0 + +-;std::basic_ios<char, std::char_traits<char> >::setstate(std::_Ios_Iostate);;2;0;0.0 + +-;std::basic_ios<char, std::char_traits<char> >::widen(char) const;;2;0;0.0 + +-;std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0 + +-;std::basic_ostream<char, std::char_traits<char> >& std::flush<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0 + +-;std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*);;5;0;0.0 + +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&));;2;0;0.0 + +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned long);;2;0;0.0 + +-;std::char_traits<char>::length(char const*);;2;0;0.0 + +-;std::ctype<char> const& std::__check_facet<std::ctype<char> >(std::ctype<char> const*);;4;0;0.0 + +-;std::ctype<char>::widen(char) const;;5;0;0.0 + +-;std::operator|(std::_Ios_Iostate, std::_Ios_Iostate);;2;0;0.0 |