Ejemplo n.º 1
0
 def test_examineWithOnlyMakefile(self):
     try:
         tempDir = mdTestUtilities.makeTempDir()
         targetDir = os.path.join(tempDir, "targetDir")
         os.makedirs(targetDir)
         mdTestUtilities.createBlankFile(os.path.join(
             targetDir, "Makefile"))
         option = options.Options()
         option.buildDir = os.path.join(tempDir, option.buildDir)
         option.importMode = True
         targets = target.Target("OnlyMakefile", targetDir)
         targets.examine(option)
         targets.expandDefines(option)
         self.assertEquals(
             targets.findBuildStep("preconfig").command, "",
             "Target with only Makefile returned a preconfig command when it should not have"
         )
         self.assertEquals(
             targets.findBuildStep("config").command, "",
             "Target with only Makefile returned a config command when it should not have"
         )
         self.assertEquals(
             targets.findBuildStep("build").command, "make",
             "Target with only Makefile returned wrong build command")
         self.assertEquals(
             targets.findBuildStep("install").command, "make install",
             "Target with only Makefile returned wrong install command")
     finally:
         utilityFunctions.removeDir(tempDir)
Ejemplo n.º 2
0
    def test_processCommandline05(self):
        try:
            tempDir = mdTestUtilities.makeTempDir()
            url = "http://www.webdav.org/neon/neon-0.29.5.tar.gz"
            tarDir, tarFile = mdTestUtilities.createTarFile(tempDir)
            tarPath = os.path.join(tempDir, tarFile)
            directory = os.path.join(tempDir, "c")
            os.mkdir(directory)

            testOptions = options.Options()
            commandline = "MixDown --import " + url + " " + tarPath + " " + directory
            self.assertEquals(
                testOptions.processCommandline(commandline.split(" ")), True,
                "Command-line should have processed correctly")
            self.assertEquals(len(testOptions.targetsToImport), 3,
                              "Number of targets to import was wrong")
            self.assertEquals(testOptions.targetsToImport[0].name, "neon",
                              "Target had wrong name")
            self.assertEquals(testOptions.targetsToImport[0].path, url,
                              "Target had wrong name")
            self.assertEquals(testOptions.targetsToImport[1].name, "test",
                              "Target had wrong name")
            self.assertEquals(testOptions.targetsToImport[1].path, tarPath,
                              "Target had wrong name")
            self.assertEquals(testOptions.targetsToImport[2].name, "c",
                              "Target had wrong name")
            self.assertEquals(testOptions.targetsToImport[2].path, directory,
                              "Target had wrong name")
            self.assertEquals(testOptions.validate(), True,
                              "Command-line options should have validated")
        finally:
            utilityFunctions.removeDir(tempDir)
Ejemplo n.º 3
0
    def test_examineWithJobSlots(self):
        option = options.Options()
        option.buildDir = "."
        option.importMode = True
        defines.setJobSlotsDefines(option.defines, "4")

        targets = target.Target("TestCaseA",
                                "cases/simpleGraphAutoTools/TestCaseA")
        targets.examine(option)
        targets.expandDefines(option)
        self.assertEquals(
            targets.findBuildStep("preconfig").command,
            "test -x configure || autoreconf -i",
            "'cases/simpleGraphAutoTools/TestCaseA' returned wrong preconfig command"
        )
        self.assertEquals(
            targets.findBuildStep("config").command,
            "./configure --prefix=/usr/local",
            "'cases/simpleGraphAutoTools/TestCaseA' returned wrong config command"
        )
        self.assertEquals(
            targets.findBuildStep("build").command, "make -j4",
            "'cases/simpleGraphAutoTools/TestCaseA' returned wrong build command"
        )
        self.assertEquals(
            targets.findBuildStep("install").command, "make -j4 install",
            "'cases/simpleGraphAutoTools/TestCaseA' returned wrong install command"
        )
