Skip to content

Commit 56103bf

Browse files
committed
Update to hpy 79571e2c558318f10be6f04040e6781ebbadb86f
1 parent e6b441c commit 56103bf

File tree

15 files changed

+74
-17
lines changed

15 files changed

+74
-17
lines changed

graalpython/hpy/.github/workflows/valgrind-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
python-version: 3.9
2424

2525
- name: Install / Upgrade Python dependencies
26-
run: python -m pip install --upgrade pip wheel
26+
run: python -m pip install --upgrade pip wheel setuptools
2727

2828
- name: Build
2929
run: |

graalpython/hpy/hpy/universal/src/hpymodule.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
#ifdef PYPY_VERSION
2323
# error "Cannot build hpy.universal on top of PyPy. PyPy comes with its own version of it"
2424
#endif
25-
#ifdef GRAALVM_PYTHON
26-
# error "Cannot build hpy.universal on top of GraalPy. GraalPy comes with its own version of it"
27-
#endif
2825

2926
static const char *hpy_mode_names[] = {
3027
"MODE_UNIVERSAL",

graalpython/hpy/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from setuptools.command.build_clib import build_clib
55
import platform
66

7-
# this package is supposed to be installed ONLY on CPython. Try to bail out
8-
# with a meaningful error message in other cases.
9-
if sys.implementation.name != 'cpython':
7+
# this package is supposed to be installed ONLY on CPython and GraalPy. Try to
8+
# bail out with a meaningful error message in other cases.
9+
if sys.implementation.name not in ('cpython', 'graalpy'):
1010
msg = 'ERROR: Cannot install and/or update hpy on this python implementation:\n'
1111
msg += f' sys.implementation.name == {sys.implementation.name!r}\n\n'
1212
if '_hpy_universal' in sys.builtin_module_names:

graalpython/hpy/test/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import sys
23
from .support import ExtensionCompiler, DefaultExtensionTemplate,\
34
PythonSubprocessRunner, HPyDebugCapture, make_hpy_abi_fixture
45
from pathlib import Path
@@ -32,6 +33,13 @@ def pytest_configure(config):
3233
"markers", "syncgc: Mark tests that rely on a synchronous GC."
3334
)
3435

36+
37+
def pytest_runtest_setup(item):
38+
if any(item.iter_markers(name="syncgc")):
39+
if sys.implementation.name in ("pypy", "graalpy"):
40+
pytest.skip("requires synchronous garbage collector")
41+
42+
3543
# this is the default set of hpy_abi for all the tests. Individual files and
3644
# classes can override it.
3745
hpy_abi = make_hpy_abi_fixture('default')

graalpython/hpy/test/debug/test_charptr.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import pytest
3-
from ..support import SUPPORTS_SYS_EXECUTABLE, SUPPORTS_MEM_PROTECTION
3+
import sys
4+
from ..support import SUPPORTS_SYS_EXECUTABLE, SUPPORTS_MEM_PROTECTION, IS_GRAALPY
45

56
# Tests detection of usage of char pointers associated with invalid already
67
# closed handles. For now, the debug mode does not provide any hook for this
@@ -13,6 +14,7 @@ def hpy_abi():
1314
yield "debug"
1415

1516

