Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2014-06-24 21:15:36 +0000
committerJeff Johnston2014-06-24 22:15:45 +0000
commit753276a27d94ba9a066fa4a92beba199bcf62385 (patch)
tree0b15800e527abee88d20882010df6266f1769b65 /build/org.eclipse.cdt.autotools.tests
parent1f29931ff1266efe491032c098741fc08ef7b5f5 (diff)
downloadorg.eclipse.cdt-753276a27d94ba9a066fa4a92beba199bcf62385.tar.gz
org.eclipse.cdt-753276a27d94ba9a066fa4a92beba199bcf62385.tar.xz
org.eclipse.cdt-753276a27d94ba9a066fa4a92beba199bcf62385.zip
Bug 438092 - Advanced Autotools flags not set for C++ projects
- enhance the FlagConfigureOption to handle multiple flags at once by accepting the | delimiter in the name and generate separate multiple flag outputs using the children flag value options - add a new CFLAGS|CXXFLAGS flag so that both CFLAGS and CXXFLAGS will be set at the same time (to handle both C and C++ source) - modify the Autotools tests to verify the fix works Change-Id: I4e97c1a16381a3a10404e2fd20f8e49d99590db5 Reviewed-on: https://git.eclipse.org/r/28941 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
Diffstat (limited to 'build/org.eclipse.cdt.autotools.tests')
-rw-r--r--build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java99
1 files changed, 97 insertions, 2 deletions
diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java
index 9e3fa4aad41..6e62368bbe4 100644
--- a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java
+++ b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java
@@ -12,8 +12,8 @@
package org.eclipse.cdt.autotools.tests;
import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
-import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
@@ -63,6 +63,101 @@ public class UpdateConfigureTest extends TestCase {
}
/**
+ * Test setting the special advanced options for gcov, gprof, and debug flags. Verify that
+ * the configure script sets both the C and C++ flags.
+ * @throws Exception
+ */
+ public void testGprofGcovDebugFlagOptions() throws Exception {
+ Path p = new Path("zip/project2.zip");
+ ProjectTools.addSourceContainerWithImport(testProject, "src", p, null);
+ assertTrue(testProject.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ ProjectTools.setConfigDir(testProject, "src");
+ ProjectTools.markExecutable(testProject, "src/autogen.sh");
+ assertTrue(ProjectTools.build());
+ ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject).getActiveConfiguration();
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
+ assertTrue(cfg.getName().equals("Build (GNU)"));
+ Map<String, IAutotoolsOption> opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
+
+ IAutotoolsOption k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GPROF);
+ k.setValue("true");
+
+ // Now update the options we changed
+ AutotoolsPlugin.getDefault().updateAutotoolCfgOptions(testProject, cfg.getId(), opts);
+
+ // Rebuild project
+ assertTrue(ProjectTools.build());
+
+ org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("config.log");
+ assertTrue(testProject.exists(x));
+
+ IResource r = testProject.findMember(x);
+
+ File f = r.getLocation().toFile();
+
+ FileReader fr = new FileReader(f);
+
+ char[] cbuf = new char[2000];
+ fr.read(cbuf);
+
+ String s = new String(cbuf);
+
+ assertTrue(s.contains("testProject2/src/configure CFLAGS=-pg CXXFLAGS=-pg"));
+
+ fr.close();
+
+ // Reset gprof opt and set gcov opt
+ opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
+ k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GPROF);
+ k.setValue("false");
+
+ k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GCOV);
+ k.setValue("true");
+
+ // Now update the options we changed
+ AutotoolsPlugin.getDefault().updateAutotoolCfgOptions(testProject, cfg.getId(), opts);
+
+ // Rebuild project
+ assertTrue(ProjectTools.build());
+
+ r = testProject.findMember(x);
+ f = r.getLocation().toFile();
+ fr = new FileReader(f);
+ fr.read(cbuf);
+
+ s = new String(cbuf);
+
+ assertTrue(s.contains("testProject2/src/configure CFLAGS=-fprofile-arcs -ftest-coverage CXXFLAGS=-fprofile-arcs -ftest-coverage"));
+
+ fr.close();
+
+ // Reset gcov opt and set debug opt
+ opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
+ k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GCOV);
+ k.setValue("false");
+
+ k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_DEBUG);
+ k.setValue("true");
+
+ // Now update the options we changed
+ AutotoolsPlugin.getDefault().updateAutotoolCfgOptions(testProject, cfg.getId(), opts);
+
+ // Rebuild project
+ assertTrue(ProjectTools.build());
+
+ r = testProject.findMember(x);
+ f = r.getLocation().toFile();
+ fr = new FileReader(f);
+ fr.read(cbuf);
+
+ s = new String(cbuf);
+
+ assertTrue(s.contains("testProject2/src/configure CFLAGS=-g CXXFLAGS=-g"));
+
+ fr.close();
+ }
+
+ /**
* Test getting and updating configuration options for an Autotools Project. The top-level
* contains autogen.sh which will build configure, but not run it.
* @throws Exception
@@ -106,7 +201,7 @@ public class UpdateConfigureTest extends TestCase {
assertFalse(k.canUpdate());
assertEquals(k.getType(), IAutotoolsOption.CATEGORY);
- k = opts.get(AutotoolsOptionConstants.FLAG_CFLAGS);
+ k = opts.get(AutotoolsOptionConstants.FLAG_CFLAGS_CXXFLAGS);
assertFalse(k.canUpdate());
assertEquals(k.getType(), IAutotoolsOption.FLAG);

Back to the top