Ejemplo n.º 4
0
    def test_examineWithDependenciesWithPrefix(self):
        option = options.Options()
        option.buildDir = "."
        option.importMode = True
        defines.setPrefixDefines(option.defines, "/test/path")
        option.prefixDefined = True

        targets = target.Target("TestCaseA",
                                "cases/simpleGraphAutoTools/TestCaseA")
        targets.dependsOn = ["TestCaseB", "TestCaseC"]
        targets.examine(option)
        targets.expandDefines(option)
        self.assertEquals(
            targets.findBuildStep("preconfig").command,
            "test -x configure || autoreconf -i",
            "'cases/simpleGraphAutoTools/TestCaseA' returned wrong preconfig command"
        )
        self.assertEquals(
            targets.findBuildStep("config").command,
            "./configure --prefix=/test/path  --with-TestCaseB=/test/path --with-TestCaseC=/test/path",
            "'cases/simpleGraphAutoTools/TestCaseA' returned wrong config command"
        )
        self.assertEquals(
            targets.findBuildStep("build").command, "make",
            "'cases/simpleGraphAutoTools/TestCaseA' returned wrong build command"
        )
        self.assertEquals(
            targets.findBuildStep("install").command, "make install",
            "'cases/simpleGraphAutoTools/TestCaseA' returned wrong install command"
        )
Ejemplo n.º 5
0
    def test_examineWithAutoToolsWithPrefix(self):
        try:
            tempDir = mdTestUtilities.makeTempDir()
            targetDir = os.path.join(tempDir, "targetDir")
            os.makedirs(targetDir)
            mdTestUtilities.createBlankFiles(targetDir,
                                             ["Makefile.am", "configure.ac"])
            option = options.Options()
            defines.setPrefixDefines(option.defines, "/test/prefix")
            option.prefixDefined = True
            option.buildDir = os.path.join(tempDir, option.buildDir)
            option.importMode = True

            targets = target.Target("AutoTools", targetDir)
            targets.examine(option)
            targets.expandDefines(option)
            self.assertEquals(
                targets.findBuildStep("preconfig").command,
                "test -x configure || autoreconf -i",
                "Target with autotool files returned wrong preconfig command")
            self.assertEquals(
                targets.findBuildStep("config").command,
                "./configure --prefix=/test/prefix",
                "Target with autotool files returned wrong config command")
            self.assertEquals(
                targets.findBuildStep("build").command, "make",
                "Target with autotool files returned wrong build command")
            self.assertEquals(
                targets.findBuildStep("install").command, "make install",
                "Target with autotool files returned wrong install command")
        finally:
            utilityFunctions.removeDir(tempDir)
Ejemplo n.º 6
0
    def test_processCommandline13(self):
        try:
            tempDir = mdTestUtilities.makeTempDir()
            overrideFilePath = os.path.join(tempDir, "testOverrides")
            mdTestUtilities.createBlankFile(overrideFilePath)

            testOptions = options.Options()
            commandline = "MixDown --import -otestOverrides"
            self.assertEquals(
                testOptions.processCommandline(commandline.split(" ")), False,
                "Command-line should not have processed correctly")
            self.assertEquals(testOptions.targetsToImport, [],
                              "targetsToImport should have not been set")
            self.assertEquals(testOptions.overrideFile, "",
                              "overrideFile should not have been set")
            self.assertEquals(testOptions.overrideGroup, None,
                              "overrideGroup should not have been set")
            self.assertEquals(testOptions.compilerGroupName, "",
                              "compilerGroupName should not have been set")
            self.assertEquals(
                testOptions.optimizationGroupName, "",
                "optimizationGroupName should not have been set")
            self.assertEquals(testOptions.parallelGroupName, "",
                              "parallelGroupName should not have been set")
        finally:
            utilityFunctions.removeDir(tempDir)
Ejemplo n.º 7
0
    def test_processCommandline29(self):
        try:
            tempDir = mdTestUtilities.makeTempDir()
            overrideFilePath = os.path.join(tempDir, "testOverrides")
            mdTestUtilities.createBlankFile(overrideFilePath)
            projectFilePath = os.path.join(tempDir, "test.md")
            mdTestUtilities.createBlankFile(projectFilePath)

            testOptions = options.Options()
            commandline = "MixDown -o" + overrideFilePath + " -g,, " + projectFilePath
            self.assertEquals(
                testOptions.processCommandline(commandline.split(" ")), False,
                "Command-line should not have processed correctly")
            self.assertEquals(testOptions.overrideFile, overrideFilePath,
                              "overrideFile should have been set")
            self.assertEquals(testOptions.overrideGroup, None,
                              "overrideGroup should not have been set")
            self.assertEquals(testOptions.compilerGroupName, "",
                              "compilerGroupName should have been set")
            self.assertEquals(testOptions.optimizationGroupName, "",
                              "optimizationGroupName should have been set")
            self.assertEquals(testOptions.parallelGroupName, "",
                              "parallelGroupName should have been set")
        finally:
            utilityFunctions.removeDir(tempDir)
