From 683d490074d93baa8a47db7ec43b7bd31145a12a Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Thu, 5 Nov 2009 23:00:15 +0100 Subject: Tar file expanded and committed --- .../sf/antcontrib/cpptasks/MockBuildListener.java | 172 + .../sf/antcontrib/cpptasks/MockFileCollector.java | 90 + .../net/sf/antcontrib/cpptasks/TestAllClasses.java | 63 + .../net/sf/antcontrib/cpptasks/TestCCTask.java | 128 + .../java/net/sf/antcontrib/cpptasks/TestCUtil.java | 153 + .../sf/antcontrib/cpptasks/TestCompilerDef.java | 357 +++ .../sf/antcontrib/cpptasks/TestCompilerEnum.java | 51 + .../antcontrib/cpptasks/TestDependencyTable.java | 73 + .../net/sf/antcontrib/cpptasks/TestLinkerDef.java | 374 +++ .../net/sf/antcontrib/cpptasks/TestLinkerEnum.java | 40 + .../sf/antcontrib/cpptasks/TestOutputTypeEnum.java | 39 + .../sf/antcontrib/cpptasks/TestProcessorDef.java | 278 ++ .../cpptasks/TestTargetHistoryTable.java | 141 + .../net/sf/antcontrib/cpptasks/TestTargetInfo.java | 134 + .../sf/antcontrib/cpptasks/TestXMLConsumer.java | 96 + .../cpptasks/borland/TestBorlandCCompiler.java | 37 + .../cpptasks/compiler/TestAbstractCompiler.java | 85 + .../cpptasks/compiler/TestAbstractLinker.java | 89 + .../cpptasks/compiler/TestAbstractProcessor.java | 80 + .../TestCommandLineCompilerConfiguration.java | 59 + .../compiler/TestCompilerConfiguration.java | 68 + .../antcontrib/cpptasks/compiler/TestLinkType.java | 59 + .../devstudio/TestDevStudio2005CCompiler.java | 41 + .../cpptasks/devstudio/TestDevStudioCCompiler.java | 41 + .../cpptasks/devstudio/TestDevStudioLinker.java | 44 + .../devstudio/TestInstalledDevStudioLinker.java | 60 + .../cpptasks/gcc/TestAbstractArLibrarian.java | 79 + .../cpptasks/gcc/TestAbstractLdLinker.java | 247 ++ .../antcontrib/cpptasks/gcc/TestGccCCompiler.java | 80 + .../cpptasks/gcc/TestGccCompatibleCCompiler.java | 105 + .../sf/antcontrib/cpptasks/gcc/TestGccLinker.java | 79 + .../sf/antcontrib/cpptasks/hp/TestaCCCompiler.java | 93 + .../cpptasks/ibm/TestVisualAgeCCompiler.java | 68 + .../java/net/sf/antcontrib/cpptasks/package.html | 28 + .../sf/antcontrib/cpptasks/parser/TestCParser.java | 199 ++ .../cpptasks/parser/TestFortranParser.java | 81 + .../net/sf/antcontrib/cpptasks/parser/package.html | 27 + .../cpptasks/sun/TestForteCCCompiler.java | 132 + .../cpptasks/trolltech/TestMetaObjectCompiler.java | 74 + .../cpptasks/trolltech/TestMetaObjectParser.java | 58 + .../sf/antcontrib/cpptasks/trolltech/package.html | 27 + .../cpptasks/types/TestDefineArgument.java | 124 + .../antcontrib/cpptasks/types/TestLibrarySet.java | 337 ++ .../net/sf/antcontrib/cpptasks/types/package.html | 28 + src/test/resources/openshore/dependencies.xml | 911 ++++++ src/test/resources/openshore/history.xml | 74 + src/test/resources/xerces-c/dependencies.xml | 3330 ++++++++++++++++++++ src/test/resources/xerces-c/history.xml | 636 ++++ 48 files changed, 9669 insertions(+) create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/MockBuildListener.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/MockFileCollector.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestAllClasses.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestCCTask.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestCUtil.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestCompilerDef.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestCompilerEnum.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestDependencyTable.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestLinkerEnum.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestOutputTypeEnum.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestProcessorDef.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestTargetInfo.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/TestXMLConsumer.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/borland/TestBorlandCCompiler.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/compiler/TestCommandLineCompilerConfiguration.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/compiler/TestLinkType.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudio2005CCompiler.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioCCompiler.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioLinker.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudioLinker.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccCCompiler.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccCompatibleCCompiler.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/hp/TestaCCCompiler.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/ibm/TestVisualAgeCCompiler.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/package.html create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/parser/TestCParser.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/parser/TestFortranParser.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/parser/package.html create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/sun/TestForteCCCompiler.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectParser.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/trolltech/package.html create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/types/TestDefineArgument.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/types/package.html create mode 100644 src/test/resources/openshore/dependencies.xml create mode 100644 src/test/resources/openshore/history.xml create mode 100644 src/test/resources/xerces-c/dependencies.xml create mode 100644 src/test/resources/xerces-c/history.xml (limited to 'src/test') diff --git a/src/test/java/net/sf/antcontrib/cpptasks/MockBuildListener.java b/src/test/java/net/sf/antcontrib/cpptasks/MockBuildListener.java new file mode 100644 index 0000000..e7bd999 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/MockBuildListener.java @@ -0,0 +1,172 @@ +/* + * + * Copyright 2003-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks; +import java.util.Vector; + +import org.apache.tools.ant.BuildEvent; +import org.apache.tools.ant.BuildListener; +/** + * Captures build events + * + */ +public class MockBuildListener implements BuildListener { + private Vector buildFinishedEvents = new Vector(); + private Vector buildStartedEvents = new Vector(); + private Vector messageLoggedEvents = new Vector(); + private Vector targetFinishedEvents = new Vector(); + private Vector targetStartedEvents = new Vector(); + private Vector taskFinishedEvents = new Vector(); + private Vector taskStartedEvents = new Vector(); + /** + * Signals that the last target has finished. This event will still be + * fired if an error occurred during the build. + * + * @param event + * An event with any relevant extra information. Must not be + * null. + * + * @see BuildEvent#getException() + */ + public void buildFinished(BuildEvent event) { + buildFinishedEvents.addElement(event); + } + /** + * Signals that a build has started. This event is fired before any targets + * have started. + * + * @param event + * An event with any relevant extra information. Must not be + * null. + */ + public void buildStarted(BuildEvent event) { + buildStartedEvents.addElement(event); + } + public Vector getBuildFinishedEvents() { + return new Vector(buildFinishedEvents); + } + /** + * Gets a list of buildStarted events + * + * @return list of build started events + */ + public Vector getBuildStartedEvents() { + return new Vector(buildStartedEvents); + } + /** + * Gets message logged events + * + * @return vector of "MessageLogged" events. + */ + public Vector getMessageLoggedEvents() { + return new Vector(messageLoggedEvents); + } + /** + * Gets target finished events + * + * @return vector of "TargetFinished" events. + */ + public Vector getTargetFinishedEvents() { + return new Vector(targetFinishedEvents); + } + /** + * Gets target started events + * + * @return vector of "TargetStarted" events. + */ + public Vector getTargetStartedEvents() { + return new Vector(targetStartedEvents); + } + /** + * Gets task finished events + * + * @return vector of "TaskFinished" events. + */ + public Vector getTaskFinishedEvents() { + return new Vector(taskFinishedEvents); + } + /** + * Gets task started events + * + * @return vector of "TaskStarted" events. + */ + public Vector getTaskStartedEvents() { + return new Vector(taskStartedEvents); + } + /** + * Signals a message logging event. + * + * @param event + * An event with any relevant extra information. Must not be + * null. + * + * @see BuildEvent#getMessage() + * @see BuildEvent#getPriority() + */ + public void messageLogged(BuildEvent event) { + messageLoggedEvents.addElement(event); + } + /** + * Signals that a target has finished. This event will still be fired if an + * error occurred during the build. + * + * @param event + * An event with any relevant extra information. Must not be + * null. + * + * @see BuildEvent#getException() + */ + public void targetFinished(BuildEvent event) { + targetFinishedEvents.addElement(event); + } + /** + * Signals that a target is starting. + * + * @param event + * An event with any relevant extra information. Must not be + * null. + * + * @see BuildEvent#getTarget() + */ + public void targetStarted(BuildEvent event) { + targetStartedEvents.addElement(event); + } + /** + * Signals that a task has finished. This event will still be fired if an + * error occurred during the build. + * + * @param event + * An event with any relevant extra information. Must not be + * null. + * + * @see BuildEvent#getException() + */ + public void taskFinished(BuildEvent event) { + taskFinishedEvents.addElement(event); + } + /** + * Signals that a task is starting. + * + * @param event + * An event with any relevant extra information. Must not be + * null. + * + * @see BuildEvent#getTask() + */ + public void taskStarted(BuildEvent event) { + taskStartedEvents.addElement(event); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/MockFileCollector.java b/src/test/java/net/sf/antcontrib/cpptasks/MockFileCollector.java new file mode 100644 index 0000000..d1768fd --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/MockFileCollector.java @@ -0,0 +1,90 @@ +/* + * + * Copyright 2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package net.sf.antcontrib.cpptasks; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * Implementation of FileVisitor that collects visited files for later + * retrieval. + * + * @author Curt Arnold + * + */ +public final class MockFileCollector + implements FileVisitor { + + /** + * list of fileName parameter values. + */ + private final List fileNames = new ArrayList(); + + /** + * list of baseDir parameter values. + */ + private final List baseDirs = new ArrayList(); + + /** + * Constructor. + * + */ + public MockFileCollector() { + } + + /** + * Implementation of FileVisitor.visit. + * @param baseDir base directory + * @param fileName file name + */ + public void visit(final File baseDir, final String fileName) { + fileNames.add(fileName); + baseDirs.add(baseDir); + } + + /** + * Get value of fileName parameter for a specified index. + * + * @param index + * index + * @return value of failName parameter + */ + public String getFileName(final int index) { + return (String) fileNames.get(index); + } + + /** + * Get value of baseDir parameter for the specified index. + * + * @param index + * index + * @return value of baseDir parameter + */ + public File getBaseDir(final int index) { + return (File) baseDirs.get(index); + } + + /** + * Get count of calls to FileVisitor.visit. + * + * @return count of calls. + */ + public int size() { + return fileNames.size(); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestAllClasses.java b/src/test/java/net/sf/antcontrib/cpptasks/TestAllClasses.java new file mode 100644 index 0000000..e85fe27 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestAllClasses.java @@ -0,0 +1,63 @@ +/* + * + * Copyright 2002-2007 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks; +import junit.framework.TestSuite; +/** + * Test for abstract compiler class + * + * Override create to test concrete compiler implementions + */ +public class TestAllClasses extends TestSuite { + public static TestSuite suite() { + return new TestAllClasses("TestAllClasses"); + } + public TestAllClasses(String name) { + super(name); + addTestSuite(net.sf.antcontrib.cpptasks.TestCUtil.class); + addTestSuite(net.sf.antcontrib.cpptasks.borland.TestBorlandCCompiler.class); + addTestSuite(net.sf.antcontrib.cpptasks.compiler.TestAbstractCompiler.class); + addTestSuite(net.sf.antcontrib.cpptasks.compiler.TestAbstractLinker.class); + addTestSuite(net.sf.antcontrib.cpptasks.compiler.TestAbstractProcessor.class); + addTestSuite(net.sf.antcontrib.cpptasks.TestCCTask.class); + addTestSuite(net.sf.antcontrib.cpptasks.TestCompilerEnum.class); + addTestSuite(net.sf.antcontrib.cpptasks.compiler.TestCommandLineCompilerConfiguration.class); + addTestSuite(net.sf.antcontrib.cpptasks.TestDependencyTable.class); + addTestSuite(net.sf.antcontrib.cpptasks.types.TestDefineArgument.class); + addTestSuite(net.sf.antcontrib.cpptasks.devstudio.TestDevStudio2005CCompiler.class); + addTestSuite(net.sf.antcontrib.cpptasks.devstudio.TestDevStudioCCompiler.class); + addTestSuite(net.sf.antcontrib.cpptasks.devstudio.TestDevStudioLinker.class); + addTestSuite(net.sf.antcontrib.cpptasks.TestLinkerDef.class); + addTestSuite(net.sf.antcontrib.cpptasks.TestTargetInfo.class); + addTestSuite(net.sf.antcontrib.cpptasks.types.TestLibrarySet.class); + addTestSuite(net.sf.antcontrib.cpptasks.TestCompilerDef.class); + addTestSuite(net.sf.antcontrib.cpptasks.parser.TestCParser.class); + addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestGccCCompiler.class); + addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestAbstractLdLinker.class); + addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestAbstractArLibrarian.class); + addTestSuite(net.sf.antcontrib.cpptasks.TestTargetHistoryTable.class); + addTestSuite(net.sf.antcontrib.cpptasks.TestOutputTypeEnum.class); + addTestSuite(net.sf.antcontrib.cpptasks.compiler.TestLinkType.class); + addTestSuite(net.sf.antcontrib.cpptasks.TestLinkerEnum.class); + addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestAbstractLdLinker.class); + addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestAbstractArLibrarian.class); + addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestGccLinker.class); + addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestGccLinker.class); + addTestSuite(net.sf.antcontrib.cpptasks.sun.TestForteCCCompiler.class); + addTestSuite(net.sf.antcontrib.cpptasks.hp.TestaCCCompiler.class); + addTestSuite(net.sf.antcontrib.cpptasks.ibm.TestVisualAgeCCompiler.class); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestCCTask.java b/src/test/java/net/sf/antcontrib/cpptasks/TestCCTask.java new file mode 100644 index 0000000..82faae2 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestCCTask.java @@ -0,0 +1,128 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package net.sf.antcontrib.cpptasks; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Hashtable; +import java.util.Vector; +import junit.framework.TestCase; +import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration; +import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration; +import net.sf.antcontrib.cpptasks.gcc.GccCCompiler; + +/** + * Tests for CCTask. + * + */ +public final class TestCCTask + extends TestCase { + /** + * Constructor. + * @param name test name + * + */ + public TestCCTask(final String name) { + super(name); + } + + /** + * Test that a target with no existing object file is + * returned by getTargetsToBuildByConfiguration. + */ + public void testGetTargetsToBuildByConfiguration1() { + CompilerConfiguration config1 = new CommandLineCompilerConfiguration( + (GccCCompiler) GccCCompiler.getInstance(), "dummy", + new File[0], new File[0], new File[0], "", new String[0], + new ProcessorParam[0], true, new String[0]); + TargetInfo target1 = new TargetInfo(config1, new File[] {new File( + "src/foo.bar")} + , null, new File("foo.obj"), true); + Hashtable targets = new Hashtable(); + targets.put(target1.getOutput(), target1); + Hashtable targetsByConfig = CCTask + .getTargetsToBuildByConfiguration(targets); + Vector targetsForConfig1 = (Vector) targetsByConfig.get(config1); + assertNotNull(targetsForConfig1); + assertEquals(1, targetsForConfig1.size()); + TargetInfo targetx = (TargetInfo) targetsForConfig1.elementAt(0); + assertSame(target1, targetx); + } + + /** + * Test that a target that is up to date is not returned by + * getTargetsToBuildByConfiguration. + * + */ + public void testGetTargetsToBuildByConfiguration2() { + CompilerConfiguration config1 = new CommandLineCompilerConfiguration( + (GccCCompiler) GccCCompiler.getInstance(), "dummy", + new File[0], new File[0], new File[0], "", new String[0], + new ProcessorParam[0], false, new String[0]); + // + // target doesn't need to be rebuilt + // + TargetInfo target1 = new TargetInfo(config1, new File[] {new File( + "src/foo.bar")} + , null, new File("foo.obj"), false); + Hashtable targets = new Hashtable(); + targets.put(target1.getOutput(), target1); + // + // no targets need to be built, return a zero-length hashtable + // + Hashtable targetsByConfig = CCTask + .getTargetsToBuildByConfiguration(targets); + assertEquals(0, targetsByConfig.size()); + } + + /** + * Tests that the default value of failonerror is true. + */ + public void testGetFailOnError() { + CCTask task = new CCTask(); + boolean failOnError = task.getFailonerror(); + assertEquals(true, failOnError); + } + + /** + * Tests that setting failonerror is effective. + */ + public void testSetFailOnError() { + CCTask task = new CCTask(); + task.setFailonerror(false); + boolean failOnError = task.getFailonerror(); + assertEquals(false, failOnError); + task.setFailonerror(true); + failOnError = task.getFailonerror(); + assertEquals(true, failOnError); + } + + /** + * Test checks for the presence of antlib.xml. + * @throws IOException if stream can't be closed. + * + */ + public void testAntlibXmlPresent() throws IOException { + InputStream stream = TestCCTask.class.getClassLoader() + .getResourceAsStream("net/sf/antcontrib/cpptasks/antlib.xml"); + if (stream != null) { + stream.close(); + } + assertNotNull("antlib.xml missing", stream); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestCUtil.java b/src/test/java/net/sf/antcontrib/cpptasks/TestCUtil.java new file mode 100644 index 0000000..42b86d3 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestCUtil.java @@ -0,0 +1,153 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks; +import java.io.File; +import java.io.IOException; + +import junit.framework.TestCase; +/** + * Tests for CUtil class + */ +public class TestCUtil extends TestCase { + public TestCUtil(String name) { + super(name); + } + public void testGetPathFromEnvironment() { + File[] files = CUtil.getPathFromEnvironment("LIB", ";"); + assertNotNull(files); + } + public void testGetRelativePath1() throws IOException { + String canonicalBase = new File("/foo/bar/").getCanonicalPath(); + String rel = CUtil.getRelativePath(canonicalBase, new File( + "/foo/bar/baz")); + assertEquals("baz", rel); + } + public void testGetRelativePath2() throws IOException { + String canonicalBase = new File("/foo/bar/").getCanonicalPath(); + String rel = CUtil + .getRelativePath(canonicalBase, new File("/foo/bar/")); + assertEquals(".", rel); + } + public void testGetRelativePath3() throws IOException { + String canonicalBase = new File("/foo/bar/").getCanonicalPath(); + String rel = CUtil.getRelativePath(canonicalBase, + new File("/foo/bar/a")); + assertEquals("a", rel); + } + public void testGetRelativePath4() throws IOException { + String canonicalBase = new File("/foo/bar/").getCanonicalPath(); + String rel = CUtil.getRelativePath(canonicalBase, new File("/foo/")); + assertEquals("..", rel); + } + public void testGetRelativePath5() throws IOException { + String canonicalBase = new File("/foo/bar/").getCanonicalPath(); + String rel = CUtil.getRelativePath(canonicalBase, new File("/a")); + String expected = ".." + File.separator + ".." + File.separator + "a"; + assertEquals(expected, rel); + } + public void testGetRelativePath6() throws IOException { + String canonicalBase = new File("/foo/bar/").getCanonicalPath(); + String rel = CUtil.getRelativePath(canonicalBase, new File( + "/foo/baz/bar")); + String expected = ".." + File.separator + "baz" + File.separator + + "bar"; + assertEquals(expected, rel); + } + public void testGetRelativePath7() throws IOException { + String canonicalBase = new File("/foo/bar/").getCanonicalPath(); + // + // skip the UNC test unless running on Windows + // + String osName = System.getProperty("os.name"); + if (osName.indexOf("Windows") >= 0) { + File uncFile = new File("\\\\fred\\foo.bar"); + String uncPath; + try { + uncPath = uncFile.getCanonicalPath(); + } catch (IOException ex) { + uncPath = uncFile.toString(); + } + String rel = CUtil.getRelativePath(canonicalBase, uncFile); + assertEquals(uncPath, rel); + } + } + public void testGetRelativePath8() throws IOException { + String canonicalBase = new File("/foo/bar/something").getCanonicalPath(); + String rel = CUtil.getRelativePath(canonicalBase, + new File("/foo/bar/something.extension")); + String expected = ".." + File.separator + "something.extension"; + assertEquals(expected, rel); + } + public void testGetRelativePath9() throws IOException { + String canonicalBase = new +File("/foo/bar/something").getCanonicalPath(); + String rel = CUtil.getRelativePath(canonicalBase, + new File("/foo/bar/somethingElse")); + String expected = ".." + File.separator + "somethingElse"; + assertEquals(expected, rel); + } + public void testGetRelativePath10() throws IOException { + String canonicalBase = new +File("/foo/bar/something").getCanonicalPath(); + String rel = CUtil.getRelativePath(canonicalBase, + new File("/foo/bar/something else")); + String expected = ".." + File.separator + "something else"; + assertEquals(expected, rel); + } + public void testParsePath1() { + File[] files = CUtil.parsePath("", ";"); + assertEquals(0, files.length); + } + public void testParsePath2() { + String workingDir = System.getProperty("user.dir"); + File[] files = CUtil.parsePath(workingDir, ";"); + assertEquals(1, files.length); + File workingDirFile = new File(workingDir); + assertEquals(workingDirFile, files[0]); + } + public void testParsePath3() { + String workingDir = System.getProperty("user.dir"); + File[] files = CUtil.parsePath(workingDir + ";", ";"); + assertEquals(1, files.length); + assertEquals(new File(workingDir), files[0]); + } + public void testParsePath4() { + String workingDir = System.getProperty("user.dir"); + String javaHome = System.getProperty("java.home"); + File[] files = CUtil.parsePath(workingDir + ";" + javaHome, ";"); + assertEquals(2, files.length); + assertEquals(new File(workingDir), files[0]); + assertEquals(new File(javaHome), files[1]); + } + public void testParsePath5() { + String workingDir = System.getProperty("user.dir"); + String javaHome = System.getProperty("java.home"); + File[] files = CUtil.parsePath(workingDir + ";" + javaHome + ";", ";"); + assertEquals(2, files.length); + assertEquals(new File(workingDir), files[0]); + assertEquals(new File(javaHome), files[1]); + } + + /** + * Test of xmlAttributeEncode. + * + * See patch 1267472 and bug 1032302. + */ + public void testXmlEncode() { + assertEquals("<"boo">", CUtil.xmlAttribEncode("<\"boo\">")); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestCompilerDef.java b/src/test/java/net/sf/antcontrib/cpptasks/TestCompilerDef.java new file mode 100644 index 0000000..12e1967 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestCompilerDef.java @@ -0,0 +1,357 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package net.sf.antcontrib.cpptasks; + +import java.io.File; +import java.io.IOException; +import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration; +import net.sf.antcontrib.cpptasks.compiler.Compiler; +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.devstudio.DevStudioCCompiler; +import net.sf.antcontrib.cpptasks.gcc.GccCCompiler; +import net.sf.antcontrib.cpptasks.types.CompilerArgument; +import net.sf.antcontrib.cpptasks.types.ConditionalPath; +import net.sf.antcontrib.cpptasks.types.DefineArgument; +import net.sf.antcontrib.cpptasks.types.DefineSet; +import net.sf.antcontrib.cpptasks.types.IncludePath; +import net.sf.antcontrib.cpptasks.types.SystemIncludePath; +import net.sf.antcontrib.cpptasks.types.UndefineArgument; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; + +/** + * Tests for CompilerDef. + */ +public final class TestCompilerDef + extends TestProcessorDef { + /** + * Constructor. + * + * @param name + * test name + */ + public TestCompilerDef(final String name) { + super(name); + } + + /** + * Creates a new processor. + * + * @return new processor + */ + protected ProcessorDef create() { + return new CompilerDef(); + } + + /** + * This method tests CompilerDef.getActiveDefines. + * + * A CompilerDef is created similar to what would be created for + * + * + * + * Then getActiveDefines is called for a project without and with the + * "debug" property defined. Return value from getActiveDefines should + * contain one member + */ + public void testGetActiveDefines() { + Project project = new org.apache.tools.ant.Project(); + CompilerDef def = new CompilerDef(); + def.setProject(project); + DefineSet defset = new DefineSet(); + DefineArgument arg1 = new DefineArgument(); + arg1.setName("DEBUG"); + arg1.setIf("debug"); + defset.addDefine(arg1); + DefineArgument arg2 = new DefineArgument(); + arg2.setName("NDEBUG"); + arg2.setUnless("debug"); + defset.addDefine(arg2); + def.addConfiguredDefineset(defset); + // + // Evaluate without "debug" set + // + UndefineArgument[] activeArgs = def.getActiveDefines(); + assertEquals(1, activeArgs.length); + assertEquals("NDEBUG", activeArgs[0].getName()); + // + // Set the "debug" property + // + project.setProperty("debug", ""); + activeArgs = def.getActiveDefines(); + assertEquals(1, activeArgs.length); + assertEquals("DEBUG", activeArgs[0].getName()); + } + + /** + * This method tests CompilerDef.getActiveIncludePath. + * + * A CompilerDef is created similar to what would be created for + * + * + * + * and is evaluate for a project without and without "debug" set + */ + public void testGetActiveIncludePaths() { + Project project = new org.apache.tools.ant.Project(); + CompilerDef def = new CompilerDef(); + def.setProject(project); + ConditionalPath path = def.createIncludePath(); + path.setLocation(new File("..")); + path.setIf("debug"); + // + // Evaluate without "debug" set + // + String[] includePaths = def.getActiveIncludePaths(); + assertEquals(0, includePaths.length); + // + // Set the "debug" property + // + project.setProperty("debug", ""); + includePaths = def.getActiveIncludePaths(); + assertEquals(1, includePaths.length); + } + + /** + * Tests that setting classname to the Gcc compiler is effective. + */ + public void testGetGcc() { + CompilerDef compilerDef = (CompilerDef) create(); + compilerDef.setClassname("net.sf.antcontrib.cpptasks.gcc.GccCCompiler"); + Compiler comp = (Compiler) compilerDef.getProcessor(); + assertNotNull(comp); + assertSame(GccCCompiler.getInstance(), comp); + } + + /** + * Tests that setting classname to the MSVC compiler is effective. + */ + public void testGetMSVC() { + CompilerDef compilerDef = (CompilerDef) create(); + compilerDef + .setClassname( + "net.sf.antcontrib.cpptasks.devstudio.DevStudioCCompiler"); + Compiler comp = (Compiler) compilerDef.getProcessor(); + assertNotNull(comp); + assertSame(DevStudioCCompiler.getInstance(), comp); + } + + /** + * Tests that setting classname to an bogus class name results in a + * BuildException. + */ + public void testUnknownClass() { + CompilerDef compilerDef = (CompilerDef) create(); + try { + compilerDef + .setClassname("net.sf.antcontrib.cpptasks.bogus.BogusCompiler"); + } catch (BuildException ex) { + return; + } + fail("Exception not thrown"); + } + + /** + * Test that setting classname to a class that doesn't support Compiler + * throws a BuildException. + * + */ + public void testWrongType() { + CompilerDef compilerDef = (CompilerDef) create(); + try { + compilerDef + .setClassname("net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker"); + } catch (BuildException ex) { + return; + } + fail("Exception not thrown"); + } + + /** + * Gets the command line arguments that precede filenames. + * + * @param processor + * processor under test + * @return command line arguments + */ + protected String[] getPreArguments(final ProcessorDef processor) { + return ((CommandLineCompilerConfiguration) getConfiguration(processor)) + .getPreArguments(); + } + + /** + * Tests if a fileset enclosed in the base compiler definition is effective. + * + * @throws IOException + * if unable to create or delete a temporary file + */ + public void testExtendsFileSet() throws IOException { + super.testExtendsFileSet(File.createTempFile("cpptaskstest", ".cpp")); + } + + /** + * Tests if the rebuild attribute of the base compiler definition is + * effective. + * + */ + public void testExtendsRebuild() { + testExtendsRebuild(new CompilerDef()); + } + + /** + * Tests that compilerarg's contained in the base compiler definition are + * effective. + */ + public void testExtendsCompilerArgs() { + CompilerDef baseLinker = new CompilerDef(); + CompilerArgument linkerArg = new CompilerArgument(); + linkerArg.setValue("/base"); + baseLinker.addConfiguredCompilerArg(linkerArg); + CompilerDef extendedLinker = (CompilerDef) createExtendedProcessorDef( + baseLinker); + String[] preArgs = getPreArguments(extendedLinker); + assertEquals(2, preArgs.length); + assertEquals("/base", preArgs[0]); + } + + /** + * Tests that defineset's contained in the base compiler definition are + * effective. + */ + public void testExtendsDefineSet() { + CompilerDef baseCompiler = new CompilerDef(); + DefineSet defSet = new DefineSet(); + DefineArgument define = new DefineArgument(); + define.setName("foo"); + define.setValue("bar"); + defSet.addDefine(define); + baseCompiler.addConfiguredDefineset(defSet); + CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef( + baseCompiler); + String[] preArgs = getPreArguments(extendedCompiler); + assertEquals(2, preArgs.length); + assertEquals("-Dfoo=bar", preArgs[1]); + } + + /** + * Tests that includepath's contained in the base compiler definition are + * effective. + */ + public void testExtendsIncludePath() { + CompilerDef baseCompiler = new CompilerDef(); + CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef( + baseCompiler); + IncludePath path = baseCompiler.createIncludePath(); + path.setPath("/tmp"); + String[] preArgs = getPreArguments(extendedCompiler); + assertEquals(2, preArgs.length); + assertEquals("-I", preArgs[1].substring(0, 2)); + } + + /** + * Tests that sysincludepath's contained in the base compiler definition are + * effective. + */ + public void testExtendsSysIncludePath() { + CompilerDef baseCompiler = new CompilerDef(); + CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef( + baseCompiler); + SystemIncludePath path = baseCompiler.createSysIncludePath(); + path.setPath("/tmp"); + String[] preArgs = getPreArguments(extendedCompiler); + assertEquals(2, preArgs.length); + assertEquals("-I", preArgs[1].substring(0, 2)); + } + + /** + * Sets the name attribute. + * + * @param compiler + * compiler under test + * @param name + * compiler name + */ + private static void setCompilerName(final CompilerDef compiler, + final String name) { + CompilerEnum compilerName = new CompilerEnum(); + compilerName.setValue(name); + compiler.setName(compilerName); + } + + /** + * Tests that the extend attribute of the base compiler definition is + * effective. + */ + public void testExtendsExceptions() { + CompilerDef baseCompiler = new CompilerDef(); + baseCompiler.setExceptions(true); + CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef( + baseCompiler); + setCompilerName(extendedCompiler, "msvc"); + String[] preArgs = getPreArguments(extendedCompiler); + assertEquals("/EHsc", preArgs[2]); + } + + /** + * Tests that the multithread attribute of the base compiler definition is + * effective. + */ + public void testExtendsMultithreaded() { + CompilerDef baseCompiler = new CompilerDef(); + baseCompiler.setMultithreaded(false); + CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef( + baseCompiler); + setCompilerName(extendedCompiler, "msvc"); + CCTask cctask = new CCTask(); + LinkType linkType = new LinkType(); + linkType.setStaticRuntime(true); + CommandLineCompilerConfiguration config = (CommandLineCompilerConfiguration) + extendedCompiler + .createConfiguration(cctask, linkType, null, null, null); + String[] preArgs = config.getPreArguments(); + assertEquals("/ML", preArgs[3]); + } + + /** + * Tests that the name attribute in the base compiler is effective. + */ + public void testExtendsName() { + CompilerDef baseCompiler = new CompilerDef(); + setCompilerName(baseCompiler, "msvc"); + CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef( + baseCompiler); + extendedCompiler.setExceptions(true); + String[] preArgs = getPreArguments(extendedCompiler); + assertEquals("/EHsc", preArgs[2]); + } + + /** + * Tests that the classname attribute in the base compiler is effective. + */ + public void testExtendsClassname() { + CompilerDef baseCompiler = new CompilerDef(); + baseCompiler + .setClassname( + "net.sf.antcontrib.cpptasks.devstudio.DevStudioCCompiler"); + CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef( + baseCompiler); + extendedCompiler.setExceptions(true); + String[] preArgs = getPreArguments(extendedCompiler); + assertEquals("/EHsc", preArgs[2]); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestCompilerEnum.java b/src/test/java/net/sf/antcontrib/cpptasks/TestCompilerEnum.java new file mode 100644 index 0000000..6fc72ba --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestCompilerEnum.java @@ -0,0 +1,51 @@ +/* + * + * Copyright 2002-2005 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks; +import junit.framework.TestCase; + +import org.apache.tools.ant.BuildException; +/** + * Tests for CompilerEnum. + */ +public class TestCompilerEnum extends TestCase { + /** + * Create instance of TestCompilerEnum. + * @param name test name. + */ + public TestCompilerEnum(final String name) { + super(name); + } + /** + * Test that "gcc" is recognized as a compiler enum. + */ + public void testCompilerEnum1() { + CompilerEnum compilerEnum = new CompilerEnum(); + compilerEnum.setValue("gcc"); + assertTrue(compilerEnum.getIndex() >= 0); + } + /** + * Test that "bogus" is not recognized as a compiler enum. + */ + public void testCompilerEnum2() { + CompilerEnum compilerEnum = new CompilerEnum(); + try { + compilerEnum.setValue("bogus"); + fail(); + } catch (BuildException ex) { + } + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestDependencyTable.java b/src/test/java/net/sf/antcontrib/cpptasks/TestDependencyTable.java new file mode 100644 index 0000000..0796353 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestDependencyTable.java @@ -0,0 +1,73 @@ +/* + * + * Copyright 2003-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks; +import java.io.File; +import java.io.IOException; + +import javax.xml.parsers.ParserConfigurationException; + +import org.xml.sax.SAXException; +/** + * DependencyTable tests + * + * @author curta + */ +public class TestDependencyTable extends TestXMLConsumer { + /** + * Constructor + * + * @param testName + * test name + */ + public TestDependencyTable(String testName) { + super(testName); + } + /** + * Loads a dependency file from OpenSHORE (http://www.openshore.org) + * + * @throws IOException + */ + public void testLoadOpenshore() throws IOException, + ParserConfigurationException, SAXException { + String tmpDir = System.getProperty("java.io.tmpdir"); + try { + copyResourceToTmpDir("openshore/dependencies.xml", + "dependencies.xml"); + DependencyTable dependencies = new DependencyTable(new File(tmpDir)); + dependencies.load(); + } finally { + deleteTmpFile("dependencies.xml"); + } + } + /** + * Loads a dependency file from Xerces-C (http://xml.apache.org) + * + * @throws IOException + */ + public void testLoadXerces() throws IOException, + ParserConfigurationException, SAXException { + String tmpDir = System.getProperty("java.io.tmpdir"); + try { + copyResourceToTmpDir("xerces-c/dependencies.xml", + "dependencies.xml"); + DependencyTable dependencies = new DependencyTable(new File(tmpDir)); + dependencies.load(); + } finally { + deleteTmpFile("dependencies.xml"); + } + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java b/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java new file mode 100644 index 0000000..994b068 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java @@ -0,0 +1,374 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package net.sf.antcontrib.cpptasks; + +import java.io.File; +import java.io.IOException; +import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration; +import net.sf.antcontrib.cpptasks.compiler.Linker; +import net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker; +import net.sf.antcontrib.cpptasks.gcc.GccLinker; +import net.sf.antcontrib.cpptasks.types.FlexLong; +import net.sf.antcontrib.cpptasks.types.LibrarySet; +import net.sf.antcontrib.cpptasks.types.LinkerArgument; +import net.sf.antcontrib.cpptasks.types.SystemLibrarySet; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.types.FlexInteger; +import org.apache.tools.ant.types.Reference; + +/** + * Tests for LinkerDef class. + */ +public final class TestLinkerDef + extends TestProcessorDef { + /** + * Constructor. + * + * @param name + * test name + */ + public TestLinkerDef(final String name) { + super(name); + } + + /** + * Creates a processor. + * + * @return new linker + */ + protected ProcessorDef create() { + return new LinkerDef(); + } + + /** + * Test if setting the classname attribute to the name of the GCC linker + * results in the singleton GCC linker. + */ + public void testGetGcc() { + LinkerDef linkerDef = (LinkerDef) create(); + linkerDef.setClassname("net.sf.antcontrib.cpptasks.gcc.GccLinker"); + Linker comp = (Linker) linkerDef.getProcessor(); + assertNotNull(comp); + assertSame(GccLinker.getInstance(), comp); + } + + /** + * Test if setting the classname attribute to the name of the MSVC linker + * results in the singleton MSVC linker. + */ + public void testGetMSVC() { + LinkerDef linkerDef = (LinkerDef) create(); + linkerDef + .setClassname("net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker"); + Linker comp = (Linker) linkerDef.getProcessor(); + assertNotNull(comp); + assertSame(DevStudioLinker.getInstance(), comp); + } + + /** + * Tests if setting the classname attribute to an bogus classname results in + * a BuildException. + * + */ + public void testUnknownClass() { + LinkerDef linkerDef = (LinkerDef) create(); + try { + linkerDef + .setClassname("net.sf.antcontrib.cpptasks.bogus.BogusLinker"); + } catch (BuildException ex) { + return; + } + fail("should have thrown exception"); + } + + /** + * Tests if setting the classname to the name of a class that doesn't + * support Linker throws a BuildException. + * + */ + public void testWrongType() { + LinkerDef linkerDef = (LinkerDef) create(); + try { + linkerDef.setClassname("net.sf.antcontrib.cpptasks.CCTask"); + } catch (ClassCastException ex) { + return; + } + fail("should have thrown exception"); + } + + /** + * Gets the command line arguments that appear before the filenames. + * + * @param processor processor under test + * @return command line arguments + */ + protected String[] getPreArguments(final ProcessorDef processor) { + return ((CommandLineLinkerConfiguration) getConfiguration(processor)) + .getPreArguments(); + } + + /** + * Sets the name attribute. + * + * @param linker + * linker defintion + * @param name + * linker name + */ + private static void setLinkerName(final LinkerDef linker, + final String name) { + LinkerEnum linkerName = new LinkerEnum(); + linkerName.setValue(name); + linker.setName(linkerName); + } + + /** + * Tests that linkerarg's that appear in the base linker are effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsLinkerArgs() { + LinkerDef baseLinker = new LinkerDef(); + LinkerArgument linkerArg = new LinkerArgument(); + linkerArg.setValue("/base"); + baseLinker.addConfiguredLinkerArg(linkerArg); + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + String[] preArgs = getPreArguments(extendedLinker); + assertEquals(1, preArgs.length); + assertEquals("/base", preArgs[0]); + } + + /** + * Verify linkerarg's that appear in the base linker are effective when + * creating the command line for a linker that extends it, even if the + * linker is brought in through a reference. + */ + public void testExtendsLinkerArgsViaReference() { + Project project = new Project(); + LinkerDef baseLinker = new LinkerDef(); + baseLinker.setProject(project); + baseLinker.setId("base"); + project.addReference("base", baseLinker); + LinkerArgument linkerArg = new LinkerArgument(); + linkerArg.setValue("/base"); + baseLinker.addConfiguredLinkerArg(linkerArg); + + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + extendedLinker.setProject(project); + extendedLinker.setId("extended"); + project.addReference("extended", extendedLinker); + + LinkerDef linkerRef = new LinkerDef(); + linkerRef.setProject(project); + linkerRef.setRefid(new Reference(project, "extended")); + String[] preArgs = getPreArguments(linkerRef); + assertEquals(1, preArgs.length); + assertEquals("/base", preArgs[0]); + } + + /** + * Tests that fileset's that appear in the base linker are effective when + * creating the command line for a linker that extends it. + * @throws IOException if unable to create or delete temporary file + */ + public void testExtendsFileSet() throws IOException { + super.testExtendsFileSet(File.createTempFile("cpptaskstest", ".o")); + } + + /** + * Tests that libset's that appear in the base linker are effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsLibSet() { + LinkerDef baseLinker = new LinkerDef(); + LibrarySet libset = new LibrarySet(); + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + libset.setProject(baseLinker.getProject()); + CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("advapi32"); + libset.setLibs(libs); + baseLinker.addLibset(libset); + CommandLineLinkerConfiguration config = (CommandLineLinkerConfiguration) + getConfiguration(extendedLinker); + String[] libnames = config.getLibraryNames(); + assertEquals(1, libnames.length); + assertEquals("advapi32", libnames[0]); + } + + /** + * Tests that syslibset's that appear in the base linker are effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsSysLibSet() { + LinkerDef baseLinker = new LinkerDef(); + SystemLibrarySet libset = new SystemLibrarySet(); + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + libset.setProject(baseLinker.getProject()); + CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("advapi32"); + libset.setLibs(libs); + baseLinker.addSyslibset(libset); + CommandLineLinkerConfiguration config = (CommandLineLinkerConfiguration) + getConfiguration(extendedLinker); + String[] libnames = config.getLibraryNames(); + assertEquals(1, libnames.length); + assertEquals("advapi32", libnames[0]); + } + + /** + * Tests that the base attribute in the base linker is effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsBase() { + LinkerDef baseLinker = new LinkerDef(); + baseLinker.setBase(new FlexLong("10000")); + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + setLinkerName(extendedLinker, "msvc"); + String[] preArgs = getPreArguments(extendedLinker); + assertEquals("/NOLOGO", preArgs[0]); + assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + assertEquals("/INCREMENTAL:NO", preArgs[2]); + assertEquals("/BASE:0x2710", preArgs[3]); + } + + /** + * Tests that the stack attribute in the base linker is effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsStack() { + LinkerDef baseLinker = new LinkerDef(); + baseLinker.setStack(new FlexInteger("10000")); + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + setLinkerName(extendedLinker, "msvc"); + String[] preArgs = getPreArguments(extendedLinker); + assertEquals("/NOLOGO", preArgs[0]); + assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + assertEquals("/INCREMENTAL:NO", preArgs[2]); + assertEquals("/STACK:0x2710", preArgs[3]); + } + + /** + * Tests that the entry attribute in the base linker is effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsEntry() { + LinkerDef baseLinker = new LinkerDef(); + baseLinker.setEntry("foo"); + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + String[] preArgs = getPreArguments(extendedLinker); + assertEquals("-e", preArgs[0]); + assertEquals("foo", preArgs[1]); + } + + /** + * Tests that the fixed attribute in the base linker is effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsFixed() { + LinkerDef baseLinker = new LinkerDef(); + baseLinker.setFixed(true); + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + setLinkerName(extendedLinker, "msvc"); + String[] preArgs = getPreArguments(extendedLinker); + assertEquals("/NOLOGO", preArgs[0]); + assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + assertEquals("/INCREMENTAL:NO", preArgs[2]); + assertEquals("/FIXED", preArgs[3]); + } + + /** + * Tests that the incremental attribute in the base linker is effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsIncremental() { + LinkerDef baseLinker = new LinkerDef(); + baseLinker.setIncremental(true); + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + setLinkerName(extendedLinker, "msvc"); + String[] preArgs = getPreArguments(extendedLinker); + assertEquals("/NOLOGO", preArgs[0]); + assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + assertEquals("/INCREMENTAL:YES", preArgs[2]); + } + + /** + * Tests that the map attribute in the base linker is effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsMap() { + LinkerDef baseLinker = new LinkerDef(); + baseLinker.setMap(true); + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + setLinkerName(extendedLinker, "msvc"); + String[] preArgs = getPreArguments(extendedLinker); + assertEquals("/NOLOGO", preArgs[0]); + assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + assertEquals("/INCREMENTAL:NO", preArgs[2]); + assertEquals("/MAP", preArgs[3]); + } + + /** + * Tests that the rebuild attribute in the base linker is effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsRebuild() { + testExtendsRebuild(new LinkerDef()); + } + + /** + * Tests that the name attribute in the base linker is effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsName() { + LinkerDef baseLinker = new LinkerDef(); + setLinkerName(baseLinker, "msvc"); + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + extendedLinker.setBase(new FlexLong("10000")); + String[] preArgs = getPreArguments(extendedLinker); + assertEquals("/NOLOGO", preArgs[0]); + assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + assertEquals("/INCREMENTAL:NO", preArgs[2]); + assertEquals("/BASE:0x2710", preArgs[3]); + } + + /** + * Tests that the classname attribute in the base linker is effective when + * creating the command line for a linker that extends it. + */ + public void testExtendsClassname() { + LinkerDef baseLinker = new LinkerDef(); + baseLinker + .setClassname("net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker"); + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + extendedLinker.setBase(new FlexLong("10000")); + String[] preArgs = getPreArguments(extendedLinker); + assertEquals("/NOLOGO", preArgs[0]); + assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + assertEquals("/INCREMENTAL:NO", preArgs[2]); + assertEquals("/BASE:0x2710", preArgs[3]); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerEnum.java b/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerEnum.java new file mode 100644 index 0000000..2726750 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerEnum.java @@ -0,0 +1,40 @@ +/* + * + * Copyright 2003-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks; +import junit.framework.TestCase; +/** + * + * Tests for LinkerEnum + * + * @author CurtA + */ +public class TestLinkerEnum extends TestCase { + /** + * @param name test case name + */ + public TestLinkerEnum(String name) { + super(name); + } + /** + * Test checks that enumeration contains value g++ + * + * See patch [ 676276 ] Enhanced support for Mac OS X + */ + public void testContainsValueGpp() { + assertTrue(new LinkerEnum().containsValue("g++")); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestOutputTypeEnum.java b/src/test/java/net/sf/antcontrib/cpptasks/TestOutputTypeEnum.java new file mode 100644 index 0000000..61bb2b7 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestOutputTypeEnum.java @@ -0,0 +1,39 @@ +/* + * + * Copyright 2003-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks; +import junit.framework.TestCase; +/** + * @author CurtA + */ +public class TestOutputTypeEnum extends TestCase { + /** + * Default constructor + * + * @see junit.framework.TestCase#TestCase(String) + */ + public TestOutputTypeEnum(String name) { + super(name); + } + /** + * Test checks that output type enum contains "plugin" + * + * See patch [ 676276 ] Enhanced support for Mac OS X + */ + public void testContainsValuePlugin() { + assertTrue(new OutputTypeEnum().containsValue("plugin")); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestProcessorDef.java b/src/test/java/net/sf/antcontrib/cpptasks/TestProcessorDef.java new file mode 100644 index 0000000..c4e2905 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestProcessorDef.java @@ -0,0 +1,278 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package net.sf.antcontrib.cpptasks; + +import java.io.File; +import java.io.IOException; +import junit.framework.TestCase; +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration; +import net.sf.antcontrib.cpptasks.types.ConditionalFileSet; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.types.Reference; + +/** + * Tests for ProcessorDef. + */ +public abstract class TestProcessorDef + extends TestCase { + + /** + * Constructor. + * + * @param name + * test name + */ + public TestProcessorDef(final String name) { + super(name); + } + + /** + * Creates a new processor definition. + * + * @return created processor definition + */ + protected abstract ProcessorDef create(); + + /** + * Tests that isActive returns true when "if" references a set property. + */ + public final void testIsActive2() { + ProcessorDef arg = create(); + Project project = new Project(); + project.setProperty("cond", ""); + arg.setProject(project); + arg.setIf("cond"); + assertTrue(arg.isActive()); + } + + /** + * Tests that isActive returns false when "if" references an unset property. + */ + public final void testIsActive3() { + ProcessorDef arg = create(); + arg.setProject(new Project()); + arg.setIf("cond"); + assertTrue(!arg.isActive()); + } + + /** + * Tests that evaluating isActive when "if" refernces a property with the + * value "false" throws an exception to warn of a suspicious value. + * + */ + public final void testIsActive4() { + ProcessorDef arg = create(); + Project project = new Project(); + project.setProperty("cond", "false"); + arg.setProject(project); + arg.setIf("cond"); + try { + boolean isActive = arg.isActive(); + } catch (BuildException ex) { + return; + } + fail("Should throw exception for suspicious value"); + } + + /** + * Tests that isActive returns false when "unless" references a set + * property. + */ + public final void testIsActive5() { + ProcessorDef arg = create(); + Project project = new Project(); + project.setProperty("cond", ""); + arg.setProject(project); + arg.setUnless("cond"); + assertTrue(!arg.isActive()); + } + + /** + * Tests that isActive returns true when "unless" references an unset + * property. + */ + public final void testIsActive6() { + ProcessorDef arg = create(); + arg.setProject(new Project()); + arg.setUnless("cond"); + assertTrue(arg.isActive()); + } + + /** + * Tests that evaluating isActive when "unless" references a property with + * the value "false" throws an exception to warn of a suspicious value. + * + */ + public final void testIsActive7() { + ProcessorDef arg = create(); + Project project = new Project(); + project.setProperty("cond", "false"); + arg.setProject(project); + arg.setUnless("cond"); + try { + boolean isActive = arg.isActive(); + } catch (BuildException ex) { + return; + } + fail("Should throw exception for suspicious value"); + } + + /** + * Tests if a processor is active when both "if" and "unless" are specified + * and the associated properties are set. + * + */ + public final void testIsActive8() { + ProcessorDef arg = create(); + Project project = new Project(); + project.setProperty("cond", ""); + arg.setProject(project); + arg.setIf("cond"); + arg.setUnless("cond"); + assertTrue(!arg.isActive()); + } + + /** + * Creates a processor initialized to be an extension of the base processor. + * + * @param baseProcessor + * base processor + * @return extending processor + */ + protected final ProcessorDef createExtendedProcessorDef( + final ProcessorDef baseProcessor) { + Project project = new Project(); + baseProcessor.setProject(project); + baseProcessor.setId("base"); + project.addReference("base", baseProcessor); + ProcessorDef extendedLinker = create(); + extendedLinker.setProject(project); + extendedLinker.setExtends(new Reference("base")); + return extendedLinker; + } + + /** + * Gets the processor configuration. + * + * @param extendedProcessor + * processor under test + * @return configuration + */ + protected final ProcessorConfiguration getConfiguration( + final ProcessorDef extendedProcessor) { + CCTask cctask = new CCTask(); + LinkType linkType = new LinkType(); + return extendedProcessor.createConfiguration(cctask, + linkType, + null, + null, + null); + } + + /** + * Gets command line arguments that precede filenames. + * + * @param processor + * processor under test + * @return array of command line parameters + */ + protected abstract String[] getPreArguments(final ProcessorDef processor); + + /** + * Tests that a fileset in the base processor is effective when evaluating + * the files included in an extending processor. + * + * @param tempFile + * temporary file + * @throws IOException + * if unable to delete file + */ + protected final void testExtendsFileSet(final File tempFile) throws + IOException { + ProcessorDef baseLinker = create(); + ConditionalFileSet fileSet = new ConditionalFileSet(); + ProcessorDef extendedLinker = createExtendedProcessorDef(baseLinker); + fileSet.setProject(baseLinker.getProject()); + fileSet.setDir(new File(tempFile.getParent())); + fileSet.setIncludes(tempFile.getName()); + baseLinker.addFileset(fileSet); + MockFileCollector collector = new MockFileCollector(); + extendedLinker.visitFiles(collector); + tempFile.delete(); + assertEquals(1, collector.size()); + } + + /** + * Tests that the if attribute in the base processor is effective when + * evaluating if an extending processor is active. + */ + public final void testExtendsIf() { + ProcessorDef baseLinker = create(); + baseLinker.setIf("bogus"); + ProcessorDef extendedLinker = createExtendedProcessorDef(baseLinker); + boolean isActive = extendedLinker.isActive(); + assertEquals(false, isActive); + baseLinker.getProject().setProperty("bogus", ""); + isActive = extendedLinker.isActive(); + assertEquals(true, isActive); + } + + /** + * Tests that the unless attribute in the base processor is effective when + * evaluating if an extending processor is active. + */ + public final void testExtendsUnless() { + ProcessorDef baseLinker = create(); + baseLinker.setUnless("bogus"); + ProcessorDef extendedLinker = createExtendedProcessorDef(baseLinker); + boolean isActive = extendedLinker.isActive(); + assertEquals(true, isActive); + baseLinker.getProject().setProperty("bogus", ""); + isActive = extendedLinker.isActive(); + assertEquals(false, isActive); + } + + /** + * Tests that the debug attribute in the base processor is effective when + * creating the command line for a processor that extends it. + */ + public final void testExtendsDebug() { + ProcessorDef baseLinker = create(); + baseLinker.setDebug(true); + ProcessorDef extendedLinker = createExtendedProcessorDef(baseLinker); + String[] preArgs = getPreArguments(extendedLinker); + assertEquals("-g", preArgs[preArgs.length - 1]); + } + + /** + * Tests that the rebuild attribute in the base processor is effective when + * creating the command line for a processor that extends it. + * + * @param baseProcessor + * processor under test + */ + protected final void testExtendsRebuild( + final ProcessorDef baseProcessor) { + baseProcessor.setRebuild(true); + ProcessorDef extendedLinker = createExtendedProcessorDef(baseProcessor); + ProcessorConfiguration config = getConfiguration(extendedLinker); + boolean rebuild = config.getRebuild(); + assertEquals(true, rebuild); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java b/src/test/java/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java new file mode 100644 index 0000000..b105eb6 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java @@ -0,0 +1,141 @@ +/* + * + * Copyright 2003-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration; +import net.sf.antcontrib.cpptasks.VersionInfo; +/** + * Tests for TargetHistoryTable + * + * @author CurtA + */ +public class TestTargetHistoryTable extends TestXMLConsumer { + public static class MockProcessorConfiguration + implements + ProcessorConfiguration { + public MockProcessorConfiguration() { + } + public int bid(String fileName) { + return 100; + } + public String getIdentifier() { + return "Mock Configuration"; + } + public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) { + return new String[] { baseName }; + } + public ProcessorParam[] getParams() { + return new ProcessorParam[0]; + } + public boolean getRebuild() { + return false; + } + } + /** + * Constructor + * + * @param name + * test case name + * @see junit.framework.TestCase#TestCase(String) + */ + public TestTargetHistoryTable(String name) { + super(name); + } + /** + * Tests loading a stock history file + * + * @throws IOException + */ + public void testLoadOpenshore() throws IOException { + try { + copyResourceToTmpDir("openshore/history.xml", "history.xml"); + CCTask task = new CCTask(); + String tmpDir = System.getProperty("java.io.tmpdir"); + TargetHistoryTable history = new TargetHistoryTable(task, new File( + tmpDir)); + } finally { + deleteTmpFile("history.xml"); + } + } + /** + * Tests loading a stock history file + * + * @throws IOException + */ + public void testLoadXerces() throws IOException { + try { + copyResourceToTmpDir("xerces-c/history.xml", "history.xml"); + CCTask task = new CCTask(); + String tmpDir = System.getProperty("java.io.tmpdir"); + TargetHistoryTable history = new TargetHistoryTable(task, new File( + tmpDir)); + } finally { + deleteTmpFile("history.xml"); + } + } + /** + * Tests for bug fixed by patch [ 650397 ] Fix: Needless rebuilds on Unix + * + * @throws IOException + */ + public void testUpdateTimeResolution() throws IOException { + File compiledFile = null; + try { + // + // delete any history file that might exist + // in the test output directory + String tempDir = System.getProperty("java.io.tmpdir"); + File historyFile = new File(tempDir, "history.xml"); + if (historyFile.exists()) { + historyFile.delete(); + } + TargetHistoryTable table = new TargetHistoryTable(null, new File( + tempDir)); + // + // create a dummy compiled unit + // + compiledFile = new File(tempDir, "dummy.o"); + FileOutputStream compiledStream = new FileOutputStream(compiledFile); + compiledStream.close(); + // + // lastModified times can be slightly less than + // task start time due to file system resolution. + // Mimic this by slightly incrementing the last modification time. + // + long startTime = compiledFile.lastModified() + 1; + // + // update the table + // + table.update(new MockProcessorConfiguration(), + new String[]{"dummy.o"}, null); + // + // commit. If "compiled" file was judged to be + // valid we should have a history file. + // + table.commit(); + assertTrue("History file was not created", historyFile.exists()); + assertTrue("History file was empty", historyFile.length() > 10); + } finally { + if (compiledFile != null && compiledFile.exists()) { + compiledFile.delete(); + } + } + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestTargetInfo.java b/src/test/java/net/sf/antcontrib/cpptasks/TestTargetInfo.java new file mode 100644 index 0000000..5851805 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestTargetInfo.java @@ -0,0 +1,134 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks; +import java.io.File; +import junit.framework.TestCase; +import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration; +import net.sf.antcontrib.cpptasks.compiler.ProgressMonitor; +import org.apache.tools.ant.BuildException; +import net.sf.antcontrib.cpptasks.VersionInfo; + + +/** + * A description of a file built or to be built + */ +public class TestTargetInfo extends TestCase { + private class DummyConfiguration implements CompilerConfiguration { + public int bid(String filename) { + return 1; + } + public void close() { + } + public void compile(CCTask task, File workingDir, String[] source, + boolean relentless, ProgressMonitor monitor) + throws BuildException { + throw new BuildException("Not implemented"); + } + public CompilerConfiguration[] createPrecompileConfigurations( + File file, String[] exceptFiles) { + return null; + } + public String getIdentifier() { + return "dummy"; + } + public String[] getIncludeDirectories() { + return new String[0]; + } + public String getIncludePathIdentifier() { + return "dummyIncludePath"; + } + public String[] getOutputFileNames(String inputFile, VersionInfo versionInfo) { + return new String[0]; + } + public CompilerParam getParam(String name) { + return null; + } + public ProcessorParam[] getParams() { + return new ProcessorParam[0]; + } + public boolean getRebuild() { + return false; + } + public boolean isPrecompileGeneration() { + return true; + } + public DependencyInfo parseIncludes(CCTask task, File baseDir, File file) { + return null; + } + } + public TestTargetInfo(String name) { + super(name); + } + public void testConstructorNullConfig() { + try { + new TargetInfo(null, new File[]{new File("")}, null, new File(""), + false); + fail("Didn't throw exception"); + } catch (NullPointerException ex) { + } + } + public void testConstructorNullOutput() { + CompilerConfiguration config = new DummyConfiguration(); + try { + new TargetInfo(config, new File[]{new File("")}, null, null, false); + fail("Didn't throw exception"); + } catch (NullPointerException ex) { + } + } + public void testConstructorNullSource() { + CompilerConfiguration config = new DummyConfiguration(); + try { + new TargetInfo(config, null, null, new File(""), false); + fail("Didn't throw exception"); + } catch (NullPointerException ex) { + } + } + public void testGetRebuild() { + CompilerConfiguration config = new DummyConfiguration(); + TargetInfo targetInfo = new TargetInfo(config, new File[]{new File( + "FoO.BaR")}, null, new File("foo.o"), false); + assertEquals(false, targetInfo.getRebuild()); + targetInfo = new TargetInfo(config, new File[]{new File("FoO.BaR")}, + null, new File("foo.o"), true); + assertEquals(true, targetInfo.getRebuild()); + } + public void testGetSource() { + CompilerConfiguration config = new DummyConfiguration(); + TargetInfo targetInfo = new TargetInfo(config, new File[]{new File( + "FoO.BaR")}, null, new File("foo.o"), false); + String source = targetInfo.getSources()[0].getName(); + assertEquals(source, "FoO.BaR"); + } + public void testHasSameSource() { + CompilerConfiguration config = new DummyConfiguration(); + TargetInfo targetInfo = new TargetInfo(config, new File[]{new File( + "foo.bar")}, null, new File("foo.o"), false); + boolean hasSame = targetInfo.getSources()[0] + .equals(new File("foo.bar")); + assertTrue(hasSame); + hasSame = targetInfo.getSources()[0].equals(new File("boo.far")); + assertEquals(hasSame, false); + } + public void testMustRebuild() { + CompilerConfiguration config = new DummyConfiguration(); + TargetInfo targetInfo = new TargetInfo(config, new File[]{new File( + "FoO.BaR")}, null, new File("foo.o"), false); + assertEquals(false, targetInfo.getRebuild()); + targetInfo.mustRebuild(); + assertEquals(true, targetInfo.getRebuild()); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestXMLConsumer.java b/src/test/java/net/sf/antcontrib/cpptasks/TestXMLConsumer.java new file mode 100644 index 0000000..5e7b007 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestXMLConsumer.java @@ -0,0 +1,96 @@ +/* + * + * Copyright 2003-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import junit.framework.TestCase; +/** + * Base class for tests on classes that consume or public XML documents. + * + * @author Curt Arnold + * + */ +public abstract class TestXMLConsumer extends TestCase { + /** + * copies a resource to a temporary directory. + * + * @param resourceName + * resouce name, such as "files/openshore/history.xml". + * @param tmpFile name for temporary file created in /tmp or similar. + */ + public static final void copyResourceToTmpDir(String resourceName, + String tmpFile) throws IOException { + String tmpDir = System.getProperty("java.io.tmpdir"); + // + // attempt to get resource from jar + // (should succeed unless testing in IDE) + InputStream src = null; + if (TestTargetHistoryTable.class.getClassLoader().getResource( + resourceName) != null) { + src = TestTargetHistoryTable.class.getClassLoader() + .getResourceAsStream(resourceName); + } + // + // if not found, try to find it relative to the current directory + // + if (src == null) { + src = new FileInputStream(resourceName); + } + assertNotNull("Could not locate resource " + resourceName, src); + try { + File destFile = new File(tmpDir, tmpFile); + FileOutputStream dest = new FileOutputStream(destFile); + try { + int bytesRead = 0; + byte[] buffer = new byte[4096]; + do { + bytesRead = src.read(buffer); + if (bytesRead > 0) { + dest.write(buffer, 0, bytesRead); + } + } while (bytesRead == buffer.length); + } finally { + dest.close(); + } + } finally { + src.close(); + } + } + /** + * Deletes a file, if it exists, from the user's temporary directory. + * + * @param tmpName + * file name, may not be null + */ + public static void deleteTmpFile(String tmpName) throws IOException { + String tmpDir = System.getProperty("java.io.tmpdir"); + File tmpFile = new File(tmpDir, tmpName); + if (tmpFile.exists()) { + tmpFile.delete(); + } + } + /** + * @param testName + */ + protected TestXMLConsumer(final String testName) { + super(testName); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/borland/TestBorlandCCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/borland/TestBorlandCCompiler.java new file mode 100644 index 0000000..ddafc5e --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/borland/TestBorlandCCompiler.java @@ -0,0 +1,37 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.borland; +import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; +import net.sf.antcontrib.cpptasks.compiler.TestAbstractCompiler; +/** + * Borland C++ Compiler adapter tests + * + * Override create to test concrete compiler implementions + */ +public class TestBorlandCCompiler extends TestAbstractCompiler { + public TestBorlandCCompiler(String name) { + super(name); + } + protected AbstractProcessor create() { + return BorlandCCompiler.getInstance(); + } + protected String getObjectExtension() { + return ".obj"; + } + public void testGetIdentfier() { + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java new file mode 100644 index 0000000..5a1e66b --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java @@ -0,0 +1,85 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.compiler; +import java.io.File; + +import net.sf.antcontrib.cpptasks.CCTask; +import net.sf.antcontrib.cpptasks.CompilerDef; +import net.sf.antcontrib.cpptasks.ProcessorDef; +import net.sf.antcontrib.cpptasks.parser.CParser; +import net.sf.antcontrib.cpptasks.parser.Parser; +import net.sf.antcontrib.cpptasks.VersionInfo; + +import org.apache.tools.ant.BuildException; +/** + * Test for abstract compiler class + * + * Override create to test concrete compiler implementions + */ +public class TestAbstractCompiler extends TestAbstractProcessor { + private class DummyAbstractCompiler extends AbstractCompiler { + public DummyAbstractCompiler() { + super(new String[]{".cpp", ".c"}, + new String[]{".hpp", ".h", ".inl"}, ".o"); + } + public void compile(CCTask task, File[] srcfile, File[] outputfile, + CompilerConfiguration config) throws BuildException { + throw new BuildException("Not implemented"); + } + public CompilerConfiguration createConfiguration(CCTask task, + LinkType linkType, ProcessorDef[] def1, CompilerDef def2, + net.sf.antcontrib.cpptasks.TargetDef targetPlatform, + VersionInfo versionInfo) { + return null; + } + public Parser createParser(File file) { + return new CParser(); + } + public String getIdentifier() { + return "dummy"; + } + public Linker getLinker(LinkType type) { + return null; + } + } + public TestAbstractCompiler(String name) { + super(name); + } + protected AbstractProcessor create() { + return new DummyAbstractCompiler(); + } + protected String getObjectExtension() { + return ".o"; + } + public void testCanParseTlb() { + AbstractCompiler compiler = (AbstractCompiler) create(); + assertEquals(false, compiler.canParse(new File("sample.tlb"))); + } + public void testGetOutputFileName1() { + AbstractProcessor compiler = create(); + String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.c", null); + assertEquals("hello" + getObjectExtension(), output[0]); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.c", null); + assertEquals("hello" + getObjectExtension(), output[0]); + output = compiler.getOutputFileNames("hello.c", null); + assertEquals("hello" + getObjectExtension(), output[0]); + output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h", null); + assertEquals(0, output.length); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.h", null); + assertEquals(0, output.length); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java new file mode 100644 index 0000000..b444a0a --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java @@ -0,0 +1,89 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.compiler; +import java.io.File; + +import net.sf.antcontrib.cpptasks.CCTask; +import net.sf.antcontrib.cpptasks.LinkerDef; +import net.sf.antcontrib.cpptasks.ProcessorDef; +import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; +import net.sf.antcontrib.cpptasks.TargetDef; +import net.sf.antcontrib.cpptasks.VersionInfo; + +/** + * Test for abstract compiler class + * + * Override create to test concrete compiler implementions + */ +public class TestAbstractLinker extends TestAbstractProcessor { + private class DummyAbstractLinker extends AbstractLinker { + public DummyAbstractLinker() { + super(new String[]{".obj", ".lib"}, new String[]{".map", ".exp"}); + } + public LinkerConfiguration createConfiguration(final CCTask task, + final LinkType linkType, + final ProcessorDef[] def1, + final LinkerDef def2, + final TargetDef targetPlatform, + final VersionInfo versionInfo) { + return null; + } + public String getIdentifier() { + return "dummy"; + } + public File[] getLibraryPath() { + return new File[0]; + } + public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) { + return libnames; + } + public Linker getLinker(LinkType type) { + return null; + } + public String[] getOutputFileNames(String sourceFile, VersionInfo versionInfo) { + return new String[0]; + } + public String[][] getRuntimeLibraries(boolean debug, + boolean multithreaded, boolean staticLink) { + return new String[2][0]; + } + public boolean isCaseSensitive() { + return true; + } + } + public TestAbstractLinker(String name) { + super(name); + } + protected AbstractProcessor create() { + return new DummyAbstractLinker(); + } + public void testBid() { + AbstractProcessor compiler = create(); + int bid = compiler.bid("c:/foo\\bar\\hello.obj"); + assertEquals(100, bid); + bid = compiler.bid("c:/foo\\bar/hello.lib"); + assertEquals(100, bid); + bid = compiler.bid("c:/foo\\bar\\hello.map"); + assertEquals(0, bid); + bid = compiler.bid("c:/foo\\bar/hello.map"); + assertEquals(0, bid); + bid = compiler.bid("c:/foo\\bar/hello.c"); + assertEquals(1, bid); + bid = compiler.bid("c:/foo\\bar/hello.cpp"); + assertEquals(1, bid); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java new file mode 100644 index 0000000..f2c04a3 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java @@ -0,0 +1,80 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.compiler; +import junit.framework.TestCase; +import net.sf.antcontrib.cpptasks.CCTask; +import net.sf.antcontrib.cpptasks.ProcessorDef; +import net.sf.antcontrib.cpptasks.VersionInfo; +/** + * Test for abstract compiler class + * + * Override create to test concrete compiler implementions + */ +public class TestAbstractProcessor extends TestCase { + private class DummyAbstractProcessor extends AbstractProcessor { + public DummyAbstractProcessor() { + super(new String[]{".cpp", ".c"}, + new String[]{".hpp", ".h", ".inl"}); + } + public ProcessorConfiguration createConfiguration(CCTask task, + LinkType linkType, ProcessorDef[] defaultProvider, + ProcessorDef specificProvider, + net.sf.antcontrib.cpptasks.TargetDef targetPlatform, + VersionInfo versionInfo) { + return null; + } + public String getIdentifier() { + return "dummy"; + } + public Linker getLinker(LinkType type) { + return null; + } + public String[] getOutputFileNames(String sourceFile, VersionInfo versionInfo) { + return new String[0]; + } + public String[][] getRuntimeLibraries(boolean debug, + boolean multithreaded, boolean staticLink) { + return new String[2][0]; + } + } + public TestAbstractProcessor(String name) { + super(name); + } + protected AbstractProcessor create() { + return new DummyAbstractProcessor(); + } + public void testBid() { + AbstractProcessor compiler = create(); + int bid = compiler.bid("c:/foo\\bar\\hello.c"); + assertEquals(100, bid); + bid = compiler.bid("c:/foo\\bar/hello.c"); + assertEquals(100, bid); + bid = compiler.bid("c:/foo\\bar\\hello.h"); + assertEquals(1, bid); + bid = compiler.bid("c:/foo\\bar/hello.h"); + assertEquals(1, bid); + bid = compiler.bid("c:/foo\\bar/hello.pas"); + assertEquals(0, bid); + bid = compiler.bid("c:/foo\\bar/hello.java"); + assertEquals(0, bid); + } + public void testGetIdentfier() { + AbstractProcessor compiler = create(); + String id = compiler.getIdentifier(); + assertEquals("dummy", id); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestCommandLineCompilerConfiguration.java b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestCommandLineCompilerConfiguration.java new file mode 100644 index 0000000..a22fa0d --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestCommandLineCompilerConfiguration.java @@ -0,0 +1,59 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.compiler; +import java.io.File; + +import net.sf.antcontrib.cpptasks.ProcessorParam; +import net.sf.antcontrib.cpptasks.gcc.GccCCompiler; +/** + */ +public class TestCommandLineCompilerConfiguration + extends + TestCompilerConfiguration { + private final CommandLineCompiler compiler; + private final String compilerId; + public TestCommandLineCompilerConfiguration(String name) { + super(name); + compiler = (GccCCompiler) GccCCompiler.getInstance(); + compilerId = compiler.getIdentifier(); + } + protected CompilerConfiguration create() { + return new CommandLineCompilerConfiguration(compiler, "dummy", + new File[0], new File[0], new File[0], "", + new String[]{"/Id:/gcc"}, new ProcessorParam[0], false, + new String[0]); + } + public void testConstructorNullCompiler() { + try { + new CommandLineCompilerConfiguration(null, "dummy", new File[0], + new File[0], new File[0], "", new String[0], + new ProcessorParam[0], false, new String[0]); + fail("Should throw exception for null compiler"); + } catch (NullPointerException ex) { + } + } + public void testGetIdentifier() { + CompilerConfiguration config = create(); + String id = config.getIdentifier(); + assertEquals("dummy", id); + } + public void testToString() { + CompilerConfiguration config = create(); + String toString = config.toString(); + assertEquals("dummy", toString); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java new file mode 100644 index 0000000..a928ae4 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java @@ -0,0 +1,68 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.compiler; +import junit.framework.TestCase; +/** + */ +public abstract class TestCompilerConfiguration extends TestCase { + public TestCompilerConfiguration(String name) { + super(name); + } + protected abstract CompilerConfiguration create(); + public String getObjectFileExtension() { + return ".o"; + } + public void testBid() { + CompilerConfiguration compiler = create(); + int bid = compiler.bid("c:/foo\\bar\\hello.c"); + assertEquals(100, bid); + bid = compiler.bid("c:/foo\\bar/hello.c"); + assertEquals(100, bid); + bid = compiler.bid("c:/foo\\bar\\hello.h"); + assertEquals(1, bid); + bid = compiler.bid("c:/foo\\bar/hello.h"); + assertEquals(1, bid); + bid = compiler.bid("c:/foo\\bar/hello.pas"); + assertEquals(0, bid); + bid = compiler.bid("c:/foo\\bar/hello.java"); + assertEquals(0, bid); + } + public void testGetOutputFileName1() { + CompilerConfiguration compiler = create(); + String input = "c:/foo\\bar\\hello.c"; + // + // may cause IllegalStateException since + // setPlatformInfo has not been called + try { + String[] output = compiler.getOutputFileNames(input, null); + } catch (java.lang.IllegalStateException ex) { + } + } + public void testGetOutputFileName2() { + CompilerConfiguration compiler = create(); + String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.c", null); + assertEquals("hello" + getObjectFileExtension(), output[0]); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.c", null); + assertEquals("hello" + getObjectFileExtension(), output[0]); + output = compiler.getOutputFileNames("hello.c", null); + assertEquals("hello" + getObjectFileExtension(), output[0]); + output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h", null); + assertEquals(0, output.length); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.h", null); + assertEquals(0, output.length); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestLinkType.java b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestLinkType.java new file mode 100644 index 0000000..a7e3a45 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/compiler/TestLinkType.java @@ -0,0 +1,59 @@ +/* + * + * Copyright 2003-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.compiler; +import junit.framework.TestCase; +import net.sf.antcontrib.cpptasks.OutputTypeEnum; +/** + * Tests for LinkType + * + * @author CurtA + */ +public class TestLinkType extends TestCase { + /** + * Constructor + * + * @param name + * test case name + */ + public TestLinkType(String name) { + super(name); + } + /** + * Tests if isPluginModule returns true when set to plugin output type + * + * See patch [ 676276 ] Enhanced support for Mac OS X + */ + public void testIsPluginFalse() { + LinkType type = new LinkType(); + OutputTypeEnum pluginType = new OutputTypeEnum(); + pluginType.setValue("executable"); + type.setOutputType(pluginType); + assertTrue(!type.isPluginModule()); + } + /** + * Tests if isPluginModule returns true when set to plugin output type + * + * See patch [ 676276 ] Enhanced support for Mac OS X + */ + public void testIsPluginTrue() { + LinkType type = new LinkType(); + OutputTypeEnum pluginType = new OutputTypeEnum(); + pluginType.setValue("plugin"); + type.setOutputType(pluginType); + assertTrue(type.isPluginModule()); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudio2005CCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudio2005CCompiler.java new file mode 100644 index 0000000..dccb986 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudio2005CCompiler.java @@ -0,0 +1,41 @@ +/* + * + * Copyright 2002-2007 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.devstudio; +import java.util.Vector; + +import junit.framework.TestCase; + +import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; +/** + * Test Microsoft C/C++ compiler adapter + * + */ +public class TestDevStudio2005CCompiler extends TestCase { + public TestDevStudio2005CCompiler(String name) { + super(name); + } + public void testDebug() { + DevStudio2005CCompiler compiler = DevStudio2005CCompiler.getInstance(); + Vector args = new Vector(); + compiler.addDebugSwitch(args); + assertEquals(4, args.size()); + assertEquals("/Zi", args.elementAt(0)); + assertEquals("/Od", args.elementAt(1)); + assertEquals("/RTC1", args.elementAt(2)); + assertEquals("/D_DEBUG", args.elementAt(3)); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioCCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioCCompiler.java new file mode 100644 index 0000000..eeeec14 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioCCompiler.java @@ -0,0 +1,41 @@ +/* + * + * Copyright 2002-2007 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.devstudio; +import java.util.Vector; + +import junit.framework.TestCase; + +import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; +/** + * Test Microsoft C/C++ compiler adapter + * + */ +public class TestDevStudioCCompiler extends TestCase { + public TestDevStudioCCompiler(String name) { + super(name); + } + public void testDebug() { + DevStudioCCompiler compiler = DevStudioCCompiler.getInstance(); + Vector args = new Vector(); + compiler.addDebugSwitch(args); + assertEquals(4, args.size()); + assertEquals("/Zi", args.elementAt(0)); + assertEquals("/Od", args.elementAt(1)); + assertEquals("/GZ", args.elementAt(2)); + assertEquals("/D_DEBUG", args.elementAt(3)); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioLinker.java b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioLinker.java new file mode 100644 index 0000000..7fdaabe --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioLinker.java @@ -0,0 +1,44 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.devstudio; +import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; +import net.sf.antcontrib.cpptasks.compiler.TestAbstractLinker; +import org.apache.tools.ant.taskdefs.condition.Os; +/** + * Test for Microsoft Developer Studio linker + * + * Override create to test concrete compiler implementions + */ +public class TestDevStudioLinker extends TestAbstractLinker { + public TestDevStudioLinker(String name) { + super(name); + } + protected AbstractProcessor create() { + return DevStudioLinker.getInstance(); + } + public void testGetIdentfier() { + if (!Os.isFamily("windows")) { + return; + } + AbstractProcessor compiler = create(); + String id = compiler.getIdentifier(); + boolean hasMSLinker = ((id.indexOf("Microsoft") >= 0) && (id + .indexOf("Linker") >= 0)) + || id.indexOf("link") >= 0; + assertTrue(hasMSLinker); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudioLinker.java b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudioLinker.java new file mode 100644 index 0000000..07f1339 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudioLinker.java @@ -0,0 +1,60 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.devstudio; + +import java.io.File; + + +/** + * Test for Microsoft Developer Studio linker + * + * Override create to test concrete compiler implementions + */ +public class TestInstalledDevStudioLinker extends TestDevStudioLinker +{ + public TestInstalledDevStudioLinker(String name) { + super(name); + } + + public void testGetLibraryPath() { + File[] libpath = DevStudioLinker.getInstance().getLibraryPath(); + // + // unless you tweak the library path + // it should have more thean three entries + assertTrue(libpath.length >= 2); + // + // check if these files can be found + // + String[] libnames = new String[] { "kernel32.lib", + "advapi32.lib", "msvcrt.lib", "mfc42.lib", "mfc70.lib" }; + boolean[] libfound = new boolean[libnames.length]; + for (int i = 0; i < libpath.length; i++) { + for (int j = 0; j < libnames.length; j++) { + File libfile = new File(libpath[i], libnames[j]); + if (libfile.exists()) { + libfound[j] = true; + } + } + } + assertTrue("kernel32 not found", libfound[0]); + assertTrue("advapi32 not found", libfound[1]); + assertTrue("msvcrt not found", libfound[2]); + if(!(libfound[3] || libfound[4])) { + fail("mfc42.lib or mfc70.lib not found"); + } + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java new file mode 100644 index 0000000..0fc8449 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java @@ -0,0 +1,79 @@ +/* + * + * Copyright 2003-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.gcc; +import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; +import net.sf.antcontrib.cpptasks.compiler.TestAbstractLinker; +/** + * Tests for classes that derive from AbstractArLibrarian + * + * @author CurtA + */ +public class TestAbstractArLibrarian extends TestAbstractLinker { + /** + * Constructor + * + * @param name + * test name + * @see junit.framework.TestCase#TestCase(String) + */ + public TestAbstractArLibrarian(String name) { + super(name); + } + /** + * Creates item under test @returns item under test + * + * @see net.sf.antcontrib.cpptasks.compiler.TestAbstractProcessor#create() + */ + protected AbstractProcessor create() { + return GccLibrarian.getInstance(); + } + /** + * Override of + * + * @see net.sf.antcontrib.cpptasks.compiler.TestAbstractProcessor#testBid() + */ + public void testBid() { + AbstractProcessor compiler = create(); + int bid = compiler.bid("c:/foo\\bar\\hello.o"); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, bid); + } + public void testGetIdentfier() { + AbstractProcessor processor = create(); + String id = processor.getIdentifier(); + assertTrue(id.indexOf("ar") >= 0); + } + /** + * Tests for library patterns + * + * See patch [ 676276 ] Enhanced support for Mac OS X + */ + public void testGetLibraryPatterns() { + String[] libnames = new String[]{"foo"}; + String[] patterns = ((AbstractArLibrarian) create()) + .getLibraryPatterns(libnames, null); + assertEquals(0, patterns.length); + } + /** + * Tests output file for ar library + * + * See bug [ 687732 ] Filenames for gcc static library does start with lib + */ + public void testOutputFileName() { + String[] outputFiles = GccLibrarian.getInstance().getOutputFileNames("x", null); + assertEquals("libx.a", outputFiles[0]); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java new file mode 100644 index 0000000..63996c5 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java @@ -0,0 +1,247 @@ +/* + * + * Copyright 2003-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.gcc; +import java.io.File; +import java.util.Vector; + +import junit.framework.TestCase; +import net.sf.antcontrib.cpptasks.CCTask; +import net.sf.antcontrib.cpptasks.CUtil; +import net.sf.antcontrib.cpptasks.OutputTypeEnum; +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.types.LibrarySet; +import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; +/** + * Test ld linker adapter abstract base class + * + * Override create to test concrete compiler implementions + */ +public class TestAbstractLdLinker extends TestCase { + private final String realOSName; + public TestAbstractLdLinker(String name) { + super(name); + realOSName = System.getProperty("os.name"); + } + protected AbstractLdLinker getLinker() { + return GccLinker.getInstance(); + } + protected void tearDown() throws java.lang.Exception { + System.setProperty("os.name", realOSName); + } + /** + * Checks for proper arguments for plugin generation on Darwin + * + * See [ 676276 ] Enhanced support for Mac OS X + */ + public void testAddImpliedArgsDarwinPlugin() { + System.setProperty("os.name", "Mac OS X"); + AbstractLdLinker linker = getLinker(); + Vector args = new Vector(); + LinkType pluginType = new LinkType(); + OutputTypeEnum pluginOutType = new OutputTypeEnum(); + pluginOutType.setValue("plugin"); + pluginType.setOutputType(pluginOutType); + linker.addImpliedArgs(false, pluginType, args); + assertEquals(1, args.size()); + assertEquals("-bundle", args.elementAt(0)); + } + /** + * Checks for proper arguments for shared generation on Darwin + * + * See [ 676276 ] Enhanced support for Mac OS X + */ + public void testAddImpliedArgsDarwinShared() { + System.setProperty("os.name", "Mac OS X"); + AbstractLdLinker linker = getLinker(); + Vector args = new Vector(); + LinkType pluginType = new LinkType(); + OutputTypeEnum pluginOutType = new OutputTypeEnum(); + pluginOutType.setValue("shared"); + pluginType.setOutputType(pluginOutType); + linker.addImpliedArgs(false, pluginType, args); + assertEquals(2, args.size()); + assertEquals("-prebind", args.elementAt(0)); + assertEquals("-dynamiclib", args.elementAt(1)); + } + /** + * Checks for proper arguments for plugin generation on Darwin + * + * See [ 676276 ] Enhanced support for Mac OS X + */ + public void testAddImpliedArgsNonDarwinPlugin() { + System.setProperty("os.name", "VAX/VMS"); + AbstractLdLinker linker = getLinker(); + Vector args = new Vector(); + LinkType pluginType = new LinkType(); + OutputTypeEnum pluginOutType = new OutputTypeEnum(); + pluginOutType.setValue("plugin"); + pluginType.setOutputType(pluginOutType); + linker.addImpliedArgs(false, pluginType, args); + assertEquals(1, args.size()); + assertEquals("-shared", args.elementAt(0)); + } + /** + * Checks for proper arguments for shared generation on Darwin + * + * See [ 676276 ] Enhanced support for Mac OS X + */ + public void testAddImpliedArgsNonDarwinShared() { + System.setProperty("os.name", "VAX/VMS"); + AbstractLdLinker linker = getLinker(); + Vector args = new Vector(); + LinkType pluginType = new LinkType(); + OutputTypeEnum pluginOutType = new OutputTypeEnum(); + pluginOutType.setValue("shared"); + pluginType.setOutputType(pluginOutType); + linker.addImpliedArgs(false, pluginType, args); + assertEquals(1, args.size()); + assertEquals("-shared", args.elementAt(0)); + } + public void testAddLibrarySetDirSwitch() { + AbstractLdLinker linker = getLinker(); + CCTask task = new CCTask(); + LibrarySet[] sets = new LibrarySet[]{new LibrarySet()}; + /* throws an Exception in setLibs otherwise */ + sets[0].setProject(new org.apache.tools.ant.Project()); + sets[0].setDir(new File("/foo")); + sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart")); + Vector preargs = new Vector(); + Vector midargs = new Vector(); + Vector endargs = new Vector(); + String[] rc = linker.addLibrarySets(task, sets, preargs, midargs, + endargs); + String libdirSwitch = (String) endargs.elementAt(0); + assertEquals(libdirSwitch.substring(0, 2), "-L"); + // + // can't have space after -L or will break Mac OS X + // + assertTrue(!libdirSwitch.substring(2, 3).equals(" ")); + assertEquals(libdirSwitch.substring(libdirSwitch.length() - 3), "foo"); + } + public void testAddLibrarySetLibSwitch() { + AbstractLdLinker linker = getLinker(); + CCTask task = new CCTask(); + LibrarySet[] sets = new LibrarySet[]{new LibrarySet()}; + /* throws an Exception in setLibs otherwise */ + sets[0].setProject(new org.apache.tools.ant.Project()); + sets[0].setDir(new File("/foo")); + sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart")); + Vector preargs = new Vector(); + Vector midargs = new Vector(); + Vector endargs = new Vector(); + String[] rc = linker.addLibrarySets(task, sets, preargs, midargs, + endargs); + assertEquals("-lbart", (String) endargs.elementAt(1)); + assertEquals("-lcart", (String) endargs.elementAt(2)); + assertEquals("-ldart", (String) endargs.elementAt(3)); + assertEquals(endargs.size(), 4); + } + public void testAddLibrarySetLibFrameworkNonDarwin() { + System.setProperty("os.name", "VAX/VMS"); + AbstractLdLinker linker = getLinker(); + CCTask task = new CCTask(); + LibrarySet[] sets = new LibrarySet[]{new LibrarySet()}; + /* throws an Exception in setLibs otherwise */ + sets[0].setProject(new org.apache.tools.ant.Project()); + sets[0].setDir(new File("/foo")); + LibraryTypeEnum libType = new LibraryTypeEnum(); + libType.setValue("framework"); + sets[0].setType(libType); + sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart")); + Vector preargs = new Vector(); + Vector midargs = new Vector(); + Vector endargs = new Vector(); + String[] rc = linker.addLibrarySets(task, sets, preargs, midargs, + endargs); + assertEquals("-L", ((String) endargs.elementAt(0)).substring(0, 2)); + assertEquals("-Bdynamic", (String) endargs.elementAt(1)); + assertEquals("-lbart", (String) endargs.elementAt(2)); + assertEquals("-lcart", (String) endargs.elementAt(3)); + assertEquals("-ldart", (String) endargs.elementAt(4)); + assertEquals(endargs.size(), 5); + } + public void testAddLibrarySetLibFrameworkDarwin() { + System.setProperty("os.name", "Mac OS X"); + AbstractLdLinker linker = getLinker(); + CCTask task = new CCTask(); + LibrarySet[] sets = new LibrarySet[]{new LibrarySet()}; + /* throws an Exception in setLibs otherwise */ + sets[0].setProject(new org.apache.tools.ant.Project()); + sets[0].setDir(new File("/foo")); + LibraryTypeEnum libType = new LibraryTypeEnum(); + libType.setValue("framework"); + sets[0].setType(libType); + sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart")); + Vector preargs = new Vector(); + Vector midargs = new Vector(); + Vector endargs = new Vector(); + String[] rc = linker.addLibrarySets(task, sets, preargs, midargs, + endargs); + assertEquals("-F", ((String) endargs.elementAt(0)).substring(0, 2)); + assertEquals("-framework bart", (String) endargs.elementAt(1)); + assertEquals("-framework cart", (String) endargs.elementAt(2)); + assertEquals("-framework dart", (String) endargs.elementAt(3)); + assertEquals(endargs.size(), 4); + } + public void testAddLibraryStatic() { + AbstractLdLinker linker = getLinker(); + CCTask task = new CCTask(); + LibrarySet[] sets = new LibrarySet[]{ + new LibrarySet(), + new LibrarySet(), + new LibrarySet()}; + /* throws an Exception in setLibs otherwise */ + sets[0].setProject(new org.apache.tools.ant.Project()); + sets[0].setLibs(new CUtil.StringArrayBuilder("bart")); + sets[1].setProject(new org.apache.tools.ant.Project()); + sets[1].setLibs(new CUtil.StringArrayBuilder("cart")); + LibraryTypeEnum libType = new LibraryTypeEnum(); + libType.setValue("static"); + sets[1].setType(libType); + sets[2].setProject(new org.apache.tools.ant.Project()); + sets[2].setLibs(new CUtil.StringArrayBuilder("dart")); + Vector preargs = new Vector(); + Vector midargs = new Vector(); + Vector endargs = new Vector(); + String[] rc = linker.addLibrarySets(task, sets, preargs, midargs, + endargs); + assertEquals("-lbart", (String) endargs.elementAt(0)); + assertEquals("-Bstatic", (String) endargs.elementAt(1)); + assertEquals("-lcart", (String) endargs.elementAt(2)); + assertEquals("-Bdynamic", (String) endargs.elementAt(3)); + assertEquals("-ldart", (String) endargs.elementAt(4)); + assertEquals(endargs.size(), 5); + } + public void testLibReturnValue() { + AbstractLdLinker linker = getLinker(); + CCTask task = new CCTask(); + LibrarySet[] sets = new LibrarySet[]{new LibrarySet()}; + /* throws an Exception in setLibs otherwise */ + sets[0].setProject(new org.apache.tools.ant.Project()); + sets[0].setDir(new File("/foo")); + sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart")); + Vector preargs = new Vector(); + Vector midargs = new Vector(); + Vector endargs = new Vector(); + String[] rc = linker.addLibrarySets(task, sets, preargs, midargs, + endargs); + assertEquals(3, rc.length); + assertEquals("bart", rc[0]); + assertEquals("cart", rc[1]); + assertEquals("dart", rc[2]); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccCCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccCCompiler.java new file mode 100644 index 0000000..3abe409 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccCCompiler.java @@ -0,0 +1,80 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.gcc; +import java.io.File; + +import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; +import net.sf.antcontrib.cpptasks.parser.CParser; +import net.sf.antcontrib.cpptasks.parser.FortranParser; +import net.sf.antcontrib.cpptasks.parser.Parser; +/** + * Test gcc compiler adapter + * + */ +public class TestGccCCompiler extends TestGccCompatibleCCompiler { + public TestGccCCompiler(String name) { + super(name); + } + protected GccCompatibleCCompiler create() { + return GccCCompiler.getInstance(); + } + public void testBidObjectiveAssembly() { + GccCCompiler compiler = GccCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.s")); + } + public void testBidObjectiveC() { + GccCCompiler compiler = GccCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.m")); + } + public void testBidObjectiveCpp() { + GccCCompiler compiler = GccCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.mm")); + } + public void testBidPreprocessedCpp() { + GccCCompiler compiler = GccCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.ii")); + } + public void testCreateCParser1() { + Parser parser = GccCCompiler.getInstance().createParser( + new File("foo.c")); + assertTrue(parser instanceof CParser); + } + public void testCreateCParser2() { + Parser parser = GccCCompiler.getInstance().createParser( + new File("foo.")); + assertTrue(parser instanceof CParser); + } + public void testCreateCParser3() { + Parser parser = GccCCompiler.getInstance() + .createParser(new File("foo")); + assertTrue(parser instanceof CParser); + } + public void testCreateFortranParser1() { + Parser parser = GccCCompiler.getInstance().createParser( + new File("foo.f")); + assertTrue(parser instanceof FortranParser); + } + public void testCreateFortranParser2() { + Parser parser = GccCCompiler.getInstance().createParser( + new File("foo.FoR")); + assertTrue(parser instanceof FortranParser); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccCompatibleCCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccCompatibleCCompiler.java new file mode 100644 index 0000000..68fab2e --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccCompatibleCCompiler.java @@ -0,0 +1,105 @@ +/* + * + * Copyright 2003-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.gcc; +import java.util.Vector; + +import junit.framework.TestCase; +/** + * Tests for gcc compatible compilers + * + * @author CurtA + */ +public abstract class TestGccCompatibleCCompiler extends TestCase { + /** + * Constructor + * + * @param name + * test case name + */ + public TestGccCompatibleCCompiler(String name) { + super(name); + } + /** + * Compiler creation method + * + * Must be overriden by extending classes + * + * @return GccCompatibleCCompiler + */ + protected abstract GccCompatibleCCompiler create(); + /** + * Tests command lines switches for warning = 0 + */ + public void testWarningLevel0() { + GccCompatibleCCompiler compiler = create(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 0); + assertEquals(1, args.size()); + assertEquals("-w", args.elementAt(0)); + } + /** + * Tests command lines switches for warning = 1 + */ + public void testWarningLevel1() { + GccCompatibleCCompiler compiler = create(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 1); + assertEquals(0, args.size()); + } + /** + * Tests command lines switches for warning = 2 + */ + public void testWarningLevel2() { + GccCompatibleCCompiler compiler = create(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 2); + assertEquals(0, args.size()); + } + /** + * Tests command lines switches for warning = 3 + */ + public void testWarningLevel3() { + GccCompatibleCCompiler compiler = create(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 3); + assertEquals(1, args.size()); + assertEquals("-Wall", args.elementAt(0)); + } + /** + * Tests command lines switches for warning = 4 + */ + public void testWarningLevel4() { + GccCompatibleCCompiler compiler = create(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 4); + assertEquals(2, args.size()); + assertEquals("-W", args.elementAt(0)); + assertEquals("-Wall", args.elementAt(1)); + } + /** + * Tests command lines switches for warning = 5 + */ + public void testWarningLevel5() { + GccCompatibleCCompiler compiler = create(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 5); + assertEquals(3, args.size()); + assertEquals("-Werror", args.elementAt(0)); + assertEquals("-W", args.elementAt(1)); + assertEquals("-Wall", args.elementAt(2)); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java new file mode 100644 index 0000000..84e8d57 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java @@ -0,0 +1,79 @@ +/* + * + * Copyright 2003-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.gcc; +import junit.framework.TestCase; +import net.sf.antcontrib.cpptasks.OutputTypeEnum; +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.Linker; +/** + * @author CurtA + */ +public class TestGccLinker extends TestCase { + private final String realOSName; + /** + * Constructor + * + * @param name test name + */ + public TestGccLinker(String name) { + super(name); + realOSName = System.getProperty("os.name"); + } + protected void tearDown() throws java.lang.Exception { + System.setProperty("os.name", realOSName); + } + public void testGetLinkerDarwinPlugin() { + System.setProperty("os.name", "Mac OS X"); + GccLinker linker = GccLinker.getInstance(); + OutputTypeEnum outputType = new OutputTypeEnum(); + outputType.setValue("plugin"); + LinkType linkType = new LinkType(); + linkType.setOutputType(outputType); + Linker pluginLinker = linker.getLinker(linkType); + assertEquals("libfoo.bundle", pluginLinker.getOutputFileNames("foo", null)[0]); + } + public void testGetLinkerDarwinShared() { + System.setProperty("os.name", "Mac OS X"); + GccLinker linker = GccLinker.getInstance(); + OutputTypeEnum outputType = new OutputTypeEnum(); + outputType.setValue("shared"); + LinkType linkType = new LinkType(); + linkType.setOutputType(outputType); + Linker sharedLinker = linker.getLinker(linkType); + assertEquals("libfoo.dylib", sharedLinker.getOutputFileNames("foo", null)[0]); + } + public void testGetLinkerNonDarwinPlugin() { + System.setProperty("os.name", "Microsoft Windows"); + GccLinker linker = GccLinker.getInstance(); + OutputTypeEnum outputType = new OutputTypeEnum(); + outputType.setValue("plugin"); + LinkType linkType = new LinkType(); + linkType.setOutputType(outputType); + Linker pluginLinker = linker.getLinker(linkType); + assertEquals("libfoo.so", pluginLinker.getOutputFileNames("foo", null)[0]); + } + public void testGetLinkerNonDarwinShared() { + System.setProperty("os.name", "Microsoft Windows"); + GccLinker linker = GccLinker.getInstance(); + OutputTypeEnum outputType = new OutputTypeEnum(); + outputType.setValue("shared"); + LinkType linkType = new LinkType(); + linkType.setOutputType(outputType); + Linker sharedLinker = linker.getLinker(linkType); + assertEquals("libfoo.so", sharedLinker.getOutputFileNames("foo", null)[0]); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/hp/TestaCCCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/hp/TestaCCCompiler.java new file mode 100644 index 0000000..073463e --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/hp/TestaCCCompiler.java @@ -0,0 +1,93 @@ +/* + * + * Copyright 2002-2007 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.hp; +import java.util.Vector; + +import junit.framework.TestCase; + +import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; +/** + * Test HP aCC compiler adapter + * + */ +// TODO Since aCCCompiler extends GccCompatibleCCompiler, this test +// should probably extend TestGccCompatibleCCompiler. +public class TestaCCCompiler extends TestCase { + public TestaCCCompiler(String name) { + super(name); + } + public void testBidC() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.c")); + } + public void testBidCpp() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.C")); + } + public void testBidCpp2() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.cc")); + } + public void testBidCpp3() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.CC")); + } + public void testBidCpp4() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.cxx")); + } + public void testBidCpp5() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.CXX")); + } + public void testBidCpp6() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.cpp")); + } + public void testBidCpp7() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.CPP")); + } + public void testBidCpp8() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.c++")); + } + public void testBidCpp9() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.C++")); + } + public void testBidPreprocessed() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.i")); + } + public void testBidAssembly() { + aCCCompiler compiler = aCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.s")); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/ibm/TestVisualAgeCCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/ibm/TestVisualAgeCCompiler.java new file mode 100644 index 0000000..62a513e --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/ibm/TestVisualAgeCCompiler.java @@ -0,0 +1,68 @@ +/* + * + * Copyright 2002-2007 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.ibm; +import java.util.Vector; + +import junit.framework.TestCase; + +import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; +/** + * Test IBM Visual Age compiler adapter + * + */ +// TODO Since VisualAgeCCompiler extends GccCompatibleCCompiler, this test +// should probably extend TestGccCompatibleCCompiler. +public class TestVisualAgeCCompiler extends TestCase { + public TestVisualAgeCCompiler(String name) { + super(name); + } + public void testBidC() { + VisualAgeCCompiler compiler = VisualAgeCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.c")); + } + public void testBidCpp() { + VisualAgeCCompiler compiler = VisualAgeCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.C")); + } + public void testBidCpp2() { + VisualAgeCCompiler compiler = VisualAgeCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.cc")); + } + public void testBidCpp3() { + VisualAgeCCompiler compiler = VisualAgeCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.cxx")); + } + public void testBidCpp4() { + VisualAgeCCompiler compiler = VisualAgeCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.cpp")); + } + public void testBidPreprocessed() { + VisualAgeCCompiler compiler = VisualAgeCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.i")); + } + public void testBidAssembly() { + VisualAgeCCompiler compiler = VisualAgeCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.s")); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/package.html b/src/test/java/net/sf/antcontrib/cpptasks/package.html new file mode 100644 index 0000000..eba4e2c --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/package.html @@ -0,0 +1,28 @@ + + + + + + + +JUnit tests for the net.sf.antcontrib.cpptasks package. + + + + diff --git a/src/test/java/net/sf/antcontrib/cpptasks/parser/TestCParser.java b/src/test/java/net/sf/antcontrib/cpptasks/parser/TestCParser.java new file mode 100644 index 0000000..d5e9888 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/parser/TestCParser.java @@ -0,0 +1,199 @@ +/* + * + * Copyright 2002-2005 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.parser; + +import junit.framework.TestCase; + +import java.io.CharArrayReader; +import java.io.IOException; + +/** + * Tests for the CParser class. + */ +public final class TestCParser + extends TestCase { + /** + * Constructor. + * @param name String test name + */ + public TestCParser(final String name) { + super(name); + } + + /** + * Checks parsing of #include . + * @throws IOException test fails on IOException + */ + public void testImmediateImportBracket() throws IOException { + CharArrayReader reader = new CharArrayReader( + "#import nowhatever ".toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 1); + assertEquals("foo.h", includes[0]); + } + + /** + * Checks parsing of #import "foo.h". + * @throws IOException test fails on IOException + */ + public void testImmediateImportQuote() throws IOException { + CharArrayReader reader = new CharArrayReader("#import \"foo.h\" " + .toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 1); + assertEquals("foo.h", includes[0]); + } + + /** + * Checks parsing of #include . + * @throws IOException test fails on IOException + */ + public void testImmediateIncludeBracket() throws IOException { + CharArrayReader reader = new CharArrayReader("#include " + .toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 1); + assertEquals("foo.h", includes[0]); + } + + /** + * Checks parsing of #include "foo.h". + * @throws IOException test fails on IOException. + */ + public void testImmediateIncludeQuote() throws IOException { + CharArrayReader reader = new CharArrayReader( + "#include \"foo.h\" ".toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 1); + assertEquals("foo.h", includes[0]); + } + + /** + * Checks parsing of #import + + + + + + +JUnit tests for the net.sf.antcontrib.cpptasks.parser package. + + + diff --git a/src/test/java/net/sf/antcontrib/cpptasks/sun/TestForteCCCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/sun/TestForteCCCompiler.java new file mode 100644 index 0000000..df08539 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/sun/TestForteCCCompiler.java @@ -0,0 +1,132 @@ +/* + * + * Copyright 2002-2007 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.sun; +import java.util.Vector; + +import junit.framework.TestCase; + +import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; +/** + * Test Sun Forte compiler adapter + * + */ +// TODO Since ForteCCCompiler extends GccCompatibleCCompiler, this test +// should probably extend TestGccCompatibleCCompiler. +public class TestForteCCCompiler extends TestCase { + public TestForteCCCompiler(String name) { + super(name); + } + public void testBidC() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.c")); + } + public void testBidCpp() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.C")); + } + public void testBidCpp2() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.cc")); + } + public void testBidCpp3() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.cxx")); + } + public void testBidCpp4() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.cpp")); + } + public void testBidCpp5() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.c++")); + } + public void testBidPreprocessed() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.i")); + } + public void testBidAssembly() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler + .bid("foo.s")); + } + /** + * Tests command line switches for warning = 0 + */ + public void testWarningLevel0() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 0); + assertEquals(1, args.size()); + assertEquals("-w", args.elementAt(0)); + } + /** + * Tests command line switches for warning = 1 + */ + public void testWarningLevel1() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 1); + assertEquals(0, args.size()); + } + /** + * Tests command line switches for warning = 2 + */ + public void testWarningLevel2() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 2); + assertEquals(0, args.size()); + } + /** + * Tests command line switches for warning = 3 + */ + public void testWarningLevel3() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 3); + assertEquals(1, args.size()); + assertEquals("+w", args.elementAt(0)); + } + /** + * Tests command line switches for warning = 4 + */ + public void testWarningLevel4() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 4); + assertEquals(1, args.size()); + assertEquals("+w2", args.elementAt(0)); + } + /** + * Tests command line switches for warning = 5 + */ + public void testWarningLevel5() { + ForteCCCompiler compiler = ForteCCCompiler.getInstance(); + Vector args = new Vector(); + compiler.addWarningSwitch(args, 5); + assertEquals(2, args.size()); + assertEquals("+w2", args.elementAt(0)); + assertEquals("-xwe", args.elementAt(1)); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java new file mode 100644 index 0000000..6d97c12 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java @@ -0,0 +1,74 @@ +/* + * + * Copyright 2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.trolltech; + +import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; +import net.sf.antcontrib.cpptasks.compiler.TestAbstractCompiler; + +/** + * Tests for Trolltech Meta Object Compiler. + * + */ +public class TestMetaObjectCompiler + extends TestAbstractCompiler { + /** + * Constructor. + * @param name test name + */ + public TestMetaObjectCompiler(final String name) { + super(name); + } + + /** + * Creates compiler for inherited tests. + * @return AbstractProcessor compiler + */ + protected AbstractProcessor create() { + return MetaObjectCompiler.getInstance(); + } + + /** + * Gets default output file extension. + * @return String output file extension + */ + protected String getObjectExtension() { + return ".moc"; + } + + /** + * Skip testGetIdentifier. + */ + public void testGetIdentfier() { + } + + /** + * Override inherited test. + */ + public void testGetOutputFileName1() { + AbstractProcessor compiler = MetaObjectCompiler.getInstance(); + String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.cpp", null); + assertEquals("hello" + getObjectExtension(), output[0]); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.cpp", null); + assertEquals("hello" + getObjectExtension(), output[0]); + output = compiler.getOutputFileNames("hello.cpp", null); + assertEquals("hello" + getObjectExtension(), output[0]); + output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h", null); + assertEquals("moc_hello.cpp", output[0]); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.h", null); + assertNull("moc_hello.cpp", output[0]); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectParser.java b/src/test/java/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectParser.java new file mode 100644 index 0000000..371bdf1 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectParser.java @@ -0,0 +1,58 @@ +/* + * + * Copyright 2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.trolltech; + +import java.io.CharArrayReader; +import java.io.IOException; +import junit.framework.TestCase; + +/** + * Tests for the MetaObjectParser class. + */ +public final class TestMetaObjectParser + extends TestCase { + /** + * Constructor. + * @param name String test name + */ + public TestMetaObjectParser(final String name) { + super(name); + } + + /** + * Test that the presence of Q_OBJECT causes hasQObject to return true. + * @throws IOException test fails on IOException + */ + public void testHasQObject1() throws IOException { + CharArrayReader reader = new CharArrayReader( + " Q_OBJECT ".toCharArray()); + boolean hasQObject = MetaObjectParser.hasQObject(reader); + assertTrue(hasQObject); + } + + /** + * Test that the lack of Q_OBJECT causes hasQObject to return false. + * @throws IOException test fails on IOException + */ + public void testHasQObject2() throws IOException { + CharArrayReader reader = new CharArrayReader( + " Q_OBJ ECT ".toCharArray()); + boolean hasQObject = MetaObjectParser.hasQObject(reader); + assertFalse(hasQObject); + } + +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/trolltech/package.html b/src/test/java/net/sf/antcontrib/cpptasks/trolltech/package.html new file mode 100644 index 0000000..bbdaa89 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/trolltech/package.html @@ -0,0 +1,27 @@ + + + + + + + +Tests for Trolltech Qt uic and moc compilers. + + + diff --git a/src/test/java/net/sf/antcontrib/cpptasks/types/TestDefineArgument.java b/src/test/java/net/sf/antcontrib/cpptasks/types/TestDefineArgument.java new file mode 100644 index 0000000..e5b53ee --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/types/TestDefineArgument.java @@ -0,0 +1,124 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.types; +import junit.framework.TestCase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +/** + * Tests for the DefineArgument class + */ +public class TestDefineArgument extends TestCase { + public TestDefineArgument(String name) { + super(name); + } + public void testIsActive1() { + DefineArgument arg = new DefineArgument(); + Project project = new Project(); + try { + boolean isActive = arg.isActive(project); + } catch (BuildException ex) { + return; + } + fail("isActive should throw exception if name is not set"); + } + public void testIsActive2() { + DefineArgument arg = new DefineArgument(); + arg.setName("TEST"); + Project project = new Project(); + project.setProperty("cond", ""); + arg.setIf("cond"); + assertTrue(arg.isActive(project)); + } + public void testIsActive3() { + DefineArgument arg = new DefineArgument(); + arg.setName("TEST"); + Project project = new Project(); + arg.setIf("cond"); + assertTrue(!arg.isActive(project)); + } + public void testIsActive4() { + DefineArgument arg = new DefineArgument(); + arg.setName("TEST"); + Project project = new Project(); + project.setProperty("cond", "false"); + arg.setIf("cond"); + try { + boolean isActive = arg.isActive(project); + } catch (BuildException ex) { + return; + } + fail("Should throw exception for suspicious value"); + } + public void testIsActive5() { + DefineArgument arg = new DefineArgument(); + arg.setName("TEST"); + Project project = new Project(); + project.setProperty("cond", ""); + arg.setUnless("cond"); + assertTrue(!arg.isActive(project)); + } + public void testIsActive6() { + DefineArgument arg = new DefineArgument(); + arg.setName("TEST"); + Project project = new Project(); + arg.setUnless("cond"); + assertTrue(arg.isActive(project)); + } + public void testIsActive7() { + DefineArgument arg = new DefineArgument(); + arg.setName("TEST"); + Project project = new Project(); + project.setProperty("cond", "false"); + arg.setUnless("cond"); + try { + boolean isActive = arg.isActive(project); + } catch (BuildException ex) { + return; + } + fail("Should throw exception for suspicious value"); + } + public void testIsActive8() { + DefineArgument arg = new DefineArgument(); + arg.setName("TEST"); + Project project = new Project(); + project.setProperty("cond", ""); + arg.setIf("cond"); + arg.setUnless("cond"); + assertTrue(!arg.isActive(project)); + } + public void testMerge() { + UndefineArgument[] base = new UndefineArgument[2]; + UndefineArgument[] specific = new UndefineArgument[2]; + base[0] = new DefineArgument(); + base[0].setName("foo"); + base[1] = new UndefineArgument(); + base[1].setName("hello"); + specific[0] = new DefineArgument(); + specific[0].setName("hello"); + specific[1] = new UndefineArgument(); + specific[1].setName("world"); + UndefineArgument[] merged = UndefineArgument.merge(base, specific); + assertEquals(3, merged.length); + assertEquals("foo", merged[0].getName()); + assertEquals(true, merged[0].isDefine()); + assertEquals("hello", merged[1].getName()); + assertEquals(true, merged[1].isDefine()); + assertEquals("world", merged[2].getName()); + assertEquals(false, merged[2].isDefine()); + } +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java b/src/test/java/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java new file mode 100644 index 0000000..180f765 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java @@ -0,0 +1,337 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package net.sf.antcontrib.cpptasks.types; + +import java.io.File; +import java.io.IOException; + +import junit.framework.TestCase; +import net.sf.antcontrib.cpptasks.CUtil; +import net.sf.antcontrib.cpptasks.MockBuildListener; +import net.sf.antcontrib.cpptasks.MockFileCollector; +import net.sf.antcontrib.cpptasks.compiler.Linker; +import net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker; +import net.sf.antcontrib.cpptasks.devstudio.DevStudioLibrarian; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; + +/** + * Tests for the LibrarySet class. + */ +public class TestLibrarySet + extends TestCase { + + /** + * Constructor. + * + * @param name + * test name + */ + public TestLibrarySet(final String name) { + super(name); + } + + /** + * Evaluate isActive when "if" specifies a property that is set. + */ + public final void testIsActive1() { + LibrarySet libset = new LibrarySet(); + Project project = new Project(); + project.setProperty("windows", ""); + libset.setProject(project); + libset.setIf("windows"); + CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("kernel32"); + libset.setLibs(libs); + boolean isActive = libset.isActive(project); + assertTrue(isActive); + } + + /** + * Evaluate isActive when "if" specifies a property whose value suggests the + * user thinks the value is significant. + * + */ + public final void testIsActive2() { + LibrarySet libset = new LibrarySet(); + Project project = new Project(); + // + // setting the value to false should throw + // exception to warn user that they are misusing if + // + project.setProperty("windows", "false"); + libset.setIf("windows"); + try { + boolean isActive = libset.isActive(project); + } catch (BuildException ex) { + return; + } + fail(); + } + + /** + * Evaluate isActive when "if" specifies a property that is not set. + */ + public final void testIsActive3() { + LibrarySet libset = new LibrarySet(); + Project project = new Project(); + libset.setIf("windows"); + boolean isActive = libset.isActive(project); + assertTrue(!isActive); + } + + /** + * Evaluate isActive when "unless" specifies a property that is set. + * + */ + public final void testIsActive4() { + LibrarySet libset = new LibrarySet(); + Project project = new Project(); + project.setProperty("windows", ""); + libset.setUnless("windows"); + boolean isActive = libset.isActive(project); + assertTrue(!isActive); + } + + /** + * Evaluate isActive when "unless" specifies a property whose value suggests + * the user thinks the value is significant. + * + */ + public final void testIsActive5() { + LibrarySet libset = new LibrarySet(); + Project project = new Project(); + // + // setting the value to false should throw + // exception to warn user that they are misusing if + // + project.setProperty("windows", "false"); + libset.setUnless("windows"); + try { + boolean isActive = libset.isActive(project); + } catch (BuildException ex) { + return; + } + fail(); + } + + /** + * Evaluate isActive when "unless" specifies a property that is not set. + */ + public final void testIsActive6() { + LibrarySet libset = new LibrarySet(); + Project project = new Project(); + libset.setProject(project); + libset.setUnless("windows"); + CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("kernel32"); + libset.setLibs(libs); + boolean isActive = libset.isActive(project); + assertTrue(isActive); + } + + /** + * The libs parameter should not end with .lib, .so, .a etc New behavior is + * to warn if it ends in a suspicious extension. + */ + public final void testLibContainsDot() { + LibrarySet libset = new LibrarySet(); + Project p = new Project(); + MockBuildListener listener = new MockBuildListener(); + p.addBuildListener(listener); + libset.setProject(p); + CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("mylib1.1"); + libset.setLibs(libs); + assertEquals(0, listener.getMessageLoggedEvents().size()); + } + + /** + * The libs parameter should not end with .lib, .so, .a (that is, + * should be kernel, not kernel.lib). Previously the libset would + * warn on configuration, now provides more feedback + * when library is not found. + */ + public final void testLibContainsDotLib() { + LibrarySet libset = new LibrarySet(); + Project p = new Project(); + MockBuildListener listener = new MockBuildListener(); + p.addBuildListener(listener); + libset.setProject(p); + CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder( + "mylib1.lib"); + libset.setLibs(libs); + assertEquals(0, listener.getMessageLoggedEvents().size()); + } + + /** + * Use of a libset or syslibset without a libs attribute should log a + * warning message. + */ + public final void testLibNotSpecified() { + LibrarySet libset = new LibrarySet(); + Project p = new Project(); + MockBuildListener listener = new MockBuildListener(); + p.addBuildListener(listener); + libset.setProject(p); + boolean isActive = libset.isActive(p); + assertEquals(false, isActive); + assertEquals(1, listener.getMessageLoggedEvents().size()); + } + + /** + * this threw an exception prior to 2002-09-05 and started to throw one + * again 2002-11-19 up to 2002-12-11. + */ + public final void testShortLibName() { + LibrarySet libset = new LibrarySet(); + CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("li"); + libset.setProject(new Project()); + libset.setLibs(libs); + } + + /** + * The libs parameter should contain not a lib prefix (that is, + * pthread not libpthread). Previously the libset would + * warn on configuration, now provides more feedback + * when library is not found. + */ + public final void testStartsWithLib() { + LibrarySet libset = new LibrarySet(); + Project p = new Project(); + MockBuildListener listener = new MockBuildListener(); + p.addBuildListener(listener); + libset.setProject(p); + CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder( + "libmylib1"); + libset.setLibs(libs); + assertEquals(0, listener.getMessageLoggedEvents().size()); + } + + /** + * This test creates two "fake" libraries in the temporary directory and + * check how many are visited. + * + * @param linker linker + * @param expected expected number of visited files + * @throws IOException + * if unable to write to temporary directory or delete temporary + * files + */ + public final void testVisitFiles(final Linker linker, + final int expected) + throws IOException { + LibrarySet libset = new LibrarySet(); + Project p = new Project(); + MockBuildListener listener = new MockBuildListener(); + p.addBuildListener(listener); + libset.setProject(p); + // + // create temporary files named cpptasksXXXXX.lib + // + File lib1 = File.createTempFile("cpptasks", ".lib"); + String lib1Name = lib1.getName(); + lib1Name = lib1Name.substring(0, lib1Name.indexOf(".lib")); + File lib2 = File.createTempFile("cpptasks", ".lib"); + File baseDir = lib1.getParentFile(); + + // set the dir attribute to the temporary directory + libset.setDir(baseDir); + // set libs to the file name without the suffix + CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder(lib1Name); + libset.setLibs(libs); + + // + // collect all files visited + MockFileCollector collector = new MockFileCollector(); + libset.visitLibraries(p, linker, new File[0], collector); + + // + // get the canonical paths for the initial and visited libraries + String expectedCanonicalPath = lib1.getCanonicalPath(); + String actualCanonicalPath = null; + if (collector.size() == 1) { + actualCanonicalPath = new File(collector.getBaseDir(0), collector + .getFileName(0)).getCanonicalPath(); + } + // + // delete the temporary files + lib1.delete(); + lib2.delete(); + // was there only one match + assertEquals(expected, collector.size()); + if (expected == 1) { + // is its canonical path as expected + assertEquals(expectedCanonicalPath, actualCanonicalPath); + } + } + + /** + * Run testVisitFiles with the MSVC Linker + * expect one matching file. + * + * @throws IOException if unable to create or delete temporary file + */ + public final void testLinkerVisitFiles() throws IOException { + Linker linker = DevStudioLinker.getInstance(); + testVisitFiles(linker, 1); + } + + /** + * Run testVisitFiles with the MSVC Librarian + * expect one matching file. + * + * @throws IOException if unable to create or delete temporary file + */ + public final void testLibrarianVisitFiles() throws IOException { + Linker linker = DevStudioLibrarian.getInstance(); + testVisitFiles(linker, 0); + } + + + /** + * This test specifies a library pattern that should + * not match any available libraries and expects that + * a build exception will be raised. + * + * See bug 1380366 + */ + public final void testBadLibname() { + LibrarySet libset = new LibrarySet(); + Project p = new Project(); + MockBuildListener listener = new MockBuildListener(); + p.addBuildListener(listener); + libset.setProject(p); + // set libs to the file name without the suffix + CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("badlibname"); + libset.setLibs(libs); + + // + // collect all files visited + MockFileCollector collector = new MockFileCollector(); + try { + libset.visitLibraries(p, DevStudioLinker.getInstance(), new File[0], collector); + } catch(BuildException ex) { + return; + } +// +// code around line 320 in LibrarySet that would throw BuildException +// (and prevent reaching this line) is disabled since logic for identifying +// missing libraries does not work reliably on non-Windows platforms +// +// fail("visitLibraries should throw exception due to unsatisifed libname"); + } + +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/types/package.html b/src/test/java/net/sf/antcontrib/cpptasks/types/package.html new file mode 100644 index 0000000..e5efbc4 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/types/package.html @@ -0,0 +1,28 @@ + + + + + + + +JUnit tests for the net.sf.antcontrib.cpptasks.types package. + + + + diff --git a/src/test/resources/openshore/dependencies.xml b/src/test/resources/openshore/dependencies.xml new file mode 100644 index 0000000..1644f84 --- /dev/null +++ b/src/test/resources/openshore/dependencies.xml @@ -0,0 +1,911 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/openshore/history.xml b/src/test/resources/openshore/history.xml new file mode 100644 index 0000000..19fe515 --- /dev/null +++ b/src/test/resources/openshore/history.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/xerces-c/dependencies.xml b/src/test/resources/xerces-c/dependencies.xml new file mode 100644 index 0000000..f8d7324 --- /dev/null +++ b/src/test/resources/xerces-c/dependencies.xml @@ -0,0 +1,3330 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/xerces-c/history.xml b/src/test/resources/xerces-c/history.xml new file mode 100644 index 0000000..2e8a3c0 --- /dev/null +++ b/src/test/resources/xerces-c/history.xml @@ -0,0 +1,636 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3