Skip to content

Commit 72549a1

Browse files
committed
Adjust test case to check for pointer access
1 parent b091a50 commit 72549a1

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_ctypes_callbacks.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,28 @@ class _dl_phdr_info(ctypes.Structure):
101101
_RTLD_NOLOAD = ctypes.DEFAULT_MODE
102102

103103
libc_name = find_library("c")
104-
LIBC = None if libc_name is None else ctypes.CDLL(libc_name, mode=_RTLD_NOLOAD)
104+
LIBC = None
105+
if libc_name is not None:
106+
try:
107+
LIBC = ctypes.CDLL(libc_name, mode=_RTLD_NOLOAD)
108+
except OSError:
109+
# we most certainly don't have permission to load a native library
110+
# so, this test is irrelevant in this case.
111+
pass
105112
CNT = 0
106-
113+
DLPI_LIST = []
107114

108115
def _callback(info, size, data):
109116
global CNT
117+
global DLPI_LIST
118+
# Get the path of the current library
119+
filepath = info.contents.dlpi_name
120+
if filepath:
121+
filepath = filepath.decode("utf-8")
122+
123+
DLPI_LIST.append(filepath)
124+
# Store the library controller if it is supported and selected
125+
# self._make_controller_from_path(filepath)
110126
CNT += 1
111127
return 0
112128

@@ -125,4 +141,5 @@ def test_libc_callbacks():
125141
data = ctypes.c_char_p(b"")
126142
LIBC.dl_iterate_phdr(c_match_library_callback, data)
127143

144+
assert len(DLPI_LIST) > 0, "no library was found!"
128145
assert CNT > 0, "no callbacks have been called"

0 commit comments

Comments
 (0)