Ejemplo n.º 8
0
    def test_processCommandline22(self):
        try:
            tempDir = mdTestUtilities.makeTempDir()
            tarDir, tarFile = mdTestUtilities.createTarFile(tempDir)
            tarPath = os.path.join(tempDir, tarFile)

            testOptions = options.Options()
            commandline = "MixDown -v -i --import " + tarPath
            self.assertEquals(
                testOptions.processCommandline(commandline.split(" ")), True,
                "Command-line should have processed correctly")
            self.assertEquals(len(testOptions.targetsToImport), 1,
                              "Number of targets to import was wrong")
            self.assertEquals(testOptions.targetsToImport[0].name, "test",
                              "Target had wrong name")
            self.assertEquals(testOptions.targetsToImport[0].path, tarPath,
                              "Target had wrong name")
            self.assertEquals(testOptions.verbose, True,
                              "verbose should have been set")
            self.assertEquals(testOptions.interactive, True,
                              "interactive should have been set")
            self.assertEquals(testOptions.validate(), True,
                              "Command-line options should have validated")
        finally:
            utilityFunctions.removeDir(tempDir)
Ejemplo n.º 9
0
    def test_selectGroups03(self):
        #regression test whether selectGroups alters original groups
        mdOptions = options.Options()
        mdOptions.compilerGroupName = "compiler1"
        mdOptions.optimizationGroupName = "optimization1"
        mdOptions.parallelGroupName = "*"
        mdOptions.overrideFile = "testNOREALFILE"

        groupList = []

        group1 = overrides.OverrideGroup()
        group1.compiler = "compiler1"
        group1.optimization = "*"
        group1.parallel = "*"
        group1["test"] = "value1"
        group1["group1Only"] = "group1OnlyValue"
        groupList.append(group1)

        group2 = overrides.OverrideGroup()
        group2.compiler = "compiler1"
        group2.optimization = "optimization1"
        group2.parallel = "*"
        group2["test"] = "value2"
        group2["group2Only"] = "group2OnlyValue"
        groupList.append(group2)

        finalGroup = overrides.selectGroups(groupList, mdOptions)
        self.assertEquals(
            fullCount(group1), 2,
            "After selectGroups(), group1 was incorrectly altered")
        self.assertEquals(
            "test" in group1, True,
            "After selectGroups(), group1 was incorrectly altered")
        self.assertEquals(
            group1["test"], "value1",
            "After selectGroups(), group1 was incorrectly altered")
        self.assertEquals(
            "group1Only" in group1, True,
            "After selectGroups(), group1 was incorrectly altered")
        self.assertEquals(
            group1["group1Only"], "group1OnlyValue",
            "After selectGroups(), group1 was incorrectly altered")
        self.assertEquals(
            fullCount(group2), 2,
            "After selectGroups(), group2 was incorrectly altered")
        self.assertEquals(
            "test" in group2, True,
            "After selectGroups(), group2 was incorrectly altered")
        self.assertEquals(
            group2["test"], "value2",
            "After selectGroups(), group2 was incorrectly altered")
        self.assertEquals(
            "group2Only" in group2, True,
            "After selectGroups(), group2 was incorrectly altered")
        self.assertEquals(
            group2["group2Only"], "group2OnlyValue",
            "After selectGroups(), group2 was incorrectly altered")
Ejemplo n.º 10
0
 def test_determineOutputPath1(self):
     option = options.Options()
     option.buildDir = "."
     targets = target.Target("foo", "/bar/paz")
     targets.outputPathSpecified = True
     targets.outputPath = "/outputPath"
     targets.outputPath = targets.determineOutputPath(option)
     self.assertEquals(
         targets.outputPath, "/outputPath",
         "Specified output path was overwritten by determineOutputPath.")
Ejemplo n.º 11
0
 def test_processCommandline20(self):
     testOptions = options.Options()
     commandline = "MixDown --import -lconsole"
     self.assertEquals(
         testOptions.processCommandline(commandline.split(" ")), False,
         "Command-line should not have processed correctly")
     self.assertEquals(testOptions.targetsToImport, [],
                       "targetsToImport should have not been set")
     self.assertEquals(testOptions.logger, "file",
                       "logger should not have been set")
