Ejemplo n.º 1
0
    def testMacroOverrides(self):
        self.addTestPkg(1)
        repos = self.openRepository()
        loader = loadrecipe.recipeLoaderFromSourceComponent('test1:source', 
                                                           self.cfg, repos)[0]
        recipeClass = loader.getRecipe()
        self.overrideBuildFlavor('is:x86(!i686,!i586,i486)')
        use.setBuildFlagsFromFlavor('test1', self.cfg.buildFlavor)

        dummy = recipeClass(self.cfg, None, None, {})
        assert(dummy.macros.dummyMacro == 'right')
Ejemplo n.º 2
0
 def testMultipleAvailable(self):
     self.addComponent('simple:source', '/localhost@rpl:branch//linux/1.0', 
                      [ ('simple.recipe', recipes.simpleRecipe)])
     laterVersion = self.addComponent('simple:source', 
                                      '/localhost@rpl:branch2//linux/1.0',
                                      [('simple.recipe', recipes.simpleRecipe)]).getVersion()
     repos = self.openRepository()
     self.logFilter.add()
     loader, version = loadrecipe.recipeLoaderFromSourceComponent('simple', 
                                                self.cfg, repos,
                                                filterVersions=True,
                                                defaultToLatest=True)
     assert(version == laterVersion)
     # switching to getTroveLatestByLabel gets rid of this message.
     self.logFilter.compare([])
Ejemplo n.º 3
0
 def testMultipleAvailable(self):
     self.addComponent('simple:source', '/localhost@rpl:branch//linux/1.0',
                       [('simple.recipe', recipes.simpleRecipe)])
     laterVersion = self.addComponent(
         'simple:source', '/localhost@rpl:branch2//linux/1.0',
         [('simple.recipe', recipes.simpleRecipe)]).getVersion()
     repos = self.openRepository()
     self.logFilter.add()
     loader, version = loadrecipe.recipeLoaderFromSourceComponent(
         'simple',
         self.cfg,
         repos,
         filterVersions=True,
         defaultToLatest=True)
     assert (version == laterVersion)
     # switching to getTroveLatestByLabel gets rid of this message.
     self.logFilter.compare([])
Ejemplo n.º 4
0
    def testBasicMacros(self):
        oldPath = os.environ['PATH']
        try:
            self.addTestPkg(1)
            repos = self.openRepository()
            loader = loadrecipe.recipeLoaderFromSourceComponent('test1:source', 
                                                               self.cfg, repos)[0]
            recipeClass = loader.getRecipe()
            use.setBuildFlagsFromFlavor('test1', self.cfg.buildFlavor)

            # This should override the value from extraMacros
            self.cfg.configLine('macros thing value')
            # And this should override the default value
            self.cfg.configLine('macros bindir /binaries')

            recipeObj = recipeClass(self.cfg, None, None,
                extraMacros={'thing': 'wrong'})
            self.assertEqual(recipeObj.macros.name, 'test1')
            self.assertEqual(recipeObj.macros.version, '1.0')
            self.assertEqual(recipeObj.macros.bindir, '/binaries')
        finally:
            os.environ['PATH'] = oldPath
Ejemplo n.º 5
0
    def testCrossCompileSetupMacrosOverride(self):

        macroOverrides = {'crossdir' : 'foo'}
        oldPath = os.environ['PATH']
        try:
            self.addTestPkg(1)
            repos = self.openRepository()
            loader = loadrecipe.recipeLoaderFromSourceComponent('test1:source', 
                                                               self.cfg, repos)[0]
            recipeClass = loader.getRecipe()
            self.overrideBuildFlavor('is:x86(!i686,!i586,i486)')
            use.setBuildFlagsFromFlavor('test1', self.cfg.buildFlavor)

            # cross compiling something for x86_64
            cross1 = recipeClass(self.cfg, None, None, macroOverrides, 
                                 (None, 'x86_64', False))

            assert(cross1.macros.target == 'x86_64-unknown-linux')
            assert(cross1.macros.host == 'x86_64-unknown-linux')
            assert(cross1.macros.build == 'i486-unknown-linux')
            assert(use.Arch.x86_64)
            assert(cross1.macros.crossprefix == '/opt/foo')
        finally:
            os.environ['PATH'] = oldPath
