From b3ccba94f59d2ce237107c3723a0c58148830ca7 Mon Sep 17 00:00:00 2001 From: lzhao Date: Mon, 8 Apr 2019 09:23:51 +0800 Subject: [PATCH 1/4] bpo-31904: skip test case in test_resource for VxWorks doesn't support set RLIMIT_FSIZE and RLIMIT_CPU --- Doc/library/resource.rst | 2 ++ Lib/test/test_resource.py | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Doc/library/resource.rst b/Doc/library/resource.rst index 2ed15c13673668..cbdd5bbf126929 100644 --- a/Doc/library/resource.rst +++ b/Doc/library/resource.rst @@ -76,6 +76,8 @@ this module for those platforms. ``setrlimit`` may also raise :exc:`error` if the underlying system call fails. + VxWorks only support setting RLIMIT_NOFILE and idtype must be P_PID. + .. function:: prlimit(pid, resource[, limits]) Combines :func:`setrlimit` and :func:`getrlimit` in one function and diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 62c7963fe6999f..c0a478f4e12e19 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -4,6 +4,13 @@ from test import support import time +_support_rlimit_fsize_set=True +_support_rlimit_cpu_set=True + +if sys.platform == "vxworks": + _support_rlimit_fsize_set=False + _support_rlimit_cpu_set=False + resource = support.import_module('resource') # This test is checking a few specific problem spots with the resource module. @@ -28,7 +35,8 @@ def test_fsize_ismax(self): # the number to a C long long and that the conversion doesn't raise # an error. self.assertEqual(resource.RLIM_INFINITY, max) - resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max)) + if _support_rlimit_fsize_set: + resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max)) def test_fsize_enforced(self): try: @@ -124,7 +132,8 @@ def __getitem__(self, key): return len(tuple(range(1000000))) raise IndexError - resource.setrlimit(resource.RLIMIT_CPU, BadSequence()) + if _support_rlimit_cpu_set: + resource.setrlimit(resource.RLIMIT_CPU, BadSequence()) def test_pagesize(self): pagesize = resource.getpagesize() From 3d49a7049d0f3c76a798318a577122ec866c907a Mon Sep 17 00:00:00 2001 From: lzhao Date: Mon, 8 Apr 2019 09:26:41 +0800 Subject: [PATCH 2/4] add news file --- .../NEWS.d/next/Library/2019-04-08-09-24-36.bpo-31904.ab03ea.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2019-04-08-09-24-36.bpo-31904.ab03ea.rst diff --git a/Misc/NEWS.d/next/Library/2019-04-08-09-24-36.bpo-31904.ab03ea.rst b/Misc/NEWS.d/next/Library/2019-04-08-09-24-36.bpo-31904.ab03ea.rst new file mode 100644 index 00000000000000..8042ca47d1f60a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-04-08-09-24-36.bpo-31904.ab03ea.rst @@ -0,0 +1 @@ +Skip setting RLIMIT_FSIZE and RLIMIT_CPU test case for VxWorks From 90f6ce713ada90f27d6df361765e0c3f99441dcf Mon Sep 17 00:00:00 2001 From: lzhao Date: Wed, 17 Apr 2019 22:20:56 +0800 Subject: [PATCH 3/4] skip LIMIT_FSIZE and RLIMIT_CPU full function test --- Lib/test/test_resource.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index c0a478f4e12e19..e5ece5284cf15b 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -4,13 +4,6 @@ from test import support import time -_support_rlimit_fsize_set=True -_support_rlimit_cpu_set=True - -if sys.platform == "vxworks": - _support_rlimit_fsize_set=False - _support_rlimit_cpu_set=False - resource = support.import_module('resource') # This test is checking a few specific problem spots with the resource module. @@ -23,6 +16,8 @@ def test_args(self): self.assertRaises(TypeError, resource.setrlimit) self.assertRaises(TypeError, resource.setrlimit, 42, 42, 42) + @unittest.skipIf(sys.platform == "vxworks", + "setting RLIMIT_FSIZE is not supported on VxWorks") def test_fsize_ismax(self): try: (cur, max) = resource.getrlimit(resource.RLIMIT_FSIZE) @@ -35,8 +30,7 @@ def test_fsize_ismax(self): # the number to a C long long and that the conversion doesn't raise # an error. self.assertEqual(resource.RLIM_INFINITY, max) - if _support_rlimit_fsize_set: - resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max)) + resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max)) def test_fsize_enforced(self): try: @@ -118,6 +112,8 @@ def test_getrusage(self): pass # Issue 6083: Reference counting bug + @unittest.skipIf(sys.platform == "vxworks", + "setting RLIMIT_CPU is not supported on VxWorks") def test_setrusage_refcount(self): try: limits = resource.getrlimit(resource.RLIMIT_CPU) @@ -132,8 +128,7 @@ def __getitem__(self, key): return len(tuple(range(1000000))) raise IndexError - if _support_rlimit_cpu_set: - resource.setrlimit(resource.RLIMIT_CPU, BadSequence()) + resource.setrlimit(resource.RLIMIT_CPU, BadSequence()) def test_pagesize(self): pagesize = resource.getpagesize() From 647cefb6eb99cdd33e106a261c93c3f430ec0b60 Mon Sep 17 00:00:00 2001 From: lzhao Date: Wed, 17 Apr 2019 23:17:27 +0800 Subject: [PATCH 4/4] move the NEWS to Test directory and update document --- Doc/library/resource.rst | 2 +- .../next/Library/2019-04-08-09-24-36.bpo-31904.ab03ea.rst | 1 - Misc/NEWS.d/next/Tests/2019-04-08-09-24-36.bpo-31904.ab03ea.rst | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2019-04-08-09-24-36.bpo-31904.ab03ea.rst create mode 100644 Misc/NEWS.d/next/Tests/2019-04-08-09-24-36.bpo-31904.ab03ea.rst diff --git a/Doc/library/resource.rst b/Doc/library/resource.rst index cbdd5bbf126929..3573da7ea2d716 100644 --- a/Doc/library/resource.rst +++ b/Doc/library/resource.rst @@ -76,7 +76,7 @@ this module for those platforms. ``setrlimit`` may also raise :exc:`error` if the underlying system call fails. - VxWorks only support setting RLIMIT_NOFILE and idtype must be P_PID. + VxWorks only supports setting :data:`RLIMIT_NOFILE`. .. function:: prlimit(pid, resource[, limits]) diff --git a/Misc/NEWS.d/next/Library/2019-04-08-09-24-36.bpo-31904.ab03ea.rst b/Misc/NEWS.d/next/Library/2019-04-08-09-24-36.bpo-31904.ab03ea.rst deleted file mode 100644 index 8042ca47d1f60a..00000000000000 --- a/Misc/NEWS.d/next/Library/2019-04-08-09-24-36.bpo-31904.ab03ea.rst +++ /dev/null @@ -1 +0,0 @@ -Skip setting RLIMIT_FSIZE and RLIMIT_CPU test case for VxWorks diff --git a/Misc/NEWS.d/next/Tests/2019-04-08-09-24-36.bpo-31904.ab03ea.rst b/Misc/NEWS.d/next/Tests/2019-04-08-09-24-36.bpo-31904.ab03ea.rst new file mode 100644 index 00000000000000..2b361011abaed6 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2019-04-08-09-24-36.bpo-31904.ab03ea.rst @@ -0,0 +1 @@ +Port test_resource to VxWorks: skip tests cases setting RLIMIT_FSIZE and RLIMIT_CPU.