Ejemplo n.º 12
0
 def test_processCommandline18(self):
     testOptions = options.Options()
     commandline = "MixDown --import -btest"
     self.assertEquals(
         testOptions.processCommandline(commandline.split(" ")), False,
         "Command-line should not have processed correctly")
     self.assertEquals(testOptions.targetsToImport, [],
                       "targetsToImport should have not been set")
     self.assertEquals(testOptions.buildDir, "mdBuild",
                       "buildDir should not have been set")
Ejemplo n.º 13
0
 def test_processCommandline16(self):
     testOptions = options.Options()
     commandline = "MixDown --import -v"
     self.assertEquals(
         testOptions.processCommandline(commandline.split(" ")), False,
         "Command-line should not have processed correctly")
     self.assertEquals(testOptions.targetsToImport, [],
                       "targetsToImport should have not been set")
     self.assertEquals(testOptions.verbose, True,
                       "verbose should have been set")
Ejemplo n.º 14
0
 def test_processCommandline14(self):
     testOptions = options.Options()
     commandline = "MixDown --import -sapr:preconfig"
     self.assertEquals(
         testOptions.processCommandline(commandline.split(" ")), False,
         "Command-line should not have processed correctly")
     self.assertEquals(testOptions.targetsToImport, [],
                       "targetsToImport should have not been set")
     self.assertEquals(testOptions.skipSteps, "",
                       "skipSteps should not have been set")
Ejemplo n.º 15
0
    def test_selectGroups01(self):
        mdOptions = options.Options()
        mdOptions.compilerGroupName = "compiler1"
        mdOptions.optimizationGroupName = "optimization1"
        mdOptions.parallelGroupName = "*"
        mdOptions.overrideFile = "testNOREALFILE"

        groupList = []

        group1 = overrides.OverrideGroup()
        group1.compiler = "compiler1"
        group1.optimization = "*"
        group1.parallel = "*"
        group1["test"] = "value1"
        group1["group1Only"] = "group1OnlyValue"
        groupList.append(group1)

        group2 = overrides.OverrideGroup()
        group2.compiler = "compiler1"
        group2.optimization = "optimization1"
        group2.parallel = "*"
        group2["test"] = "value2"
        group2["group2Only"] = "group2OnlyValue"
        groupList.append(group2)

        finalGroup = overrides.selectGroups(groupList, mdOptions)
        self.assertNotEquals(finalGroup, None,
                             "selectGroups() failed to return a group")
        self.assertEquals(fullCount(finalGroup), 3,
                          "After selectGroups() override count was wrong")
        self.assertEquals(
            "test" in finalGroup, True,
            "After selectGroups() did not returned correct value")
        self.assertEquals(
            finalGroup["test"], "value2",
            "After selectGroups() did not returned correct value")
        self.assertEquals(
            "group1Only" in finalGroup, True,
            "After selectGroups() did not returned correct value")
        self.assertEquals(
            finalGroup["group1Only"], "group1OnlyValue",
            "After selectGroups() did not returned correct value")
        self.assertEquals(
            "group2Only" in finalGroup, True,
            "After selectGroups() did not returned correct value")
        self.assertEquals(
            finalGroup["group2Only"], "group2OnlyValue",
            "After selectGroups() did not returned correct value")
        self.assertEquals(
            "test" in finalGroup, True,
            "After selectGroups() did not returned correct value")
        self.assertEquals(
            finalGroup["test"], "value2",
            "After selectGroups() did not returned correct value")
Ejemplo n.º 16
0
 def test_processCommandline21(self):
     testOptions = options.Options()
     commandline = "MixDown --import -ptest"
     self.assertEquals(
         testOptions.processCommandline(commandline.split(" ")), False,
         "Command-line should not have processed correctly")
     self.assertEquals(testOptions.targetsToImport, [],
                       "targetsToImport should have not been set")
     self.assertEquals(
         testOptions.defines[defines.surround(defines.mdPrefix[0])],
         "/usr/local", "prefix should not have been set")
Ejemplo n.º 17
0
 def test_processCommandline19(self):
     testOptions = options.Options()
     commandline = "MixDown --import -j9"
     self.assertEquals(
         testOptions.processCommandline(commandline.split(" ")), False,
         "Command-line should not have processed correctly")
     self.assertEquals(testOptions.targetsToImport, [],
                       "targetsToImport should have not been set")
     self.assertEquals(
         testOptions.defines[defines.surround(defines.mdJobSlots[0])], "",
         "cleanMixDown should not have been set")