Ejemplo n.º 6
0
    def testCrossCompileSetup(self):
        siteConfigPath = os.path.abspath(resources.get_archive('site'))
        def _checkSite(macros, *paths):
            self.assertEquals(macros.env_siteconfig,
                          ' '.join([siteConfigPath + '/' + x for x in paths]))

        self.cfg.siteConfigPath = [ siteConfigPath]
        oldPath = os.environ['PATH']
        try:
            self.addTestPkg(1)
            repos = self.openRepository()
            if 'CONFIG_SITE' in os.environ: del os.environ['CONFIG_SITE']
            loader = loadrecipe.recipeLoaderFromSourceComponent('test1:source', 
                                                               self.cfg, repos)[0]
            recipeClass = loader.getRecipe()
            self.overrideBuildFlavor('is:x86(!i686,!i586,i486)')
            use.setBuildFlagsFromFlavor('test1', self.cfg.buildFlavor)

            nocross = recipeClass(self.cfg, None, None, {})
            assert(nocross.macros.target == 'i486-unknown-linux')
            assert(nocross.macros.host == 'i486-unknown-linux')
            assert(nocross.macros.build == 'i486-unknown-linux')
            assert(not nocross.isCrossCompiling())
            assert(not nocross.isCrossCompileTool())
            assert(not nocross.needsCrossFlags())

            if 'CONFIG_SITE' in os.environ: del os.environ['CONFIG_SITE']
            use.setBuildFlagsFromFlavor('test1', self.cfg.buildFlavor)

            try:
                invalid = recipeClass(self.cfg, None, None, {}, (None, '((', False))
            except errors.CookError:
                pass

            # cross compiling something for x86_64
            cross1 = recipeClass(self.cfg, None, None, {}, (None, 'x86_64', False))

            assert(cross1.macros.target == 'x86_64-unknown-linux')
            assert(cross1.macros.host == 'x86_64-unknown-linux')
            assert(cross1.macros.build == 'i486-unknown-linux')
            assert(cross1.hostmacros.lib == 'lib64')
            assert(cross1.targetmacros.lib == 'lib64')
            assert(cross1.buildmacros.lib == 'lib')
            assert(cross1.macros.lib == 'lib64')
            assert(cross1.isCrossCompiling())
            assert(not cross1.isCrossCompileTool())
            assert(cross1.needsCrossFlags())
            assert(use.Arch.x86_64)
            _checkSite(cross1.macros, 'x86_64', 'linux')
            _checkSite(cross1.buildmacros, 'x86', 'linux')
            _checkSite(cross1.hostmacros, 'x86_64', 'linux')

            if 'CONFIG_SITE' in os.environ: del os.environ['CONFIG_SITE']
            use.setBuildFlagsFromFlavor('test1', self.cfg.buildFlavor)

            # building a cross compiling tool for i686
            cross2 = recipeClass(self.cfg, None, None, {}, (None, 'x86(i686)', 
                                                                        True))
            assert(cross2.macros.target == 'i686-unknown-linux')
            assert(cross2.macros.host == 'i486-unknown-linux')
            # note the added _build here to differentiate host from build
            assert(cross2.macros.build == 'i486-unknown_build-linux')
            assert(use.Arch.x86.i686)

            # building a cross-compiler on i386 to run on x86_64 to compile
            # for ppc

            use.setBuildFlagsFromFlavor('test1', self.cfg.buildFlavor)
            if 'CONFIG_SITE' in os.environ: del os.environ['CONFIG_SITE']
            cross3 = recipeClass(self.cfg, None, None, {}, ('x86_64', 'ppc',
                                                                        True))
            assert(cross3.macros.target == 'powerpc-unknown-linux')
            assert(cross3.macros.host == 'x86_64-unknown-linux')
            assert(cross3.macros.build == 'i486-unknown-linux')
            assert(cross3.macros.cc == 'i486-unknown-linux-gcc')
            assert(cross3.macros.cxx == 'i486-unknown-linux-g++')
            # this is a cross-tool, so we're building for the system machine
            # so buildcc == cc
            assert(cross3.macros.buildcc == 'i486-unknown-linux-gcc')
            assert(cross3.macros.buildcxx == 'i486-unknown-linux-g++')
            assert(cross3.macros.lib == 'lib')
            assert(cross3.hostmacros.lib == 'lib64')
            assert(cross3.targetmacros.lib == 'lib')
            assert(cross3.buildmacros.lib == 'lib')
            assert(use.Arch.x86_64)

            assert(not cross3.isCrossCompiling())
            assert(cross3.isCrossCompileTool())
            assert(cross3.needsCrossFlags())

            # When creating a cross compiler for a ppc system
            # on an x86_64 box, configure should return results for the x86_64
            # box, not the target arch.
            _checkSite(cross3.macros, 'x86_64', 'linux')
            _checkSite(cross3.buildmacros, 'x86', 'linux')
            _checkSite(cross3.hostmacros, 'x86_64', 'linux')

            # cross compiling for i486 on i486
            # buildcc should have /usr/bin/ in front
            use.setBuildFlagsFromFlavor('test1', self.cfg.buildFlavor)
            if 'CONFIG_SITE' in os.environ: del os.environ['CONFIG_SITE']
            cross4 = recipeClass(self.cfg, None, None, {}, (None, 'x86(i486)', False))
            assert(cross4.macros.target == 'i486-unknown-linux')
            assert(cross4.macros.host == 'i486-unknown-linux')
            assert(cross4.macros.build == 'i486-unknown_build-linux')
            assert(cross4.macros.buildcc == '/usr/bin/i486-unknown-linux-gcc')
            assert(cross4.macros.buildcxx == '/usr/bin/i486-unknown-linux-g++')
            assert(cross4.macros.cc == 'i486-unknown-linux-gcc')
            assert(cross4.macros.cxx == 'i486-unknown-linux-g++')

        finally:
            os.environ['PATH'] = oldPath