17+
@pytest.mark.skipif(IS_GRAALPY, reason="fails on GraalPy")
1618
@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess")
1719
def test_charptr_use_after_implicit_arg_handle_close(compiler, python_subprocess):
1820
mod = compiler.compile_module("""
@@ -70,6 +72,7 @@ def test_charptr_use_after_implicit_arg_handle_close(compiler, python_subprocess
7072
assert b"UnicodeDecodeError" in result.stderr
7173

7274

75+
@pytest.mark.skipif(IS_GRAALPY, reason="fails on GraalPy")
7376
@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess")
7477
def test_charptr_use_after_handle_close(compiler, python_subprocess):
7578
mod = compiler.compile_module("""
@@ -121,6 +124,7 @@ def test_charptr_use_after_handle_close(compiler, python_subprocess):
121124
assert b"UnicodeDecodeError" in result.stderr
122125

123126

127+
@pytest.mark.skipif(IS_GRAALPY, reason="transiently fails on GraalPy")
124128
@pytest.mark.skipif(not SUPPORTS_MEM_PROTECTION, reason=
125129
"Could be implemented by checking the contents on close.")
126130
@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess")

graalpython/hpy/test/debug/test_context_reuse.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import pytest
2+
import sys
3+
4+
from ..support import IS_GRAALPY
5+
26

37
@pytest.fixture
48
def hpy_abi():
59
return "debug"
610

711

12+
@pytest.mark.skipif(IS_GRAALPY, reason="Hangs on GraalPy")
813
def test_reuse_context_from_global_variable(compiler, python_subprocess):
914
mod = compiler.compile_module("""
1015
#include <stdio.h>

graalpython/hpy/test/debug/test_handles_invalid.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
import sys
33
from hpy.debug.leakdetector import LeakDetector
4-
from ..support import SUPPORTS_SYS_EXECUTABLE, IS_PYTHON_DEBUG_BUILD
4+
from ..support import SUPPORTS_SYS_EXECUTABLE, IS_PYTHON_DEBUG_BUILD, IS_GRAALPY
55
from ..conftest import IS_VALGRIND_RUN
66

77
@pytest.fixture
@@ -12,6 +12,8 @@ def hpy_abi():
1212

1313
@pytest.mark.skipif(sys.implementation.name == 'pypy',
1414
reason="Cannot recover from use-after-close on pypy")
15+
@pytest.mark.skipif(IS_GRAALPY,
16+
reason="This corrupts process memory on GraalPy and crashes later")
1517
def test_no_invalid_handle(compiler, hpy_debug_capture):
1618
# Basic sanity check that valid code does not trigger any error reports
1719
mod = compiler.make_module("""
@@ -38,6 +40,8 @@ def test_no_invalid_handle(compiler, hpy_debug_capture):
3840

3941
@pytest.mark.skipif(sys.implementation.name == 'pypy',
4042
reason="Cannot recover from use-after-close on pypy")
43+
@pytest.mark.skipif(IS_GRAALPY,
44+
reason="This corrupts process memory on GraalPy and crashes later")
4145
def test_cant_use_closed_handle(compiler, hpy_debug_capture):
4246
mod = compiler.make_module("""
4347
HPyDef_METH(f, "f", HPyFunc_O, .doc="double close")
@@ -113,6 +117,8 @@ def test_cant_use_closed_handle(compiler, hpy_debug_capture):
113117

114118
@pytest.mark.skipif(sys.implementation.name == 'pypy',
115119
reason="Cannot recover from use-after-close on pypy")
120+
@pytest.mark.skipif(IS_GRAALPY,
121+
reason="This corrupts process memory on GraalPy and crashes later")
116122
def test_keeping_and_reusing_argument_handle(compiler, hpy_debug_capture):
117123
mod = compiler.make_module("""
118124
HPy keep;
@@ -142,6 +148,7 @@ def test_keeping_and_reusing_argument_handle(compiler, hpy_debug_capture):
142148
assert hpy_debug_capture.invalid_handles_count == 1
143149

144150

151+
@pytest.mark.skipif(IS_GRAALPY, reason="Crashes on GraalPy")
145152
def test_return_ctx_constant_without_dup(compiler, python_subprocess, fatal_exit_code):
146153
# Since this puts the context->h_None into an inconsistent state, we run
147154
# this test in a subprocess and check fatal error instead
@@ -163,6 +170,7 @@ def test_return_ctx_constant_without_dup(compiler, python_subprocess, fatal_exit
163170
assert b"Invalid usage of already closed handle" in result.stderr
164171

165172

173+
@pytest.mark.skipif(IS_GRAALPY, reason="Crashes on GraalPy")
166174
def test_close_ctx_constant(compiler, python_subprocess, fatal_exit_code):
167175
# Since this puts the context->h_True into an inconsistent state, we run
168176
# this test in a subprocess and check fatal error instead
@@ -185,6 +193,7 @@ def test_close_ctx_constant(compiler, python_subprocess, fatal_exit_code):
185193
assert b"Invalid usage of already closed handle" in result.stderr
186194

187195

196+
@pytest.mark.skipif(IS_GRAALPY, reason="Crashes on GraalPy")
188197
def test_invalid_handle_crashes_python_if_no_hook(compiler, python_subprocess, fatal_exit_code):
189198
if not SUPPORTS_SYS_EXECUTABLE:
190199
pytest.skip("no sys.executable")

graalpython/hpy/test/debug/test_misc.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import pytest
2-
from ..support import SUPPORTS_SYS_EXECUTABLE, SUPPORTS_MEM_PROTECTION
2+
import sys
3+
from ..support import SUPPORTS_SYS_EXECUTABLE, SUPPORTS_MEM_PROTECTION, IS_GRAALPY
34

45
@pytest.fixture
56
def hpy_abi():
67
return "debug"
78

89

10+
@pytest.mark.skipif(IS_GRAALPY, reason="hangs on GraalPy")
911
@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess")
1012
def test_use_invalid_as_struct(compiler, python_subprocess):
1113
mod = compiler.compile_module("""
@@ -38,6 +40,7 @@ def test_use_invalid_as_struct(compiler, python_subprocess):
3840
assert "Invalid usage of _HPy_AsStruct_Object" in result.stderr.decode("utf-8")
3941

4042

43+
@pytest.mark.skipif(IS_GRAALPY, reason="hangs on GraalPy")
4144
@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess")
4245
def test_typecheck(compiler, python_subprocess):
4346
mod = compiler.compile_module("""
@@ -60,6 +63,7 @@ def test_typecheck(compiler, python_subprocess):
6063
assert "HPy_TypeCheck arg 2 must be a type" in result.stderr.decode("utf-8")
6164

6265

66+
@pytest.mark.skipif(IS_GRAALPY, reason="hangs on GraalPy")
6367
@pytest.mark.skipif(not SUPPORTS_MEM_PROTECTION, reason=
6468
"Could be implemented by checking the contents on close.")
6569
@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess")
@@ -119,6 +123,7 @@ def test_type_getname(compiler, python_subprocess):
119123
assert result.returncode != 0
120124

121125

126+
@pytest.mark.skipif(IS_GRAALPY, reason="hangs on GraalPy")
122127
@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess")
123128
def test_type_issubtype(compiler, python_subprocess):
124129
mod = compiler.compile_module("""
@@ -143,6 +148,7 @@ def test_type_issubtype(compiler, python_subprocess):
143148
assert "HPyType_IsSubtype arg 1 must be a type" in result.stderr.decode("utf-8")
144149

145150

151+
@pytest.mark.skipif(IS_GRAALPY, reason="transiently fails on GraalPy")
146152
@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess")
147153
def test_unicode_substring(compiler, python_subprocess):
148154
mod = compiler.compile_module("""

graalpython/hpy/test/hpy_devel/test_distutils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import py
1717
import pytest
1818

19-
from ..support import atomic_run, HPY_ROOT
19+
from ..support import atomic_run, HPY_ROOT, IS_GRAALPY
2020

2121
# ====== IMPORTANT DEVELOPMENT TIP =====
2222
# You can use py.test --reuse-venv to speed up local testing.
@@ -43,7 +43,7 @@ def print_CalledProcessError(p):
4343

4444
@pytest.fixture(scope='session')
4545
def venv_template(request, tmpdir_factory):
46-
if request.config.option.reuse_venv:
46+
if getattr(request.config.option, "reuse_venv", False):
4747
d = py.path.local('/tmp/venv-for-hpytest')
4848
if d.check(dir=True):
4949
# if it exists, we assume it's correct. If you want to recreate,
@@ -59,7 +59,7 @@ def venv_template(request, tmpdir_factory):
5959
# it's just easier to use e.g. python -m pip
6060
attach_python_to_venv(d)
6161
for script in d.bin.listdir():
62-
if script.basename.startswith('python'):
62+
if script.basename.startswith(('python', 'graalpy')):
6363
continue
6464
script.remove()
6565
#
@@ -95,7 +95,7 @@ def initargs(self, pytestconfig, tmpdir, venv_template):
9595
self.tmpdir = tmpdir
9696
# create a fresh venv by copying the template
9797
self.venv = tmpdir.join('venv')
98-
shutil.copytree(venv_template, self.venv)
98+
shutil.copytree(venv_template, self.venv, symlinks=True)
9999
attach_python_to_venv(self.venv)
100100
# create the files for our test project
101101
self.hpy_test_project = tmpdir.join('hpy_test_project').ensure(dir=True)
@@ -290,6 +290,7 @@ def test_hpymod_wheel(self, hpy_abi):
290290
doc = self.get_docstring('hpymod')
291291
assert doc == f'hpymod with HPy ABI: {hpy_abi}'
292292

293+
@pytest.mark.skipif(IS_GRAALPY, reason='not supported on GraalPy')
293294
def test_dont_mix_cpython_and_universal_abis(self):
294295
"""
295296
See issue #322
@@ -328,6 +329,8 @@ def test_dont_mix_cpython_and_universal_abis(self):
328329
def test_hpymod_legacy(self, hpy_abi):
329330
if hpy_abi == 'universal':
330331
pytest.skip('only for cpython and hybrid ABIs')
332+
if IS_GRAALPY:
333+
pytest.skip('not supported on GraalPy')
331334
self.gen_setup_py("""
332335
setup(name = "hpy_test_project",
333336
hpy_ext_modules = [hpymod_legacy],

graalpython/hpy/test/support.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# True if we are running on the CPython debug build
2020
IS_PYTHON_DEBUG_BUILD = hasattr(sys, 'gettotalrefcount')
2121

22+
IS_GRAALPY = getattr(getattr(sys, "implementation", None), "name", None) == 'graalpy'
23+
2224
# pytest marker to run tests only on linux
2325
ONLY_LINUX = pytest.mark.skipif(sys.platform!='linux', reason='linux only')
2426

@@ -441,6 +443,7 @@ def run(self, mod, code):
441443

442444
@pytest.mark.usefixtures('initargs')
443445
class HPyTest:
446+
is_graalpy = IS_GRAALPY # Exposed here for tests running as PyPy apptests
444447
ExtensionTemplate = DefaultExtensionTemplate
445448

446449
@pytest.fixture()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy