]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46099: Fix pthread_getcpuclockid test on Solaris (GH-30140) (#30184)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 18 Dec 2021 15:51:34 +0000 (07:51 -0800)
committerGitHub <noreply@github.com>
Sat, 18 Dec 2021 15:51:34 +0000 (17:51 +0200)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
(cherry picked from commit 427a490c495cde8a152e938c6f02be65620e3e59)

Co-authored-by: Jakub KulĂ­k <Kulikjak@gmail.com>
Lib/test/test_time.py

index 90a123828b7097370738c793d81837bd8ebf45e9..be9fb5ad5f0b178dfee93dfd2144193d893672fb 100644 (file)
@@ -112,12 +112,13 @@ class TimeTestCase(unittest.TestCase):
         clk_id = time.pthread_getcpuclockid(threading.get_ident())
         self.assertTrue(type(clk_id) is int)
         # when in 32-bit mode AIX only returns the predefined constant
-        if not platform.system() == "AIX":
-            self.assertNotEqual(clk_id, time.CLOCK_THREAD_CPUTIME_ID)
-        elif (sys.maxsize.bit_length() > 32):
-            self.assertNotEqual(clk_id, time.CLOCK_THREAD_CPUTIME_ID)
-        else:
+        if platform.system() == "AIX" and (sys.maxsize.bit_length() <= 32):
             self.assertEqual(clk_id, time.CLOCK_THREAD_CPUTIME_ID)
+        # Solaris returns CLOCK_THREAD_CPUTIME_ID when current thread is given
+        elif sys.platform.startswith("sunos"):
+            self.assertEqual(clk_id, time.CLOCK_THREAD_CPUTIME_ID)
+        else:
+            self.assertNotEqual(clk_id, time.CLOCK_THREAD_CPUTIME_ID)
         t1 = time.clock_gettime(clk_id)
         t2 = time.clock_gettime(clk_id)
         self.assertLessEqual(t1, t2)