Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
68aa2401
Commit
68aa2401
authored
Mar 03, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fff59cb0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
4 deletions
+57
-4
bigfile/tests/test_virtmem.c
bigfile/tests/test_virtmem.c
+1
-0
wcfs/internal/wcfs_test.pyx
wcfs/internal/wcfs_test.pyx
+56
-4
No files found.
bigfile/tests/test_virtmem.c
View file @
68aa2401
...
...
@@ -340,6 +340,7 @@ void test_file_access_synthetic(void)
int
err
;
/* MUST_FAULT(code) - checks that code faults */
/* somewhat dup in wcfs_test.pyx */
sigjmp_buf
fault_jmp
;
volatile
int
fault_expected
=
0
;
void
sigfault_handler
(
int
sig
)
{
...
...
wcfs/internal/wcfs_test.pyx
View file @
68aa2401
...
...
@@ -23,8 +23,9 @@
"""Module wcfs_test.pyx complements wcfs_test.py with things that cannot be
implemented in Python."""
from
posix.signal
cimport
sigaction
,
sigaction_t
,
siginfo_t
,
SA_SIGINFO
from
libc.signal
cimport
SIGBUS
from
posix.signal
cimport
sigaction
,
sigaction_t
,
siginfo_t
,
SA_SIGINFO
,
sigemptyset
from
libc.signal
cimport
SIGBUS
,
SIGSEGV
from
libc.setjmp
cimport
sigjmp_buf
,
sigsetjmp
,
siglongjmp
from
libc.stdlib
cimport
abort
from
libc.string
cimport
strlen
from
posix.unistd
cimport
write
,
sleep
...
...
@@ -32,8 +33,8 @@ from posix.types cimport off_t
from
cpython.exc
cimport
PyErr_SetFromErrno
from
golang
cimport
chan
,
pychan
,
select
,
panic
,
topyexc
from
golang
cimport
time
from
golang
cimport
chan
,
pychan
,
select
,
panic
,
topyexc
,
cbool
from
golang
cimport
sync
,
time
# _tDB is pyx part of tDB.
cdef
class
_tDB
:
...
...
@@ -86,6 +87,57 @@ def read_nogil(const unsigned char[::1] mem not None) -> bytes:
return
bytes
(
bytearray
([
b
]))
# read_mustfault verifies that read-access to mem causes SIGSEGV.
cdef
sync
.
Mutex
mustfaultMu
# one at a time as sigaction is per-process
cdef
sigjmp_buf
mustfaultJmp
cdef
cbool
faultExpected
=
False
cdef
cbool
faultedOk
=
False
cdef
unsigned
char
mustfaultG
# global var for compiler not to optimize-out p[0] access
cdef
void
mustfaultSighand
(
int
sig
)
nogil
:
if
not
faultExpected
:
panic
(
"unexpected fault"
)
# just return from sighandler to proper place
faultedOk
=
True
siglongjmp
(
mustfaultJmp
,
1
)
cdef
void
_read_mustfault
(
const
unsigned
char
*
p
)
nogil
except
+
topyexc
:
global
faultExpected
,
faultedOk
cdef
sigaction_t
act
,
saveact
act
.
sa_handler
=
mustfaultSighand
act
.
sa_flags
=
0
sigemptyset
(
&
act
.
sa_mask
)
# XXX err
sigaction
(
SIGSEGV
,
&
act
,
&
saveact
)
# XXX err
faultExpected
=
True
faultedOk
=
False
if
sigsetjmp
(
mustfaultJmp
,
1
)
==
0
:
mustfaultG
=
p
[
0
]
# should pagefault -> sighandler does longjmp
panic
(
"not faulted"
)
# XXX -> just error ?
else
:
# faulted
if
not
faultedOk
:
panic
(
"faulted, but !faultedOk"
)
faultExpected
=
False
sigaction
(
SIGSEGV
,
&
saveact
,
NULL
)
# XXX err
def
read_mustfault
(
const
unsigned
char
[::
1
]
mem
not
None
):
assert
len
(
mem
)
==
1
,
"read_mustfault: only [1] mem is supported for now"
# somewhat dup of MUST_FAULT in test_virtmem.c
with
nogil
:
mustfaultMu
.
lock
()
_read_mustfault
(
&
mem
[
0
])
mustfaultMu
.
unlock
()
# --------
cdef
extern
from
"<fcntl.h>"
nogil
:
int
posix_fadvise
(
int
fd
,
off_t
offset
,
off_t
len
,
int
advice
);
enum
:
POSIX_FADV_DONTNEED
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment