From 079b9b282efa667178b15fd1d96ae96f3ae2ae82 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Dec 07 2016 07:36:46 +0000 Subject: Get target_arch in stable way Use platform.machine to get target_arch from the machine where tests are running. This is requires for running tests in various machines that have different arches. It is useful for building packages in Copr and Koji especially, that is because we have to build packages for i386, e.g. fedora-24-i386, and the build might happen in an ARM builder machine sometimes. So, we have to ensure to get - target arch i686 on i386 - target arch armv7hl on ARM Signed-off-by: Chenxiong Qi --- diff --git a/tests/test_cli.py b/tests/test_cli.py index 6ccd39d..e61e30c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -4,6 +4,7 @@ import gzip import hashlib import logging import os +import platform import rpmfluff import shutil import sys @@ -365,18 +366,6 @@ Building for target i686''', stdout) class TestLocal(CliTestCase): - def translate_arch(self, arch): - """Translate local arch to arch the rpmbuild uses - - This is another workaround for running tests in Copr, where when - building RPM in a i386 target, local arch is i386, but arch in RPM is - "translated" to i686. - """ - translation = { - 'i386': 'i686', - } - return translation.get(arch, arch) - def test_local(self): cli_cmd = ['rpkg', '--path', self.cloned_repo_path, '--release', 'rhel-6', 'local'] @@ -385,10 +374,10 @@ class TestLocal(CliTestCase): cli.local() self.assertTrue(exists(join(self.cloned_repo_path, 'docpkg-1.2-2.el6.src.rpm'))) - # This covers some special cases, e.g. building in copr, that is - # RPMs are not put in arch subdirectory even if %{_build_name_fmt} + # This covers some special cases, e.g. building in copr and Koji, that + # is RPMs are not put in arch subdirectory even if %{_build_name_fmt} # is %{ARCH}/%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm - arch = self.translate_arch(cli.cmd.localarch) + arch = platform.machine() self.assertTrue( exists(join(self.cloned_repo_path, 'docpkg-1.2-2.el6.{0}.rpm'.format(arch))) or exists(join(self.cloned_repo_path, '{0}/docpkg-1.2-2.el6.{0}.rpm'.format(arch))))