[3.12] gh-126554: correct detection of gcc for TestNullDlsym.test_null_dlsym (GH-129872) (#129945)

gh-126554: correct detection of `gcc` for `TestNullDlsym.test_null_dlsym` (GH-129872)

In case gcc is not available, the test will fail with FileNotFoundError.
So catch the exception to skip the test correctly.
(cherry picked from commit 978211c8a8)

Signed-off-by: Peter Marko <peter.marko@siemens.com>
Co-authored-by: Peter Marko <peter.marko@siemens.com>
This commit is contained in:
Miss Islington (bot) 2025-02-10 11:08:18 +01:00 committed by GitHub
parent 774458884b
commit 3d2ca741dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -58,11 +58,14 @@ class TestNullDlsym(unittest.TestCase):
import subprocess
import tempfile
retcode = subprocess.call(["gcc", "--version"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
if retcode != 0:
try:
retcode = subprocess.call(["gcc", "--version"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
except OSError:
self.skipTest("gcc is missing")
if retcode != 0:
self.skipTest("gcc --version failed")
pipe_r, pipe_w = os.pipe()
self.addCleanup(os.close, pipe_r)