14
0

Accepting request 832778 from devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/832778
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-python-prctl?expand=0&rev=3
This commit is contained in:
2020-09-07 19:36:56 +00:00
committed by Git OBS Bridge
5 changed files with 121 additions and 4 deletions

27
bigendian.patch Normal file
View File

@@ -0,0 +1,27 @@
Index: python-prctl-1.7/_prctlmodule.c
===================================================================
--- python-prctl-1.7.orig/_prctlmodule.c
+++ python-prctl-1.7/_prctlmodule.c
@@ -50,6 +50,7 @@ prctl_prctl(PyObject *self, PyObject *ar
{
long option = 0;
long arg = 0;
+ int intarg = 0;
char *argstr = NULL;
char name[17] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
int result;
@@ -286,12 +287,12 @@ prctl_prctl(PyObject *self, PyObject *ar
#ifdef PR_GET_TID_ADDRESS
case(PR_GET_TID_ADDRESS):
#endif
- result = prctl(option, &arg, 0, 0, 0);
+ result = prctl(option, &intarg, 0, 0, 0);
if(result < 0) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
- return PyInt_FromLong(arg);
+ return PyInt_FromLong(intarg);
case(PR_SET_NAME):
case(PR_GET_NAME):
result = prctl(option, name, 0, 0, 0);

View File

@@ -6,7 +6,7 @@ Index: python-prctl-1.7/test_prctl.py
self.assertEqual(prctl.get_keepcaps(), False)
@require('set_mce_kill')
+ @unittest.skipIf(sys.maxsize <= 2**32, 'fails on 32 bit')
+ @unittest.skipIf(sys.maxsize <= 2**32 or arch == 's390x', 'no such file on this architecture')
def test_mce_kill(self):
"""Test the MCE_KILL setting"""
fd = open('/proc/sys/vm/memory_failure_early_kill')

79
powerpc.patch Normal file
View File

@@ -0,0 +1,79 @@
diff -ur python-prctl-1.7.orig/test_prctl.py python-prctl-1.7/test_prctl.py
--- python-prctl-1.7.orig/test_prctl.py 2020-09-07 11:09:38.544700725 +0200
+++ python-prctl-1.7/test_prctl.py 2020-09-07 12:28:11.482301401 +0200
@@ -44,6 +44,8 @@
class PrctlTest(unittest.TestCase):
# There are architecture specific tests
arch = os.uname()[4]
+ if arch == 'ppc' or arch == 'ppc64' or arch == 'ppc64le':
+ arch = 'powerpc'
# prctl behaviour differs when root, so you should test as root and non-root
am_root = os.geteuid() == 0
@@ -110,6 +112,7 @@
self.assertEqual(prctl.get_dumpable(), False)
self.assertRaises(TypeError, prctl.get_dumpable, "42")
+ @unittest.skip('cannot change endianness of running python interpreter')
def test_endian(self):
"""Test manipulation of the endianness setting"""
if self.arch == 'powerpc':
@@ -136,13 +139,55 @@
self.assertRaises(OSError, prctl.get_fpemu)
self.assertRaises(OSError, prctl.set_fpemu, prctl.FPEMU_SIGFPE)
+# define PR_FP_EXC_SW_ENABLE 0x80 /* Use FPEXC for FP exception enables */
+# define PR_FP_EXC_DIV 0x010000 /* floating point divide by zero */
+# define PR_FP_EXC_OVF 0x020000 /* floating point overflow */
+# define PR_FP_EXC_UND 0x040000 /* floating point underflow */
+# define PR_FP_EXC_RES 0x080000 /* floating point inexact result */
+# define PR_FP_EXC_INV 0x100000 /* floating point invalid operation */
+# define PR_FP_EXC_DISABLED 0 /* FP exceptions disabled */
+# define PR_FP_EXC_NONRECOV 1 /* async non-recoverable exc. mode */
+# define PR_FP_EXC_ASYNC 2 /* async recoverable exception mode */
+# define PR_FP_EXC_PRECISE 3 /* precise exception mode */
+ def print_fpexc(self, fpexc):
+ if fpexc == 0:
+ print("PR_FP_EXC_DISABLED")
+ else:
+ if fpexc & 3 == _prctl.PR_FP_EXC_ASYNC:
+ print('PR_FP_EXC_ASYNC')
+ if fpexc & 3 == _prctl.PR_FP_EXC_NONRECOV:
+ print('PR_FP_EXC_NONRECOV')
+ if fpexc & 3 == _prctl.PR_FP_EXC_PRECISE:
+ print('PR_FP_EXC_PRECISE')
+ if fpexc & prctl.PR_FP_EXC_SW_ENABLE:
+ print('PR_FP_EXC_SW_ENABLE')
+ if fpexc & _prctl.PR_FP_EXC_DIV:
+ print('PR_FP_EXC_DIV')
+ if fpexc & _prctl.PR_FP_EXC_OVF:
+ print('PR_FP_EXC_OVF')
+ if fpexc & _prctl.PR_FP_EXC_UND:
+ print('PR_FP_EXC_UND')
+ if fpexc & _prctl.PR_FP_EXC_RES:
+ print('PR_FP_EXC_RES')
+ if fpexc & _prctl.PR_FP_EXC_INV:
+ print('PR_FP_EXC_INV')
+ print('\n');
+
def test_fpexc(self):
"""Test manipulation of the fpexc setting"""
if self.arch == 'powerpc':
- # FIXME - untested
- prctl.set_fpexc(prctl.FP_EXC_SW_ENABLE)
- self.assertEqual(prctl.get_fpexc() & prctl.PR_FP_EXC_SW_ENABLE, prctl.PR_FP_EXC_SW_ENABLE)
+ fpexc = prctl.get_fpexc()
+ self.print_fpexc(fpexc)
+ # Did not find a sane combination of flags that is supported.
+ self.assertRaises(OSError, prctl.set_fpexc,
+ prctl.FP_EXC_SW_ENABLE | _prctl.PR_FP_EXC_ASYNC | _prctl.PR_FP_EXC_DIV | _prctl.PR_FP_EXC_INV)
+ self.print_fpexc(prctl.get_fpexc())
+ self.assertEqual(prctl.get_fpexc(), fpexc)
+ prctl.set_fpexc(_prctl.PR_FP_EXC_DISABLED)
+ self.print_fpexc(prctl.get_fpexc())
+ self.assertEqual(prctl.get_fpexc(), _prctl.PR_FP_EXC_DISABLED)
self.assertRaises(ValueError, prctl.set_fpexc, 999)
+ prctl.set_fpexc(fpexc)
else:
self.assertRaises(OSError, prctl.get_fpexc)
self.assertRaises(OSError, prctl.set_fpexc)

View File

@@ -1,3 +1,13 @@
-------------------------------------------------------------------
Fri Sep 4 13:48:25 UTC 2020 - Marketa Calabkova <mcalabkova@suse.com>
- Fixing arch-dependent test failures (bsc#1176085):
* renamed failing-on-i586.patch to memory_failure_early_kill.patch
* and modified it to skip the test also on s390x
* added bigendian.patch
* added powerpc.patch
* huge thanks to Michal Suchánek
-------------------------------------------------------------------
Wed Aug 19 07:46:50 UTC 2020 - Marketa Calabkova <mcalabkova@suse.com>

View File

@@ -26,7 +26,9 @@ URL: https://github.com/seveas/python-prctl
Source: https://files.pythonhosted.org/packages/source/p/python-prctl/python-prctl-%{version}.tar.gz
Source99: https://raw.githubusercontent.com/seveas/python-prctl/master/COPYING
Patch0: disable-sandboxed-test.patch
Patch1: failing-on-i586.patch
Patch1: memory_failure_early_kill.patch
Patch2: bigendian.patch
Patch3: powerpc.patch
BuildRequires: %{python_module devel}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
@@ -48,8 +50,7 @@ and allows you to set the process name as seen in ps and top.
%prep
%setup -q -n python-prctl-%{version}
%patch0 -p1
%patch1 -p1
%autopatch -p1
cp %{SOURCE99} .
%build