From 148bc3474ec2f10eb46b4423fc45242cc77dede7 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Jun 13 2016 03:19:21 +0000 Subject: [PATCH 1/2] Test case for yum repos with multiple arches --- diff --git a/rpmfluff.py b/rpmfluff.py index bce4574..4965b68 100755 --- a/rpmfluff.py +++ b/rpmfluff.py @@ -27,6 +27,7 @@ from __future__ import print_function import unittest import os import os.path +import shutil import rpm #import base64 @@ -1269,7 +1270,6 @@ class TestSimpleRpmBuild(unittest.TestCase): "build directory %s already exists" % self.rpmbuild.get_base_dir()) def tearDown(self): - import shutil shutil.rmtree(self.rpmbuild.get_base_dir(), ignore_errors=True) def test_build(self): @@ -1804,11 +1804,25 @@ class YumRepoBuildTests(unittest.TestCase): self.assertTrue(len(element) == 1, "Could not find data for type %s" % mdtype) self.assert_is_file(os.path.join(repo.repoDir, element[0].get('href'))) finally: - import shutil shutil.rmtree(repo.repoDir, ignore_errors=True) for pkg in repo.rpmBuilds: shutil.rmtree(pkg.get_base_dir()) + @unittest.skipIf(expectedArch != 'x86_64' or not os.path.isfile('/usr/bin/createrepo'), + 'host arch is not x86_64 or /usr/bin/createrepo not found') + def test_multiple_arches(self): + package = SimpleRpmBuild('test-multilib-package', '0.1', '1', ['i386', 'x86_64']) + repo = YumRepoBuild([package]) + self.addCleanup(shutil.rmtree, package.get_base_dir()) + self.addCleanup(shutil.rmtree, repo.repoDir) + + repo.make('i386', 'x86_64') + + # Check that the repo was built with both the i386 and x86_64 packages + self.assert_is_dir(os.path.join(repo.repoDir, 'repodata')) + self.assert_is_file(os.path.join(repo.repoDir, 'test-multilib-package-0.1-1.i386.rpm')) + self.assert_is_file(os.path.join(repo.repoDir, 'test-multilib-package-0.1-1.x86_64.rpm')) + if __name__ == "__main__": unittest.main() From 42c4a7f675f2667a237f82b706925f59b962a3c8 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Jun 13 2016 03:19:21 +0000 Subject: [PATCH 2/2] Test case for building 32-bit binaries in 32-bit packages --- diff --git a/rpmfluff.py b/rpmfluff.py index 4965b68..777b223 100755 --- a/rpmfluff.py +++ b/rpmfluff.py @@ -1681,10 +1681,17 @@ class TestSimpleRpmBuild(unittest.TestCase): "/usr/bin/perl")) self.rpmbuild.make() + @unittest.skipIf(expectedArch != 'x86_64', + 'host arch is not x86_64') def test_multiarch_compilation(self): """Ensure that building on multiple archs works as expected""" - self.rpmbuild.add_simple_compilation() + self.rpmbuild.buildArchs = ['i386', 'x86_64'] + self.rpmbuild.add_simple_compilation(installPath='/usr/bin/program') self.rpmbuild.make() + hdr = self.rpmbuild.get_built_rpm_header('i386') + self.assertEqual(1, rpm.files(hdr)['/usr/bin/program'].color) + hdr = self.rpmbuild.get_built_rpm_header('x86_64') + self.assertEqual(2, rpm.files(hdr)['/usr/bin/program'].color) def test_multilib_conflict(self): """Ensure that the hooks to create a multilib conflict work as expected"""