]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46099: Fix pthread_getcpuclockid test on Solaris (GH-30140)
authorJakub Kulík <Kulikjak@gmail.com>
Sat, 18 Dec 2021 13:26:24 +0000 (14:26 +0100)
committerGitHub <noreply@github.com>
Sat, 18 Dec 2021 13:26:24 +0000 (15:26 +0200)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Lib/test/test_time.py

index f98aec2651d9d77fac5eb937660081918e06fc3e..1aa5874dfe272a2af4a3a42d6f8e0b30f7b67eab 100644 (file)
@@ -117,12 +117,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)