Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
e28778ae
Commit
e28778ae
authored
Nov 01, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Repair and extend TSS API test.
parent
8fdb0fbe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
11 deletions
+30
-11
tests/run/tss.pyx
tests/run/tss.pyx
+30
-11
No files found.
tests/run/tss.pyx
View file @
e28778ae
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
from
cpython.pythread
cimport
*
from
cpython.pythread
cimport
*
def
tss_create_delete
():
def
tss_create_delete
():
"""
"""
>>> tss_create_delete()
>>> tss_create_delete()
...
@@ -9,29 +10,48 @@ def tss_create_delete():
...
@@ -9,29 +10,48 @@ def tss_create_delete():
"""
"""
cdef
Py_tss_t
tss_key
=
Py_tss_NEEDS_INIT
cdef
Py_tss_t
tss_key
=
Py_tss_NEEDS_INIT
cdef
bint
after_create
,
after_delete
cdef
bint
after_create
,
after_delete
if
PyThread_tss_create
(
&
tss_key
)
>
0
:
if
PyThread_tss_create
(
&
tss_key
)
!=
0
:
# handle key creation failure
raise
MemoryError
()
pass
after_create
=
PyThread_tss_is_created
(
&
tss_key
)
!=
0
after_create
=
PyThread_tss_is_created
(
&
tss_key
)
!=
0
PyThread_tss_delete
(
&
tss_key
)
PyThread_tss_delete
(
&
tss_key
)
after_delete
=
PyThread_tss_is_created
(
&
tss_key
)
!=
0
after_delete
=
PyThread_tss_is_created
(
&
tss_key
)
!=
0
return
(
after_create
,
after_delete
)
return
(
after_create
,
after_delete
)
def
tss_alloc_free
():
def
tss_alloc_free
():
"""
"""
>>> tss_alloc_free()
>>> tss_alloc_free()
(True, False)
False
"""
cdef
Py_tss_t
*
ptr_key
cdef
bint
after_alloc
,
after_free
ptr_key
=
PyThread_tss_alloc
()
if
ptr_key
==
NULL
:
raise
MemoryError
()
after_alloc
=
PyThread_tss_is_created
(
ptr_key
)
!=
0
PyThread_tss_free
(
ptr_key
)
return
after_alloc
def
tss_alloc_create_delete_free
():
"""
>>> tss_alloc_create_delete_free()
(False, True, False)
"""
"""
cdef
Py_tss_t
*
ptr_key
cdef
Py_tss_t
*
ptr_key
cdef
bint
after_alloc
,
after_free
cdef
bint
after_alloc
,
after_free
ptr_key
=
PyThread_tss_alloc
()
ptr_key
=
PyThread_tss_alloc
()
if
ptr_key
==
NULL
:
if
ptr_key
==
NULL
:
# handle key allocation failure
raise
MemoryError
()
pass
after_alloc
=
PyThread_tss_is_created
(
ptr_key
)
!=
0
after_alloc
=
PyThread_tss_is_created
(
ptr_key
)
!=
0
if
PyThread_tss_create
(
ptr_key
)
!=
0
:
raise
MemoryError
()
after_create
=
PyThread_tss_is_created
(
ptr_key
)
!=
0
PyThread_tss_delete
(
ptr_key
)
after_delete
=
PyThread_tss_is_created
(
ptr_key
)
!=
0
PyThread_tss_free
(
ptr_key
)
PyThread_tss_free
(
ptr_key
)
after_free
=
PyThread_tss_is_created
(
ptr_key
)
!=
0
return
(
after_alloc
,
after_create
,
after_delete
)
return
(
after_alloc
,
after_free
)
def
tss_set_get
():
def
tss_set_get
():
"""
"""
...
@@ -41,9 +61,8 @@ def tss_set_get():
...
@@ -41,9 +61,8 @@ def tss_set_get():
cdef
Py_tss_t
tss_key
=
Py_tss_NEEDS_INIT
cdef
Py_tss_t
tss_key
=
Py_tss_NEEDS_INIT
cdef
int
the_value
=
1
cdef
int
the_value
=
1
cdef
int
ret_value
cdef
int
ret_value
if
PyThread_tss_create
(
&
tss_key
)
>
0
:
if
PyThread_tss_create
(
&
tss_key
)
!=
0
:
# handle key creation failure
raise
MemoryError
()
pass
if
PyThread_tss_get
(
&
tss_key
)
==
NULL
:
if
PyThread_tss_get
(
&
tss_key
)
==
NULL
:
PyThread_tss_set
(
&
tss_key
,
<
void
*>&
the_value
)
PyThread_tss_set
(
&
tss_key
,
<
void
*>&
the_value
)
ret_value
=
(
<
int
*>
PyThread_tss_get
(
&
tss_key
))[
0
]
ret_value
=
(
<
int
*>
PyThread_tss_get
(
&
tss_key
))[
0
]
...
...
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