def testAutounmaskMultilibUse(self): self.todo = True ebuilds = { "x11-proto/xextproto-7.2.1-r1": {"EAPI": "5", "IUSE": "abi_x86_32 abi_x86_64"}, "x11-libs/libXaw-1.0.11-r2": { "EAPI": "5", "IUSE": "abi_x86_32 abi_x86_64", "RDEPEND": "x11-proto/xextproto[abi_x86_32(-)?,abi_x86_64(-)?]", }, "app-emulation/emul-linux-x86-xlibs-20130224-r2": {"EAPI": "5", "RDEPEND": "x11-libs/libXaw[abi_x86_32]"}, "games-util/steam-client-meta-0-r20130514": {"EAPI": "5", "RDEPEND": "app-emulation/emul-linux-x86-xlibs"}, } installed = { "x11-proto/xextproto-7.2.1-r1": { "EAPI": "5", "IUSE": "abi_x86_32 abi_x86_64", "USE": "abi_x86_32 abi_x86_64", }, "x11-libs/libXaw-1.0.11-r2": { "EAPI": "5", "IUSE": "abi_x86_32 abi_x86_64", "RDEPEND": "x11-proto/xextproto[abi_x86_32(-)?,abi_x86_64(-)?]", "USE": "abi_x86_32 abi_x86_64", }, "app-emulation/emul-linux-x86-xlibs-20130224-r2": {"EAPI": "5", "RDEPEND": "x11-libs/libXaw[abi_x86_32]"}, "games-util/steam-client-meta-0-r20130514": {"EAPI": "5", "RDEPEND": "app-emulation/emul-linux-x86-xlibs"}, } user_config = { # "make.conf" : ("USE=\"abi_x86_32 abi_x86_64\"",) "make.conf": ('USE="abi_x86_64"',) } world = ("games-util/steam-client-meta",) test_cases = ( # Test autounmask solving of multilib use deps for bug #481628. # We would like it to suggest some USE changes, but instead it # currently fails with a SLOT conflict. ResolverPlaygroundTestCase( ["x11-proto/xextproto", "x11-libs/libXaw"], options={"--oneshot": True, "--autounmask": True, "--backtrack": 30}, mergelist=["x11-proto/xextproto-7.2.1-r1", "x11-libs/libXaw-1.0.11-r2"], success=True, ), ) playground = ResolverPlayground( ebuilds=ebuilds, installed=installed, user_config=user_config, world=world, debug=False ) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testBacktrackingGoodVersionFirst(self): """ When backtracking due to slot conflicts, we masked the version that has been pulled in first. This is not always a good idea. Mask the highest version instead. """ ebuilds = { "dev-libs/A-1": { "DEPEND": "=dev-libs/C-1 dev-libs/B" }, "dev-libs/B-1": { "DEPEND": "=dev-libs/C-1" }, "dev-libs/B-2": { "DEPEND": "=dev-libs/C-2" }, "dev-libs/C-1": { }, "dev-libs/C-2": { }, } test_cases = ( ResolverPlaygroundTestCase( ["dev-libs/A"], mergelist = ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", ], success = True), ) playground = ResolverPlayground(ebuilds=ebuilds) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testFeaturesMutation(self): """ Test whether mutation of config.features updates the FEATURES variable and persists through config.regenerate() calls. """ playground = ResolverPlayground() try: settings = config(clone=playground.settings) settings.features.add('noclean') self.assertEqual('noclean' in settings['FEATURES'].split(), True) settings.regenerate() self.assertEqual('noclean' in settings['FEATURES'].split(),True) settings.features.discard('noclean') self.assertEqual('noclean' in settings['FEATURES'].split(), False) settings.regenerate() self.assertEqual('noclean' in settings['FEATURES'].split(), False) settings.features.add('noclean') self.assertEqual('noclean' in settings['FEATURES'].split(), True) settings.regenerate() self.assertEqual('noclean' in settings['FEATURES'].split(),True) finally: playground.cleanup()
def testSimpleDepclean(self): ebuilds = { "dev-libs/A-1": {}, "dev-libs/B-1": {}, } installed = { "dev-libs/A-1": {}, "dev-libs/B-1": {}, } world = ( "dev-libs/A", ) test_cases = ( ResolverPlaygroundTestCase( [], options={"--depclean": True}, success=True, cleanlist=["dev-libs/B-1"]), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testBacktrackNotNeeded(self): ebuilds = { "dev-libs/A-1": {}, "dev-libs/A-2": {}, "dev-libs/B-1": {}, "dev-libs/B-2": {}, "dev-libs/C-1": {"DEPEND": "dev-libs/A dev-libs/B"}, "dev-libs/D-1": {"DEPEND": "=dev-libs/A-1 =dev-libs/B-1"}, } test_cases = ( ResolverPlaygroundTestCase( ["dev-libs/C", "dev-libs/D"], all_permutations=True, options={"--backtrack": 1}, mergelist=["dev-libs/A-1", "dev-libs/B-1", "dev-libs/C-1", "dev-libs/D-1"], ignore_mergelist_order=True, success=True, ), ) playground = ResolverPlayground(ebuilds=ebuilds) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testWithTestDeps(self): ebuilds = { "app-misc/A-0": { "EAPI": "5", "IUSE": "test", "DEPEND": "test? ( app-misc/B )" }, "app-misc/B-0": { "EAPI": "5", "IUSE": "test", "DEPEND": "test? ( app-misc/C )" }, "app-misc/C-0": { "EAPI": "5", } } test_cases = ( # Test that --with-test-deps only pulls in direct # test deps of packages matched by arguments. ResolverPlaygroundTestCase( ["app-misc/A"], success = True, options = { "--onlydeps": True, "--with-test-deps": True }, mergelist = ["app-misc/B-0"]), ) playground = ResolverPlayground(ebuilds=ebuilds, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testSetCpv(self): """ Test the clone via constructor. """ ebuilds = { "dev-libs/A-1": {"IUSE": "static-libs"}, "dev-libs/B-1": {"IUSE": "static-libs"}, } env_files = { "A" : ("USE=\"static-libs\"",) } package_env = ( "dev-libs/A A", ) eprefix = normalize_path(tempfile.mkdtemp()) playground = None try: user_config_dir = os.path.join(eprefix, USER_CONFIG_PATH) os.makedirs(user_config_dir) with io.open(os.path.join(user_config_dir, "package.env"), mode='w', encoding=_encodings['content']) as f: for line in package_env: f.write(line + "\n") env_dir = os.path.join(user_config_dir, "env") os.makedirs(env_dir) for k, v in env_files.items(): with io.open(os.path.join(env_dir, k), mode='w', encoding=_encodings['content']) as f: for line in v: f.write(line + "\n") playground = ResolverPlayground(eprefix=eprefix, ebuilds=ebuilds) settings = config(clone=playground.settings) result = playground.run(["=dev-libs/A-1"]) pkg, existing_node = result.depgraph._select_package( playground.eroot, Atom("=dev-libs/A-1")) settings.setcpv(pkg) self.assertTrue("static-libs" in settings["PORTAGE_USE"].split()) # Test bug #522362, where a USE=static-libs package.env # setting leaked from one setcpv call to the next. pkg, existing_node = result.depgraph._select_package( playground.eroot, Atom("=dev-libs/B-1")) settings.setcpv(pkg) self.assertTrue("static-libs" not in settings["PORTAGE_USE"].split()) finally: if playground is None: shutil.rmtree(eprefix) else: playground.cleanup()
def testBacktrackNoWrongRebuilds(self): """ Ensure we remove backtrack masks if the reason for the mask gets masked itself. """ ebuilds = { "dev-libs/A-1": {}, "dev-libs/A-2": {}, "dev-libs/B-1": {"RDEPEND": "dev-libs/D"}, "dev-libs/C-1": {}, "dev-libs/C-2": {"RDEPEND": ">=dev-libs/A-2"}, "dev-libs/D-1": {"RDEPEND": "<dev-libs/A-2"}, } installed = { "dev-libs/A-1": {}, "dev-libs/B-1": {"RDEPEND": "dev-libs/D"}, "dev-libs/C-1": {}, "dev-libs/D-1": {"RDEPEND": "<dev-libs/A-2"}, } world = ["dev-libs/B", "dev-libs/C"] options = {"--update": True, "--deep": True, "--selective": True} test_cases = (ResolverPlaygroundTestCase(["@world"], options=options, mergelist=[], success=True),) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testAutounmaskParentUse(self): ebuilds = { "dev-libs/B-1": { "EAPI": "5", "DEPEND": "dev-libs/D[foo(-)?,bar(-)?]", "IUSE": "+bar +foo", }, "dev-libs/D-1": {}, } test_cases = ( # Test bug 566704 ResolverPlaygroundTestCase( ["=dev-libs/B-1"], options={"--autounmask": True}, success=False, use_changes={ "dev-libs/B-1": { "foo": False, "bar": False, } }), ) playground = ResolverPlayground(ebuilds=ebuilds) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testOnlydeps(self): ebuilds = { "dev-libs/A-1": { "DEPEND": "dev-libs/B" }, "dev-libs/B-1": { }, } installed = { "dev-libs/B-1": { }, } test_cases = ( ResolverPlaygroundTestCase( ["dev-libs/A", "dev-libs/B"], all_permutations = True, success = True, options = { "--onlydeps": True }, mergelist = ["dev-libs/B-1"]), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testPackageMaskOrder(self): ebuilds = {"dev-libs/A-1": {}, "dev-libs/B-1": {}, "dev-libs/C-1": {}, "dev-libs/D-1": {}, "dev-libs/E-1": {}} repo_configs = {"test_repo": {"package.mask": ("dev-libs/A", "dev-libs/C")}} profile = {"package.mask": ("-dev-libs/A", "dev-libs/B", "-dev-libs/B", "dev-libs/D")} user_config = {"package.mask": ("-dev-libs/C", "-dev-libs/D", "dev-libs/E")} test_cases = ( ResolverPlaygroundTestCase(["dev-libs/A"], options={"--autounmask": "n"}, success=False), ResolverPlaygroundTestCase(["dev-libs/B"], success=True, mergelist=["dev-libs/B-1"]), ResolverPlaygroundTestCase(["dev-libs/C"], success=True, mergelist=["dev-libs/C-1"]), ResolverPlaygroundTestCase(["dev-libs/D"], success=True, mergelist=["dev-libs/D-1"]), ResolverPlaygroundTestCase(["dev-libs/E"], options={"--autounmask": "n"}, success=False), ) playground = ResolverPlayground( ebuilds=ebuilds, repo_configs=repo_configs, profile=profile, user_config=user_config ) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testUseDepDefaultse(self): ebuilds = { "dev-libs/A-1": { "DEPEND": "dev-libs/B[foo]", "RDEPEND": "dev-libs/B[foo]", "EAPI": "2" }, "dev-libs/A-2": { "DEPEND": "dev-libs/B[foo(+)]", "RDEPEND": "dev-libs/B[foo(+)]", "EAPI": "4" }, "dev-libs/A-3": { "DEPEND": "dev-libs/B[foo(-)]", "RDEPEND": "dev-libs/B[foo(-)]", "EAPI": "4" }, "dev-libs/B-1": { "IUSE": "+foo", "EAPI": "1" }, "dev-libs/B-2": {}, } test_cases = ( ResolverPlaygroundTestCase( ["=dev-libs/A-1"], success = True, mergelist = ["dev-libs/B-1", "dev-libs/A-1"]), ResolverPlaygroundTestCase( ["=dev-libs/A-2"], success = True, mergelist = ["dev-libs/B-2", "dev-libs/A-2"]), ResolverPlaygroundTestCase( ["=dev-libs/A-3"], success = True, mergelist = ["dev-libs/B-1", "dev-libs/A-3"]), ) playground = ResolverPlayground(ebuilds=ebuilds) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testSelfDEPENDRemovalCrash(self): """ Make sure we don't try to remove a packages twice. This happened in the past when a package had a DEPEND on itself. """ ebuilds = { "dev-libs/A-1": { "RDEPEND": "=dev-libs/X-1" }, "dev-libs/B-1": { "RDEPEND": "dev-libs/X" }, "dev-libs/X-1": { }, "dev-libs/X-2": { "DEPEND": ">=dev-libs/X-2" }, } test_cases = ( ResolverPlaygroundTestCase( ["dev-libs/A", "dev-libs/B"], all_permutations = True, success = True, ignore_mergelist_order = True, mergelist = ["dev-libs/X-1", "dev-libs/A-1", "dev-libs/B-1"]), ) playground = ResolverPlayground(ebuilds=ebuilds, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testOldDepChainDisplay(self): ebuilds = { "dev-libs/A-1": { "DEPEND": "foo? ( dev-libs/B[-bar] )", "IUSE": "+foo", "EAPI": "2" }, "dev-libs/A-2": { "DEPEND": "foo? ( dev-libs/C )", "IUSE": "+foo", "EAPI": "1" }, "dev-libs/B-1": { "IUSE": "bar", "DEPEND": "!bar? ( dev-libs/D[-baz] )", "EAPI": "2" }, "dev-libs/C-1": { "KEYWORDS": "~x86" }, "dev-libs/D-1": { "IUSE": "+baz", "EAPI": "1" }, } test_cases = ( ResolverPlaygroundTestCase( ["=dev-libs/A-1"], options = { "--autounmask": 'n' }, success = False), ResolverPlaygroundTestCase( ["=dev-libs/A-2"], options = { "--autounmask": 'n' }, success = False), ) playground = ResolverPlayground(ebuilds=ebuilds) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testSlotChangeWithoutRevBump(self): ebuilds = { "app-arch/libarchive-3.1.1" : { "EAPI": "5", "SLOT": "0/13" }, "app-arch/libarchive-3.0.4-r1" : { "EAPI": "5", "SLOT": "0" }, "kde-base/ark-4.10.0" : { "EAPI": "5", "DEPEND": "app-arch/libarchive:=", "RDEPEND": "app-arch/libarchive:=" }, } binpkgs = { "app-arch/libarchive-3.1.1" : { "EAPI": "5", "SLOT": "0" }, } installed = { "app-arch/libarchive-3.1.1" : { "EAPI": "5", "SLOT": "0" }, "kde-base/ark-4.10.0" : { "EAPI": "5", "DEPEND": "app-arch/libarchive:0/0=", "RDEPEND": "app-arch/libarchive:0/0=" }, } world = ["kde-base/ark"] test_cases = ( # Demonstrate bug #456208, where a sub-slot change # without revbump needs to trigger a rebuild. ResolverPlaygroundTestCase( ["kde-base/ark"], options = {"--oneshot": True, "--usepkg": True}, success = True, mergelist = ['app-arch/libarchive-3.1.1', "kde-base/ark-4.10.0"]), ) playground = ResolverPlayground(ebuilds=ebuilds, binpkgs=binpkgs, installed=installed, world=world, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testDirectVirtualCircularDependency(self): # Bug #384107 self.todo = True ebuilds = { "dev-java/icedtea-6.1.10.3": { "SLOT" : "6", "DEPEND": "virtual/jdk" }, "dev-java/icedtea6-bin-1.10.3": {}, "virtual/jdk-1.6.0": { "SLOT" : "1.6", "RDEPEND": "|| ( dev-java/icedtea6-bin =dev-java/icedtea-6* )" }, } test_cases = ( # Automatically pull in icedtea6-bin to solve a circular dep ResolverPlaygroundTestCase( ["dev-java/icedtea"], mergelist = ["dev-java/icedtea6-bin-1.10.3", "virtual/jdk-1.6.0", "dev-java/icedtea-6.1.10.3"], success = True, ), ) playground = ResolverPlayground(ebuilds=ebuilds) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testBacktrackWithoutUpdates(self): """ If --update is not given we might have to mask the old installed version later. """ ebuilds = { "dev-libs/A-1": { "DEPEND": "dev-libs/Z" }, "dev-libs/B-1": { "DEPEND": ">=dev-libs/Z-2" }, "dev-libs/Z-1": { }, "dev-libs/Z-2": { }, } installed = { "dev-libs/Z-1": { "USE": "" }, } test_cases = ( ResolverPlaygroundTestCase( ["dev-libs/B", "dev-libs/A"], all_permutations = True, mergelist = ["dev-libs/Z-2", "dev-libs/B-1", "dev-libs/A-1", ], ignore_mergelist_order = True, success = True), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testBacktrackMissedUpdates(self): """ An update is missed due to a dependency on an older version. """ ebuilds = { "dev-libs/A-1": { }, "dev-libs/A-2": { }, "dev-libs/B-1": { "RDEPEND": "<=dev-libs/A-1" }, } installed = { "dev-libs/A-1": { "USE": "" }, "dev-libs/B-1": { "USE": "", "RDEPEND": "<=dev-libs/A-1" }, } options = {'--update' : True, '--deep' : True, '--selective' : True} test_cases = ( ResolverPlaygroundTestCase( ["dev-libs/A", "dev-libs/B"], options = options, all_permutations = True, mergelist = [], success = True), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testHittingTheBacktrackLimit(self): ebuilds = { "dev-libs/A-1": {}, "dev-libs/A-2": {}, "dev-libs/B-1": {}, "dev-libs/B-2": {}, "dev-libs/C-1": { "DEPEND": "dev-libs/A dev-libs/B" }, "dev-libs/D-1": { "DEPEND": "=dev-libs/A-1 =dev-libs/B-1" }, } test_cases = ( ResolverPlaygroundTestCase( ["dev-libs/C", "dev-libs/D"], all_permutations = True, mergelist = ["dev-libs/A-1", "dev-libs/B-1", "dev-libs/C-1", "dev-libs/D-1"], ignore_mergelist_order = True, success = True), #This one hits the backtrack limit. Be aware that this depends on the argument order. ResolverPlaygroundTestCase( ["dev-libs/D", "dev-libs/C"], options = { "--backtrack": 1 }, mergelist = ["dev-libs/A-1", "dev-libs/B-1", "dev-libs/A-2", "dev-libs/B-2", "dev-libs/C-1", "dev-libs/D-1"], ignore_mergelist_order = True, slot_collision_solutions = [], success = False), ) playground = ResolverPlayground(ebuilds=ebuilds) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testDepcleanInstalledKeywordMaskedSlot(self): """ Verify that depclean removes newer slot masked by KEYWORDS (see bug #350285). """ ebuilds = { "dev-libs/A-1": { "RDEPEND": "|| ( =dev-libs/B-2.7* =dev-libs/B-2.6* )" }, "dev-libs/B-2.6": { "SLOT":"2.6", "KEYWORDS": "x86" }, "dev-libs/B-2.7": { "SLOT":"2.7", "KEYWORDS": "~x86" }, } installed = { "dev-libs/A-1": { "EAPI" : "3", "RDEPEND": "|| ( dev-libs/B:2.7 dev-libs/B:2.6 )" }, "dev-libs/B-2.6": { "SLOT":"2.6", "KEYWORDS": "x86" }, "dev-libs/B-2.7": { "SLOT":"2.7", "KEYWORDS": "~x86" }, } world = ( "dev-libs/A", ) test_cases = ( ResolverPlaygroundTestCase( [], options={"--depclean": True}, success=True, cleanlist=["dev-libs/B-2.7"]), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testConnectedCollision(self): """ Ensure that we are able to solve connected slot conflicts which cannot be solved each on their own. """ ebuilds = { "dev-libs/A-1": { "RDEPEND": "=dev-libs/X-1" }, "dev-libs/B-1": { "RDEPEND": "dev-libs/X" }, "dev-libs/X-1": { "RDEPEND": "=dev-libs/Y-1" }, "dev-libs/X-2": { "RDEPEND": "=dev-libs/Y-2" }, "dev-libs/Y-1": { "PDEPEND": "=dev-libs/X-1" }, "dev-libs/Y-2": { "PDEPEND": "=dev-libs/X-2" }, } test_cases = ( ResolverPlaygroundTestCase( ["dev-libs/A", "dev-libs/B"], all_permutations = True, options = { "--backtrack": 0 }, success = True, ambiguous_merge_order = True, mergelist = ["dev-libs/Y-1", "dev-libs/X-1", ("dev-libs/A-1", "dev-libs/B-1")]), ) playground = ResolverPlayground(ebuilds=ebuilds, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testCompeteIfNewSubSlotWithoutRevBump(self): ebuilds = { "media-libs/libpng-1.5.14": {"EAPI": "5", "SLOT": "0"}, "x11-libs/gdk-pixbuf-2.26.5": { "EAPI": "5", "DEPEND": ">=media-libs/libpng-1.4:=", "RDEPEND": ">=media-libs/libpng-1.4:=", }, } binpkgs = { "x11-libs/gdk-pixbuf-2.26.5": { "EAPI": "5", "DEPEND": ">=media-libs/libpng-1.4:0/15=", "RDEPEND": ">=media-libs/libpng-1.4:0/15=", }, } installed = { "media-libs/libpng-1.5.14": {"EAPI": "5", "SLOT": "0/15"}, "x11-libs/gdk-pixbuf-2.26.5": { "EAPI": "5", "DEPEND": ">=media-libs/libpng-1.4:0/15=", "RDEPEND": ">=media-libs/libpng-1.4:0/15=", }, } world = ["x11-libs/gdk-pixbuf"] test_cases = ( # Test that --complete-graph-if-new-ver=y triggers rebuild # when the sub-slot changes without a revbump. ResolverPlaygroundTestCase( ["media-libs/libpng"], options={ "--oneshot": True, "--complete-graph-if-new-ver": "y", "--rebuild-if-new-slot": "n", "--usepkg": True, }, success=True, mergelist=["media-libs/libpng-1.5.14", "x11-libs/gdk-pixbuf-2.26.5"], ), ) playground = ResolverPlayground( ebuilds=ebuilds, binpkgs=binpkgs, installed=installed, world=world, debug=False, ) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testSonameUnsatisfiable(self): binpkgs = { "app-misc/A-1": { "EAPI": "5", "PROVIDES": "x86_32: libA.so.1", }, "app-misc/B-1": { "DEPEND": "app-misc/A", "RDEPEND": "app-misc/A", "REQUIRES": "x86_32: libA.so.2", }, "app-misc/B-0": { "DEPEND": "app-misc/A", "RDEPEND": "app-misc/A", "REQUIRES": "x86_32: libA.so.1", }, } installed = { "app-misc/A-1": { "EAPI": "5", "PROVIDES": "x86_32: libA.so.1", }, "app-misc/B-0": { "DEPEND": "app-misc/A", "RDEPEND": "app-misc/A", "REQUIRES": "x86_32: libA.so.1", }, } world = ["app-misc/B"] test_cases = ( # Skip update due to unsatisfied soname dependency. ResolverPlaygroundTestCase( ["@world"], options={ "--deep": True, "--ignore-soname-deps": "n", "--update": True, "--usepkgonly": True, }, success=True, mergelist=[], ), ) playground = ResolverPlayground( binpkgs=binpkgs, debug=False, installed=installed, world=world ) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: # Disable debug so that cleanup works. playground.debug = False playground.cleanup()
def testSlotOperatorUpdateProbeParentDowngrade(self): ebuilds = { "net-nds/openldap-2.4.40-r3": { "EAPI": "5", "RDEPEND": "<sys-libs/db-6.0:= " + \ "|| ( sys-libs/db:5.3 sys-libs/db:5.1 )" }, "net-nds/openldap-2.4.40": { "EAPI": "5", "RDEPEND": "sys-libs/db" }, "sys-libs/db-6.0": { "SLOT": "6.0", }, "sys-libs/db-5.3": { "SLOT": "5.3", }, } installed = { "net-nds/openldap-2.4.40-r3": { "EAPI": "5", "RDEPEND": "<sys-libs/db-6.0:5.3/5.3= " + \ "|| ( sys-libs/db:5.3 sys-libs/db:5.1 )" }, "sys-libs/db-6.0": { "SLOT": "6.0", }, "sys-libs/db-5.3": { "SLOT": "5.3", }, } world = ( "net-nds/openldap", ) test_cases = ( # bug 528610 - openldap rebuild was triggered # inappropriately, due to slot_operator_update_probe # selecting an inappropriate replacement parent of # a lower version than desired. ResolverPlaygroundTestCase( ["@world"], success = True, options = { "--update": True, "--deep": True }, mergelist = []), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def test_gpkg_symlink_path(self): if sys.version_info.major < 3: self.skipTest("Not support Python 2") playground = ResolverPlayground( user_config={ "make.conf": ('BINPKG_COMPRESS="none"',), } ) tmpdir = tempfile.mkdtemp() try: settings = playground.settings orig_full_path = os.path.join(tmpdir, "orig/") os.makedirs(orig_full_path) os.symlink( "aaaabbbb/ccccdddd/eeeeffff/gggghhhh/iiiijjjj/kkkkllll/" "mmmmnnnn/oooopppp/qqqqrrrr/sssstttt/uuuuvvvv/wwwwxxxx/" "yyyyzzzz/00001111/22223333/44445555/66667777/88889999/test", os.path.join(orig_full_path, "a_long_symlink"), ) gpkg_file_loc = os.path.join(tmpdir, "test.gpkg.tar") test_gpkg = gpkg(settings, "test", gpkg_file_loc) check_result = test_gpkg._check_pre_image_files( os.path.join(tmpdir, "orig") ) self.assertEqual(check_result, (0, 14, 166, 0, 0)) test_gpkg.compress(os.path.join(tmpdir, "orig"), {"meta": "test"}) with open(gpkg_file_loc, "rb") as container: # container self.assertEqual( test_gpkg._get_tar_format(container), tarfile.USTAR_FORMAT ) with tarfile.open(gpkg_file_loc, "r") as container: metadata = io.BytesIO(container.extractfile("test/metadata.tar").read()) self.assertEqual( test_gpkg._get_tar_format(metadata), tarfile.USTAR_FORMAT ) metadata.close() image = io.BytesIO(container.extractfile("test/image.tar").read()) self.assertEqual(test_gpkg._get_tar_format(image), tarfile.GNU_FORMAT) image.close() test_gpkg.decompress(os.path.join(tmpdir, "test")) r = compare_files( os.path.join(tmpdir, "orig/", "a_long_symlink"), os.path.join(tmpdir, "test/", "a_long_symlink"), skipped_types=("atime", "mtime", "ctime"), ) self.assertEqual(r, ()) finally: shutil.rmtree(tmpdir) playground.cleanup()
def testAutounmaskBinpkgUse(self): ebuilds = { "dev-libs/A-1": { "EAPI": "6", "DEPEND": "dev-libs/B[foo]", "RDEPEND": "dev-libs/B[foo]", }, "dev-libs/B-1": { "EAPI": "6", "IUSE": "foo", }, } binpkgs = { "dev-libs/A-1": { "EAPI": "6", "DEPEND": "dev-libs/B[foo]", "RDEPEND": "dev-libs/B[foo]", }, "dev-libs/B-1": { "EAPI": "6", "IUSE": "foo", "USE": "foo", }, } installed = {} test_cases = ( # Bug 619626: Test for unnecessary rebuild due # to rejection of binary packages that would # be acceptable after appplication of autounmask # USE changes. ResolverPlaygroundTestCase( ["dev-libs/A"], all_permutations=True, success=True, options={ "--usepkg": True, }, mergelist=[ "[binary]dev-libs/B-1", "[binary]dev-libs/A-1", ], use_changes={"dev-libs/B-1": { "foo": True }}, ), ) playground = ResolverPlayground(ebuilds=ebuilds, binpkgs=binpkgs, installed=installed, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.debug = False playground.cleanup()
def testDepcleanWithExclude(self): installed = { "dev-libs/A-1": {}, "dev-libs/B-1": { "RDEPEND": "dev-libs/A" }, } # depclean asserts non-empty @world set world = ["non-empty/world-set"] test_cases = ( # Without --exclude. ResolverPlaygroundTestCase( [], options={"--depclean": True}, success=True, cleanlist=["dev-libs/B-1", "dev-libs/A-1"], ), ResolverPlaygroundTestCase(["dev-libs/A"], options={"--depclean": True}, success=True, cleanlist=[]), ResolverPlaygroundTestCase( ["dev-libs/B"], options={"--depclean": True}, success=True, cleanlist=["dev-libs/B-1"], ), # With --exclude ResolverPlaygroundTestCase( [], options={ "--depclean": True, "--exclude": ["dev-libs/A"] }, success=True, cleanlist=["dev-libs/B-1"], ), ResolverPlaygroundTestCase( ["dev-libs/B"], options={ "--depclean": True, "--exclude": ["dev-libs/B"] }, success=True, cleanlist=[], ), ) playground = ResolverPlayground(installed=installed, world=world) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testOrChoicesLibpostproc(self): ebuilds = { "media-video/ffmpeg-0.10": { "EAPI": "5", "SLOT": "0.10" }, "media-video/ffmpeg-1.2.2": { "EAPI": "5", "SLOT": "0" }, "media-libs/libpostproc-0.8.0.20121125": { "EAPI": "5" }, "media-plugins/gst-plugins-ffmpeg-0.10.13_p201211-r1": { "EAPI": "5", "RDEPEND": "|| ( media-video/ffmpeg:0 media-libs/libpostproc )" }, } installed = { "media-video/ffmpeg-0.10": { "EAPI": "5", "SLOT": "0.10" }, "media-libs/libpostproc-0.8.0.20121125": { "EAPI": "5" }, "media-plugins/gst-plugins-ffmpeg-0.10.13_p201211-r1": { "EAPI": "5", "RDEPEND": "|| ( media-video/ffmpeg:0 media-libs/libpostproc )" }, } world = ["media-plugins/gst-plugins-ffmpeg"] test_cases = ( # Demonstrate that libpostproc is preferred # over ffmpeg:0 for bug #480736. ResolverPlaygroundTestCase(["@world"], options={ "--update": True, "--deep": True }, success=True, all_permutations=True, mergelist=[]), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def test_gpkg_missing_manifest_signature(self): if sys.version_info.major < 3: self.skipTest("Not support Python 2") playground = ResolverPlayground( user_config={ "make.conf": ( 'FEATURES="${FEATURES} binpkg-signing ' 'binpkg-request-signature"', 'BINPKG_FORMAT="gpkg"', ), }) tmpdir = tempfile.mkdtemp() try: settings = playground.settings gpg = GPG(settings) gpg.unlock() orig_full_path = os.path.join(tmpdir, "orig/") os.makedirs(orig_full_path) data = urandom(1048576) with open(os.path.join(orig_full_path, "data"), "wb") as f: f.write(data) binpkg_1 = gpkg(settings, "test", os.path.join(tmpdir, "test-1.gpkg.tar")) binpkg_1.compress(orig_full_path, {}) with tarfile.open(os.path.join(tmpdir, "test-1.gpkg.tar"), "r") as tar_1: with tarfile.open(os.path.join(tmpdir, "test-2.gpkg.tar"), "w") as tar_2: for f in tar_1.getmembers(): if f.name == "Manifest": manifest = tar_1.extractfile(f).read().decode( "UTF-8") manifest = manifest.replace( "-----BEGIN PGP SIGNATURE-----", "") manifest = manifest.replace( "-----END PGP SIGNATURE-----", "") manifest_data = io.BytesIO( manifest.encode("UTF-8")) manifest_data.seek(0, io.SEEK_END) f.size = manifest_data.tell() manifest_data.seek(0) tar_2.addfile(f, manifest_data) else: tar_2.addfile(f, tar_1.extractfile(f)) binpkg_2 = gpkg(settings, "test", os.path.join(tmpdir, "test-2.gpkg.tar")) self.assertRaises(InvalidSignature, binpkg_2.decompress, os.path.join(tmpdir, "test")) finally: shutil.rmtree(tmpdir) playground.cleanup()
def testDoebuildSpawn(self): playground = ResolverPlayground() try: settings = config(clone=playground.settings) cpv = 'sys-apps/portage-2.1' metadata = { 'EAPI' : '2', 'INHERITED' : 'python eutils', 'IUSE' : 'build doc epydoc python3 selinux', 'LICENSE' : 'GPL-2', 'PROVIDE' : 'virtual/portage', 'RDEPEND' : '>=app-shells/bash-3.2_p17 >=dev-lang/python-2.6', 'SLOT' : '0', } root_config = playground.trees[playground.eroot]['root_config'] pkg = Package(built=False, cpv=cpv, installed=False, metadata=metadata, root_config=root_config, type_name='ebuild') settings.setcpv(pkg) settings['PORTAGE_PYTHON'] = _python_interpreter settings['PORTAGE_BUILDDIR'] = os.path.join( settings['PORTAGE_TMPDIR'], cpv) settings['T'] = os.path.join( settings['PORTAGE_BUILDDIR'], 'temp') for x in ('PORTAGE_BUILDDIR', 'T'): os.makedirs(settings[x]) # Create a fake environment, to pretend as if the ebuild # has been sourced already. open(os.path.join(settings['T'], 'environment'), 'wb').close() scheduler = PollScheduler().sched_iface for phase in ('_internal_test',): # Test EbuildSpawnProcess by calling doebuild.spawn() with # returnpid=False. This case is no longer used by portage # internals since EbuildPhase is used instead and that passes # returnpid=True to doebuild.spawn(). rval = doebuild_spawn("%s %s" % (_shell_quote( os.path.join(settings["PORTAGE_BIN_PATH"], os.path.basename(EBUILD_SH_BINARY))), phase), settings, free=1) self.assertEqual(rval, os.EX_OK) ebuild_phase = EbuildPhase(background=False, phase=phase, scheduler=scheduler, settings=settings) ebuild_phase.start() ebuild_phase.wait() self.assertEqual(ebuild_phase.returncode, os.EX_OK) ebuild_phase = MiscFunctionsProcess(background=False, commands=['success_hooks'], scheduler=scheduler, settings=settings) ebuild_phase.start() ebuild_phase.wait() self.assertEqual(ebuild_phase.returncode, os.EX_OK) finally: playground.cleanup()
def testVirtualRust(self): ebuilds = { 'dev-lang/rust-1.19.0': {}, 'dev-lang/rust-1.23.0': {}, 'dev-lang/rust-bin-1.19.0': {}, 'virtual/rust-1.19.0': { 'RDEPEND': '|| ( =dev-lang/rust-1.19.0* =dev-lang/rust-bin-1.19.0* )' }, } installed = { 'dev-lang/rust-1.19.0': {}, 'virtual/rust-1.19.0': { 'RDEPEND': '|| ( =dev-lang/rust-1.19.0* =dev-lang/rust-bin-1.19.0* )' }, } world = ['virtual/rust'] test_cases = ( # Test bug 645416, where rust-bin-1.19.0 was pulled in # inappropriately due to the rust-1.23.0 update being # available. ResolverPlaygroundTestCase( ['virtual/rust'], options={'--update': True, '--deep': True}, success=True, mergelist=[] ), # Test upgrade to rust-1.23.0, which is only possible # if rust-bin-1.19.0 is installed in order to satisfy # virtual/rust-1.19.0. ResolverPlaygroundTestCase( ['=dev-lang/rust-1.23.0', 'virtual/rust'], options={'--update': True, '--deep': True}, all_permutations=True, success=True, ambiguous_merge_order=True, mergelist=( ( 'dev-lang/rust-1.23.0', 'dev-lang/rust-bin-1.19.0', ), ), ), ) playground = ResolverPlayground(debug=False, ebuilds=ebuilds, installed=installed, world=world) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.debug = False playground.cleanup()
def testFeaturesTestUse(self): ebuilds = { "dev-libs/A-1" : { "IUSE": "test" }, "dev-libs/B-1" : { "IUSE": "test foo" }, } installed = { "dev-libs/A-1" : { "USE": "", "IUSE": "test" }, "dev-libs/B-1" : { "USE": "foo", "IUSE": "test foo" }, } user_config = { "make.conf" : ("FEATURES=test", "USE=\"-test -foo\"") } test_cases = ( # USE=test state should not trigger --newuse rebuilds, as # specified in bug #373209, comment #3. ResolverPlaygroundTestCase( ["dev-libs/A"], options = {"--newuse": True, "--selective": True}, success = True, mergelist = []), # USE=-test -> USE=test, with USE=test forced by FEATURES=test ResolverPlaygroundTestCase( ["dev-libs/A"], options = {}, success = True, mergelist = ["dev-libs/A-1"]), # USE=foo -> USE=-foo, with USE=test forced by FEATURES=test ResolverPlaygroundTestCase( ["dev-libs/B"], options = {"--newuse": True, "--selective": True}, success = True, mergelist = ["dev-libs/B-1"]), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, user_config=user_config, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testAutounmaskAndSets(self): ebuilds = { #ebuilds to test use changes "dev-libs/A-1": { }, "dev-libs/A-2": { "KEYWORDS": "~x86" }, "dev-libs/B-1": { "DEPEND": "dev-libs/A" }, "dev-libs/C-1": { "DEPEND": ">=dev-libs/A-2" }, "dev-libs/D-1": { "DEPEND": "dev-libs/A" }, } world_sets = ["@test-set"] sets = { "test-set": ( "dev-libs/A", "dev-libs/B", "dev-libs/C", "dev-libs/D", ), } test_cases = ( #Test USE changes. #The simple case. ResolverPlaygroundTestCase( ["dev-libs/B", "dev-libs/C", "dev-libs/D"], all_permutations=True, options={"--autounmask": "y"}, mergelist=["dev-libs/A-2", "dev-libs/B-1", "dev-libs/C-1", "dev-libs/D-1"], ignore_mergelist_order=True, unstable_keywords=["dev-libs/A-2"], success=False), ResolverPlaygroundTestCase( ["@test-set"], all_permutations=True, options={"--autounmask": "y"}, mergelist=["dev-libs/A-2", "dev-libs/B-1", "dev-libs/C-1", "dev-libs/D-1"], ignore_mergelist_order=True, unstable_keywords=["dev-libs/A-2"], success=False), ResolverPlaygroundTestCase( ["@world"], all_permutations=True, options={"--autounmask": "y"}, mergelist=["dev-libs/A-2", "dev-libs/B-1", "dev-libs/C-1", "dev-libs/D-1"], ignore_mergelist_order=True, unstable_keywords=["dev-libs/A-2"], success=False), ) playground = ResolverPlayground(ebuilds=ebuilds, world_sets=world_sets, sets=sets) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testDepcleanWithDeps(self): ebuilds = { "dev-libs/A-1": { "RDEPEND": "dev-libs/C" }, "dev-libs/B-1": { "RDEPEND": "dev-libs/D" }, "dev-libs/C-1": {}, "dev-libs/D-1": { "RDEPEND": "dev-libs/E" }, "dev-libs/E-1": { "RDEPEND": "dev-libs/F" }, "dev-libs/F-1": {}, } installed = { "dev-libs/A-1": { "RDEPEND": "dev-libs/C" }, "dev-libs/B-1": { "RDEPEND": "dev-libs/D" }, "dev-libs/C-1": {}, "dev-libs/D-1": { "RDEPEND": "dev-libs/E" }, "dev-libs/E-1": { "RDEPEND": "dev-libs/F" }, "dev-libs/F-1": {}, } world = ("dev-libs/A", ) test_cases = (ResolverPlaygroundTestCase( [], options={"--depclean": True}, success=True, cleanlist=[ "dev-libs/B-1", "dev-libs/D-1", "dev-libs/E-1", "dev-libs/F-1", ], ), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testUnpackDependencies(self): distfiles = { "A-1.tar.gz": b"binary\0content", "B-1.TAR.XZ": b"binary\0content", "B-docs-1.tar.bz2": b"binary\0content", "C-1.TAR.XZ": b"binary\0content", "C-docs-1.tar.bz2": b"binary\0content", } ebuilds = { "dev-libs/A-1": {"SRC_URI": "A-1.tar.gz", "EAPI": "5-progress"}, "dev-libs/B-1": {"IUSE": "doc", "SRC_URI": "B-1.TAR.XZ doc? ( B-docs-1.tar.bz2 )", "EAPI": "5-progress"}, "dev-libs/C-1": {"IUSE": "doc", "SRC_URI": "C-1.TAR.XZ doc? ( C-docs-1.tar.bz2 )", "EAPI": "5-progress"}, "app-arch/bzip2-1": {}, "app-arch/gzip-1": {}, "app-arch/tar-1": {}, "app-arch/xz-utils-1": {}, } repo_configs = { "test_repo": { "unpack_dependencies/5-progress": ( "tar.bz2 app-arch/tar app-arch/bzip2", "tar.gz app-arch/tar app-arch/gzip", "tar.xz app-arch/tar app-arch/xz-utils", ), }, } test_cases = ( ResolverPlaygroundTestCase( ["dev-libs/A"], success = True, ignore_mergelist_order = True, mergelist = ["app-arch/tar-1", "app-arch/gzip-1", "dev-libs/A-1"]), ResolverPlaygroundTestCase( ["dev-libs/B"], success = True, ignore_mergelist_order = True, mergelist = ["app-arch/tar-1", "app-arch/xz-utils-1", "dev-libs/B-1"]), ResolverPlaygroundTestCase( ["dev-libs/C"], success = True, ignore_mergelist_order = True, mergelist = ["app-arch/tar-1", "app-arch/xz-utils-1", "app-arch/bzip2-1", "dev-libs/C-1"]), ) user_config = { "package.use": ("dev-libs/C doc",) } playground = ResolverPlayground(distfiles=distfiles, ebuilds=ebuilds, repo_configs=repo_configs, user_config=user_config) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testDoebuildSpawn(self): playground = ResolverPlayground() try: settings = config(clone=playground.settings) cpv = 'sys-apps/portage-2.1' metadata = { 'EAPI' : '2', 'INHERITED' : 'python eutils', 'IUSE' : 'build doc epydoc python3 selinux', 'LICENSE' : 'GPL-2', 'PROVIDE' : 'virtual/portage', 'RDEPEND' : '>=app-shells/bash-3.2_p17 >=dev-lang/python-2.6', 'SLOT' : '0', } root_config = playground.trees[playground.root]['root_config'] pkg = Package(built=False, cpv=cpv, installed=False, metadata=metadata, root_config=root_config, type_name='ebuild') settings.setcpv(pkg) settings['PORTAGE_PYTHON'] = _python_interpreter settings['PORTAGE_BUILDDIR'] = os.path.join( settings['PORTAGE_TMPDIR'], cpv) settings['T'] = os.path.join( settings['PORTAGE_BUILDDIR'], 'temp') for x in ('PORTAGE_BUILDDIR', 'T'): os.makedirs(settings[x]) # Create a fake environment, to pretend as if the ebuild # has been sourced already. open(os.path.join(settings['T'], 'environment'), 'wb') task_scheduler = TaskScheduler() for phase in ('_internal_test',): # Test EbuildSpawnProcess by calling doebuild.spawn() with # returnpid=False. This case is no longer used by portage # internals since EbuildPhase is used instead and that passes # returnpid=True to doebuild.spawn(). rval = doebuild_spawn("%s %s" % (_shell_quote( os.path.join(settings["PORTAGE_BIN_PATH"], os.path.basename(EBUILD_SH_BINARY))), phase), settings, free=1) self.assertEqual(rval, os.EX_OK) ebuild_phase = EbuildPhase(background=False, phase=phase, scheduler=task_scheduler.sched_iface, settings=settings) task_scheduler.add(ebuild_phase) task_scheduler.run() self.assertEqual(ebuild_phase.returncode, os.EX_OK) ebuild_phase = MiscFunctionsProcess(background=False, commands=['success_hooks'], scheduler=task_scheduler.sched_iface, settings=settings) task_scheduler.add(ebuild_phase) task_scheduler.run() self.assertEqual(ebuild_phase.returncode, os.EX_OK) finally: playground.cleanup()
def test_gpkg_short_path(self): if sys.version_info.major < 3: self.skipTest("Not support Python 2") playground = ResolverPlayground( user_config={ "make.conf": ('BINPKG_COMPRESS="none"',), } ) tmpdir = tempfile.mkdtemp() try: settings = playground.settings path_name = ( "aaaabbbb/ccccdddd/eeeeffff/gggghhhh/iiiijjjj/kkkkllll/" "mmmmnnnn/oooopppp/qqqqrrrr/sssstttt/" ) orig_full_path = os.path.join(tmpdir, "orig/" + path_name) os.makedirs(orig_full_path) with open(os.path.join(orig_full_path, "test"), "wb") as test_file: test_file.write(urandom(1048576)) gpkg_file_loc = os.path.join(tmpdir, "test.gpkg.tar") test_gpkg = gpkg(settings, "test", gpkg_file_loc) check_result = test_gpkg._check_pre_image_files( os.path.join(tmpdir, "orig") ) self.assertEqual(check_result, (95, 4, 0, 1048576, 1048576)) test_gpkg.compress(os.path.join(tmpdir, "orig"), {"meta": "test"}) with open(gpkg_file_loc, "rb") as container: # container self.assertEqual( test_gpkg._get_tar_format(container), tarfile.USTAR_FORMAT ) with tarfile.open(gpkg_file_loc, "r") as container: metadata = io.BytesIO(container.extractfile("test/metadata.tar").read()) self.assertEqual( test_gpkg._get_tar_format(metadata), tarfile.USTAR_FORMAT ) metadata.close() image = io.BytesIO(container.extractfile("test/image.tar").read()) self.assertEqual(test_gpkg._get_tar_format(image), tarfile.USTAR_FORMAT) image.close() test_gpkg.decompress(os.path.join(tmpdir, "test")) r = compare_files( os.path.join(tmpdir, "orig/" + path_name + "test"), os.path.join(tmpdir, "test/" + path_name + "test"), skipped_types=("atime", "mtime", "ctime"), ) self.assertEqual(r, ()) finally: shutil.rmtree(tmpdir) playground.cleanup()
def testSimple(self): ebuilds = { "dev-libs/A-1": { "KEYWORDS": "x86" }, "dev-libs/A-2": { "KEYWORDS": "~x86" }, "dev-libs/B-1.2": {}, "app-misc/Z-1": { "DEPEND": "|| ( app-misc/Y ( app-misc/X app-misc/W ) )", "RDEPEND": "" }, "app-misc/Y-1": { "KEYWORDS": "~x86" }, "app-misc/X-1": {}, "app-misc/W-1": {}, } installed = { "dev-libs/A-1": {}, "dev-libs/B-1.1": {}, } test_cases = ( ResolverPlaygroundTestCase(["dev-libs/A"], success=True, mergelist=["dev-libs/A-1"]), ResolverPlaygroundTestCase(["=dev-libs/A-2"], options={"--autounmask": 'n'}, success=False), ResolverPlaygroundTestCase(["dev-libs/A"], options={"--noreplace": True}, success=True, mergelist=[]), ResolverPlaygroundTestCase(["dev-libs/B"], options={"--noreplace": True}, success=True, mergelist=[]), ResolverPlaygroundTestCase(["dev-libs/B"], options={"--update": True}, success=True, mergelist=["dev-libs/B-1.2"]), ResolverPlaygroundTestCase( ["app-misc/Z"], success=True, mergelist=["app-misc/W-1", "app-misc/X-1", "app-misc/Z-1"]), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testSlotConflictForgottenChild(self): """ Similar to testSlotConflictMassRebuild above, but this time the rebuilds are scheduled, but the package causing the rebuild (the child) is not installed. """ ebuilds = { "app-misc/A-2": { "EAPI": "5", "DEPEND": "app-misc/B:= app-misc/C", "RDEPEND": "app-misc/B:= app-misc/C", }, "app-misc/B-2": { "EAPI": "5", "SLOT": "2" }, "app-misc/C-1": { "EAPI": "5", "DEPEND": "app-misc/B:=", "RDEPEND": "app-misc/B:=" }, } installed = { "app-misc/A-1": { "EAPI": "5", "DEPEND": "app-misc/B:1/1= app-misc/C", "RDEPEND": "app-misc/B:1/1= app-misc/C", }, "app-misc/B-1": { "EAPI": "5", "SLOT": "1" }, "app-misc/C-1": { "EAPI": "5", "DEPEND": "app-misc/B:1/1=", "RDEPEND": "app-misc/B:1/1=" }, } test_cases = (ResolverPlaygroundTestCase( ["app-misc/A"], success=True, mergelist=['app-misc/B-2', 'app-misc/C-1', 'app-misc/A-2']), ) world = [] playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testAutounmaskBinpkgUse(self): ebuilds = { "dev-libs/A-1": { "EAPI": "6", "DEPEND": "dev-libs/B[foo]", "RDEPEND": "dev-libs/B[foo]", }, "dev-libs/B-1": { "EAPI": "6", "IUSE": "foo", }, } binpkgs = { "dev-libs/A-1": { "EAPI": "6", "DEPEND": "dev-libs/B[foo]", "RDEPEND": "dev-libs/B[foo]", }, "dev-libs/B-1": { "EAPI": "6", "IUSE": "foo", "USE": "foo", }, } installed = { } test_cases = ( # Bug 619626: Test for unnecessary rebuild due # to rejection of binary packages that would # be acceptable after appplication of autounmask # USE changes. ResolverPlaygroundTestCase( ["dev-libs/A"], all_permutations = True, success = True, options = { "--usepkg": True, "--autounmask": True, }, mergelist = [ "[binary]dev-libs/B-1", "[binary]dev-libs/A-1", ], use_changes = {"dev-libs/B-1": {"foo": True}} ), ) playground = ResolverPlayground(ebuilds=ebuilds, binpkgs=binpkgs, installed=installed, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.debug = False playground.cleanup()
def testVirtualSlotUpdate(self): ebuilds = { "dev-java/oracle-jdk-bin-1.7.0": {"SLOT": "1.7", "LICENSE": "TEST"}, "dev-java/sun-jdk-1.6.0": {"SLOT": "1.6", "LICENSE": "TEST"}, "dev-java/icedtea-6.1.10.3": {"SLOT": "6"}, "dev-java/icedtea-7": {"SLOT": "7"}, "app-misc/java-app-1": {"RDEPEND": ">=virtual/jdk-1.6.0"}, "virtual/jdk-1.6.0": { "SLOT": "1.6", "RDEPEND": "|| ( =dev-java/icedtea-6* =dev-java/sun-jdk-1.6.0* )", }, "virtual/jdk-1.7.0": { "SLOT": "1.7", "RDEPEND": "|| ( =dev-java/icedtea-7* =dev-java/oracle-jdk-bin-1.7.0* )", }, } installed = { "app-misc/java-app-1": {"RDEPEND": ">=virtual/jdk-1.6.0"}, "dev-java/icedtea-6.1.10.3": {"SLOT": "6"}, "virtual/jdk-1.6.0": { "SLOT": "1.6", "RDEPEND": "|| ( =dev-java/icedtea-6* =dev-java/sun-jdk-1.6.0* )", }, } world = ("app-misc/java-app",) test_cases = ( # Pull in the virtual/jdk-1.7.0 slot update since its dependencies # can only be satisfied by an unmasked package. ResolverPlaygroundTestCase( ["@world"], options={"--update": True, "--deep": True}, success=True, mergelist=["dev-java/icedtea-7", "virtual/jdk-1.7.0"], ), # Bug #275945 - Don't pull in the virtual/jdk-1.7.0 slot update # unless --update is enabled. ResolverPlaygroundTestCase( ["@world"], options={"--selective": True, "--deep": True}, success=True, mergelist=[], ), ) playground = ResolverPlayground( ebuilds=ebuilds, installed=installed, world=world ) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testCompleteGraphVersionChange(self): """ Prevent reverse dependency breakage triggered by version changes. """ ebuilds = { "sys-libs/x-0.1": {}, "sys-libs/x-1": {}, "sys-libs/x-2": {}, "sys-apps/a-1": {"RDEPEND" : ">=sys-libs/x-1 <sys-libs/x-2"}, } installed = { "sys-libs/x-1": {}, "sys-apps/a-1": {"RDEPEND" : ">=sys-libs/x-1 <sys-libs/x-2"}, } world = ["sys-apps/a"] test_cases = ( ResolverPlaygroundTestCase( [">=sys-libs/x-2"], options = {"--complete-graph-if-new-ver" : "n"}, mergelist = ["sys-libs/x-2"], success = True, ), ResolverPlaygroundTestCase( [">=sys-libs/x-2"], options = {"--complete-graph-if-new-ver" : "y"}, mergelist = ["sys-libs/x-2"], slot_collision_solutions = [], success = False, ), ResolverPlaygroundTestCase( ["<sys-libs/x-1"], options = {"--complete-graph-if-new-ver" : "n"}, mergelist = ["sys-libs/x-0.1"], success = True, ), ResolverPlaygroundTestCase( ["<sys-libs/x-1"], options = {"--complete-graph-if-new-ver" : "y"}, mergelist = ["sys-libs/x-0.1"], slot_collision_solutions = [], success = False, ), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testDepcleanWithExcludeAndSlots(self): installed = { "dev-libs/Z-1": { "SLOT": 1 }, "dev-libs/Z-2": { "SLOT": 2 }, "dev-libs/Y-1": { "RDEPEND": "=dev-libs/Z-1", "SLOT": 1 }, "dev-libs/Y-2": { "RDEPEND": "=dev-libs/Z-2", "SLOT": 2 }, } world = ["dev-libs/Y"] test_cases = ( # Without --exclude. ResolverPlaygroundTestCase( [], options={"--depclean": True}, success=True, cleanlist=["dev-libs/Y-1", "dev-libs/Z-1"], ), ResolverPlaygroundTestCase( [], options={ "--depclean": True, "--exclude": ["dev-libs/Z"] }, success=True, cleanlist=["dev-libs/Y-1"], ), ResolverPlaygroundTestCase( [], options={ "--depclean": True, "--exclude": ["dev-libs/Y"] }, success=True, cleanlist=[], ), ) playground = ResolverPlayground(installed=installed, world=world) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testCompleteGraphVersionChange(self): """ Prevent reverse dependency breakage triggered by version changes. """ ebuilds = { "sys-libs/x-0.1": {}, "sys-libs/x-1": {}, "sys-libs/x-2": {}, "sys-apps/a-1": {"RDEPEND" : ">=sys-libs/x-1 <sys-libs/x-2"}, } installed = { "sys-libs/x-1": {}, "sys-apps/a-1": {"RDEPEND" : ">=sys-libs/x-1 <sys-libs/x-2"}, } world = ["sys-apps/a"] test_cases = ( ResolverPlaygroundTestCase( [">=sys-libs/x-2"], options = {"--complete-graph-if-new-ver" : "n", "--rebuild-if-new-slot": "n"}, mergelist = ["sys-libs/x-2"], success = True, ), ResolverPlaygroundTestCase( [">=sys-libs/x-2"], options = {"--complete-graph-if-new-ver" : "y"}, mergelist = ["sys-libs/x-2"], slot_collision_solutions = [], success = False, ), ResolverPlaygroundTestCase( ["<sys-libs/x-1"], options = {"--complete-graph-if-new-ver" : "n", "--rebuild-if-new-slot": "n"}, mergelist = ["sys-libs/x-0.1"], success = True, ), ResolverPlaygroundTestCase( ["<sys-libs/x-1"], options = {"--complete-graph-if-new-ver" : "y"}, mergelist = ["sys-libs/x-0.1"], slot_collision_solutions = [], success = False, ), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testEbuildFetch(self): user_config = { "make.conf": ('GENTOO_MIRRORS="{scheme}://{host}:{port}"', ), } distfiles = { 'bar': b'bar\n', 'foo': b'foo\n', } ebuilds = { 'dev-libs/A-1': { 'EAPI': '7', 'SRC_URI': '''{scheme}://{host}:{port}/distfiles/bar.txt -> bar {scheme}://{host}:{port}/distfiles/foo.txt -> foo''', }, } loop = SchedulerInterface(global_event_loop()) scheme = 'http' host = '127.0.0.1' content = {} with AsyncHTTPServer(host, content, loop) as server: ebuilds_subst = {} for cpv, metadata in ebuilds.items(): metadata = metadata.copy() metadata['SRC_URI'] = metadata['SRC_URI'].format( scheme=scheme, host=host, port=server.server_port) ebuilds_subst[cpv] = metadata user_config_subst = user_config.copy() for configname, configdata in user_config.items(): configdata_sub = [] for line in configdata: configdata_sub.append( line.format(scheme=scheme, host=host, port=server.server_port)) user_config_subst[configname] = tuple(configdata_sub) playground = ResolverPlayground(ebuilds=ebuilds_subst, distfiles=distfiles, user_config=user_config_subst) ro_distdir = tempfile.mkdtemp() try: self._testEbuildFetch(loop, scheme, host, distfiles, ebuilds, content, server, playground, ro_distdir) finally: shutil.rmtree(ro_distdir) playground.cleanup()
def testBacktrackNoWrongRebuilds(self): """ Ensure we remove backtrack masks if the reason for the mask gets masked itself. """ ebuilds = { "dev-libs/A-1": {}, "dev-libs/A-2": {}, "dev-libs/B-1": { "RDEPEND": "dev-libs/D" }, "dev-libs/C-1": {}, "dev-libs/C-2": { "RDEPEND": ">=dev-libs/A-2" }, "dev-libs/D-1": { "RDEPEND": "<dev-libs/A-2" }, } installed = { "dev-libs/A-1": {}, "dev-libs/B-1": { "RDEPEND": "dev-libs/D" }, "dev-libs/C-1": {}, "dev-libs/D-1": { "RDEPEND": "<dev-libs/A-2" }, } world = ["dev-libs/B", "dev-libs/C"] options = { '--backtrack': 6, '--deep': True, '--selective': True, '--update': True, } test_cases = (ResolverPlaygroundTestCase(["@world"], options=options, mergelist=[], success=True), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testDeeplyConnectedCollision(self): """ Like testConnectedCollision, except that there is another level of dependencies between the two conflicts. """ ebuilds = { "dev-libs/A-1": { "RDEPEND": "=dev-libs/X-1" }, "dev-libs/B-1": { "RDEPEND": "dev-libs/X" }, "dev-libs/X-1": { "RDEPEND": "dev-libs/K" }, "dev-libs/X-2": { "RDEPEND": "dev-libs/L" }, "dev-libs/K-1": { "RDEPEND": "=dev-libs/Y-1" }, "dev-libs/L-1": { "RDEPEND": "=dev-libs/Y-2" }, "dev-libs/Y-1": { "PDEPEND": "=dev-libs/X-1" }, "dev-libs/Y-2": { "PDEPEND": "=dev-libs/X-2" }, } test_cases = (ResolverPlaygroundTestCase( ["dev-libs/A", "dev-libs/B"], all_permutations=True, options={"--backtrack": 0}, success=True, ignore_mergelist_order=True, mergelist=[ "dev-libs/Y-1", "dev-libs/X-1", "dev-libs/K-1", "dev-libs/A-1", "dev-libs/B-1", ], ), ) playground = ResolverPlayground(ebuilds=ebuilds, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testSlotOperatorRequiredUse(self): ebuilds = { "app-misc/A-1": { "EAPI": "5", "SLOT": "0/1" }, "app-misc/A-2": { "EAPI": "5", "SLOT": "0/2" }, "app-misc/B-0": { "EAPI": "5", "RDEPEND": "app-misc/A:=", "IUSE": "x y", "REQUIRED_USE": "|| ( x y )" }, } installed = { "app-misc/A-1": { "EAPI": "5", "SLOT": "0/1" }, "app-misc/B-0": { "EAPI": "5", "RDEPEND": "app-misc/A:0/1=", "IUSE": "x y", "USE": "x" }, } world = ["app-misc/B"] test_cases = ( # bug 523048 # Ensure that unsatisfied REQUIRED_USE is reported when # it blocks necessary slot-operator rebuilds. ResolverPlaygroundTestCase( ["app-misc/A"], success=False, required_use_unsatisfied=['app-misc/B:0']), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testUseMask(self): profile = { "use.mask": ( "abi_ppc_32", ), } ebuilds = { "sys-libs/A-1" : { "EAPI": "5", "RDEPEND": "|| ( sys-libs/zlib[abi_ppc_32(-)] " + \ "sys-libs/zlib[abi_x86_32(-)] )" }, "sys-libs/zlib-1.2.8-r1" : { "EAPI": "5", "IUSE": "abi_ppc_32 abi_x86_32" }, "sys-libs/zlib-1.2.8" : { "EAPI": "5", "IUSE": "" }, } test_cases = ( # bug #515584: We want to prefer choices that do # not require changes to use.mask or use.force. # In this case, abi_ppc_32 is use.masked in the # profile, so we want to avoid that choice. ResolverPlaygroundTestCase( ["sys-libs/A"], options = {}, success = False, use_changes = { 'sys-libs/zlib-1.2.8-r1': {'abi_x86_32': True} }, mergelist = ["sys-libs/zlib-1.2.8-r1", "sys-libs/A-1"] ), ) playground = ResolverPlayground(ebuilds=ebuilds, profile=profile, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testSlotConflictRebuildGolang(self): ebuilds = { "dev-lang/go-1.14.7": { "EAPI": "7", "SLOT": "0/1.14.7" }, "dev-lang/go-1.15": { "EAPI": "7", "SLOT": "0/1.15" }, "net-p2p/syncthing-1.3.4-r1": { "EAPI": "7", "BDEPEND": "=dev-lang/go-1.14* >=dev-lang/go-1.12", }, } installed = { "dev-lang/go-1.14.7": { "EAPI": "7", "SLOT": "0/1.14.7" }, "net-p2p/syncthing-1.3.4-r1": { "EAPI": "7", "BDEPEND": "=dev-lang/go-1.14* >=dev-lang/go-1.12", }, } world = ["dev-lang/go", "net-p2p/syncthing"] test_cases = ( # Demonstrate an unwanted dev-lang/go rebuild triggered by a missed # update due to a slot conflict (bug #439688). ResolverPlaygroundTestCase( ["@world"], options={ "--update": True, "--deep": True }, success=True, mergelist=[], ), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.debug = False playground.cleanup()
def testAutounmaskUseSlotConflict(self): self.todo = True ebuilds = { "sci-libs/K-1": { "IUSE": "+foo", "EAPI": 1 }, "sci-libs/L-1": { "DEPEND": "sci-libs/K[-foo]", "EAPI": 2 }, "sci-libs/M-1": { "DEPEND": "sci-libs/K[foo=]", "IUSE": "+foo", "EAPI": 2 }, } installed = {} test_cases = ( # Test bug 615824, where an automask USE change results in # a conflict which is not reported. In order to install L, # foo must be disabled for both K and M, but autounmask # disables foo for K and leaves it enabled for M. ResolverPlaygroundTestCase( ["sci-libs/L", "sci-libs/M"], options={"--backtrack": 0}, success=False, mergelist=[ "sci-libs/L-1", "sci-libs/M-1", "sci-libs/K-1", ], ignore_mergelist_order=True, slot_collision_solutions=[{ "sci-libs/K-1": { "foo": False }, "sci-libs/M-1": { "foo": False } }], ), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.debug = False playground.cleanup()
def testSlotConflictDepChange(self): """ Bug 490362 The dependency in the ebuild was changed form slot operator to no slot operator. The vdb contained the slot operator and emerge would refuse to rebuild. """ ebuilds = { "app-misc/A-1" : { "EAPI": "5", "DEPEND": "app-misc/B", "RDEPEND": "app-misc/B" }, "app-misc/B-1" : { "EAPI": "5", "SLOT": "0/1" }, "app-misc/B-2" : { "EAPI": "5", "SLOT": "0/2" }, } installed = { "app-misc/A-1" : { "EAPI": "5", "DEPEND": "app-misc/B:0/1=", "RDEPEND": "app-misc/B:0/1=" }, "app-misc/B-1" : { "EAPI": "5", "SLOT": "0/1" }, } test_cases = ( ResolverPlaygroundTestCase( ["app-misc/B"], success = True, mergelist = ['app-misc/B-2', 'app-misc/A-1']), ) world = ["app-misc/A"] playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testMultiSlotSelective(self): """ Test that a package isn't reinstalled due to SLOT dependency interaction with USE=multislot (bug #220341). """ ebuilds = { "sys-devel/gcc-4.4.4": { "SLOT": "4.4" }, "dev-util/nvidia-cuda-toolkit-4.0": { "EAPI": "1", "RDEPEND": "sys-devel/gcc:4.4" }, } installed = { "sys-devel/gcc-4.4.4": { "SLOT": "i686-pc-linux-gnu-4.4.4" }, "dev-util/nvidia-cuda-toolkit-4.0": { "EAPI": "1", "RDEPEND": "sys-devel/gcc:4.4" }, } world = ("dev-util/nvidia-cuda-toolkit", ) options = {'--update': True, '--deep': True, '--selective': True} test_cases = ( ResolverPlaygroundTestCase(["sys-devel/gcc:4.4"], options=options, mergelist=[], success=True), # depclean test for bug #382823 ResolverPlaygroundTestCase([], options={"--depclean": True}, success=True, cleanlist=[]), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testRegularSlotChangeWithoutRevBumpTestCase(self): ebuilds = { "dev-libs/boost-1.52.0": { "SLOT": "0" }, "app-office/libreoffice-4.0.0.2": { "EAPI": "5", "DEPEND": ">=dev-libs/boost-1.46:=", "RDEPEND": ">=dev-libs/boost-1.46:=", }, } binpkgs = { "dev-libs/boost-1.52.0": { "SLOT": "1.52" }, } installed = { "dev-libs/boost-1.52.0": { "SLOT": "1.52" }, } world = [] test_cases = ( # Test that @__auto_slot_operator_replace_installed__ # pulls in the available slot, even though it's # different from the installed slot (0 instead of 1.52). ResolverPlaygroundTestCase(["app-office/libreoffice"], options={ "--oneshot": True, "--usepkg": True }, success=True, mergelist=[ 'dev-libs/boost-1.52.0', 'app-office/libreoffice-4.0.0.2' ]), ) playground = ResolverPlayground(ebuilds=ebuilds, binpkgs=binpkgs, installed=installed, world=world, debug=False) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def testVirtualTransition(self): ebuilds = { "kde-base/kcron-4.7.1": { "RDEPEND": "virtual/cron" }, "sys-process/vixie-cron-4.1-r11": {}, "virtual/cron-0": { "RDEPEND": "sys-process/vixie-cron" }, } installed = { "kde-base/kcron-4.7.1": { "RDEPEND": "virtual/cron" }, "sys-process/vixie-cron-4.1-r11": { "PROVIDE": "virtual/cron" }, } world = ["kde-base/kcron", "sys-process/vixie-cron"] test_cases = ( # Pull in a new-style virtual, even though there is an installed # old-style virtual to satisfy the virtual/cron dep. This case # is common, due to PROVIDE being removed (without revision bump) # from lots of ebuilds. ResolverPlaygroundTestCase(["@world"], options={ "--update": True, "--deep": True }, success=True, mergelist=["virtual/cron-0"]), # Make sure that depclean is satisfied with the installed # old-style virutal. ResolverPlaygroundTestCase([], options={"--depclean": True}, success=True, cleanlist=[]), ) playground = ResolverPlayground(ebuilds=ebuilds, installed=installed, world=world) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup()
def test_gpkg_manifest_duplicate_files(self): if sys.version_info.major < 3: self.skipTest("Not support Python 2") playground = ResolverPlayground( user_config={ "make.conf": ( 'FEATURES="${FEATURES} -binpkg-signing ' '-binpkg-request-signature -gpg-keepalive"', ), } ) tmpdir = tempfile.mkdtemp() try: settings = playground.settings orig_full_path = os.path.join(tmpdir, "orig/") os.makedirs(orig_full_path) data = urandom(100) with open(os.path.join(orig_full_path, "data"), "wb") as f: f.write(data) binpkg_1 = gpkg(settings, "test", os.path.join(tmpdir, "test-1.gpkg.tar")) binpkg_1.compress(orig_full_path, {}) with tarfile.open(os.path.join(tmpdir, "test-1.gpkg.tar"), "r") as tar_1: with tarfile.open( os.path.join(tmpdir, "test-2.gpkg.tar"), "w" ) as tar_2: for f in tar_1.getmembers(): if f.name == "Manifest": manifest = tar_1.extractfile(f).read() data = io.BytesIO(manifest) data.seek(io.SEEK_END) data.write(b"\n") data.write(manifest) f.size = data.tell() data.seek(0) tar_2.addfile(f, data) data.close() else: tar_2.addfile(f, tar_1.extractfile(f)) binpkg_2 = gpkg(settings, "test", os.path.join(tmpdir, "test-2.gpkg.tar")) self.assertRaises( DigestException, binpkg_2.decompress, os.path.join(tmpdir, "test") ) finally: shutil.rmtree(tmpdir) playground.cleanup()
def testOverlapSlotConflict(self): ebuilds = { 'app-misc/bar-1': { 'EAPI': '6', 'RDEPEND': 'virtual/foo' }, 'virtual/foo-1': { 'EAPI': '6', 'RDEPEND': '|| ( app-misc/A >=app-misc/B-2 ) || ( <app-misc/B-2 app-misc/C )' }, 'app-misc/A-1': { 'EAPI': '6', }, 'app-misc/B-2': { 'EAPI': '6', }, 'app-misc/B-1': { 'EAPI': '6', }, 'app-misc/C-1': { 'EAPI': '6', }, } test_cases = ( # Here the ( >=app-misc/B-2 <app-misc/B-2 ) choice is not satisfiable. ResolverPlaygroundTestCase( ['app-misc/bar'], success=True, ambiguous_merge_order=True, mergelist=[ ( 'app-misc/C-1', 'app-misc/A-1', ), 'virtual/foo-1', 'app-misc/bar-1', ] ), ) playground = ResolverPlayground(debug=False, ebuilds=ebuilds) try: for test_case in test_cases: playground.run_TestCase(test_case) self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.debug = False playground.cleanup()