Ejemplo n.º 18
0
    def test_validate01(self):
        try:
            tempDir = mdTestUtilities.makeTempDir()
            projectFilePath = os.path.join(tempDir, "test.md")
            mdTestUtilities.createBlankFile(projectFilePath)

            testOptions = options.Options()
            commandline = "MixDown " + projectFilePath + " -ptestPrefix -v -otestOverrides -ggcc,debug,parallel"
            self.assertEquals(
                testOptions.processCommandline(commandline.split(" ")), True,
                "Command-line should have processed correctly")
            self.assertEquals(testOptions.validate(), True,
                              "Command-line options should have validated")
        finally:
            utilityFunctions.removeDir(tempDir)
Ejemplo n.º 19
0
    def test_processCommandline09(self):
        try:
            tempDir = mdTestUtilities.makeTempDir()
            tarDir, tarFile = mdTestUtilities.createTarFile(tempDir)
            tarPath = os.path.join(tempDir, tarFile)

            testOptions = options.Options()
            commandline = "MixDown " + tarPath + " --import --clean"
            self.assertEquals(
                testOptions.processCommandline(commandline.split(" ")), False,
                "Command-line should not have processed correctly")
            self.assertEquals(testOptions.targetsToImport, [],
                              "targetsToImport should have not been set")
        finally:
            utilityFunctions.removeDir(tempDir)
Ejemplo n.º 20
0
 def test_determineOutputPath3(self):
     try:
         tempDir = mdTestUtilities.makeTempDir()
         targetDir = os.path.join(tempDir, "targetDir")
         os.makedirs(targetDir)
         option = options.Options()
         option.buildDir = "."
         option.cleanMode = True
         targets = target.Target("foo", targetDir)
         targets.outputPath = targets.determineOutputPath(option)
         self.assertEquals(
             targets.outputPath, targetDir,
             "During cleaning found target path should not be overwritten.")
     finally:
         utilityFunctions.removeDir(tempDir)
Ejemplo n.º 21
0
    def test_selectGroups11(self):
        mdOptions = options.Options()
        mdOptions.compilerGroupName = "compilerDOESNOTEXIST"
        mdOptions.optimizationGroupName = "optimizationDOESNOTEXIST"
        mdOptions.parallelGroupName = "parallelDOESNOTEXIST"
        mdOptions.overrideFile = "testNOREALFILE"

        groupList = []

        group1 = overrides.OverrideGroup()
        group1.compiler = "compiler1"
        group1.optimization = "*"
        group1.parallel = "*"
        group1["test"] = "value1"
        group1["group1Only"] = "group1OnlyValue"
        groupList.append(group1)

        group2 = overrides.OverrideGroup()
        group2.compiler = "compiler1"
        group2.optimization = "optimization1"
        group2.parallel = "*"
        group2["test"] = "value2"
        group2["group2Only"] = "group2OnlyValue"
        groupList.append(group2)

        group3 = overrides.OverrideGroup()
        group3.compiler = "compiler1"
        group3.optimization = "optimization1"
        group3.parallel = "parallel1"
        group3["test"] = "value3"
        group3["group2and3"] = "group2and3Value"
        group3["group3Only"] = "group3OnlyValue"
        groupList.append(group3)

        finalGroup = overrides.selectGroups(groupList, mdOptions)
        self.assertEquals(
            finalGroup, None,
            "selectGroups() should have failed to return a group")
Ejemplo n.º 22
0
 def test_processCommandline04(self):
     testOptions = options.Options()
     commandline = "MixDown"
     self.assertEquals(
         testOptions.processCommandline(commandline.split(" ")), False,
         "Command-line should not have processed correctly")
Ejemplo n.º 23
0
 def test_validate3(self):
     option = options.Options()
     targets = target.Target("", "/some/path")
     self.assertEquals(
         targets.validate(option), False,
         "False positive returned when trying to validate target.")
Ejemplo n.º 24
0
 def test_validate4(self):
     option = options.Options()
     targets = target.Target("foo", "/some/path")
     self.assertEquals(targets.validate(option), True,
                       "Target should have validated.")