-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(py): remove Cython header and bindings using it
This removes the xNVMe Cython bindings and header. The intent is to provide a single set of Python bindings, and that these are based on a minimal toolchain requirements, that is, the built-in ctypes FFI. The "xnvme-core" is moved into "bindings". * add clang2py include-path for macos The tests implemented using the Cython bindings are "ported" to use the ctypes-bindings instead, and placed in "tests". Changes to "tests" during porting: * Change definition of NULL to None - This was defined using a class, however, ctypes represent and treat the Python None type as NULL, thus, no need to wrap it, however, for readability NULL might be preferred, thus keeping it as an alias for None * Remove duplicate definitions of NULL and UINT16_MAX - These now only reside in tests/utils.py * conftest - Rename variables retrieved via environment variables - Assert that environment variables are defined, inform when they are not - Embed 'opts' fixture inside 'dev' fixture - Use xnvme_opts_set_defaults() instead of xnvme_opts_default() Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
- Loading branch information
Showing
52 changed files
with
113 additions
and
2,309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 21 additions & 23 deletions
44
...nvme/cython_bindings/tests/test_basics.py → cijoe/tests/bindings/test_basics.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,51 @@ | ||
import xnvme.cython_bindings as xnvme | ||
import pytest | ||
|
||
import xnvme | ||
|
||
def test_version(): | ||
from ..conftest import xnvme_parametrize | ||
|
||
|
||
def test_version(cijoe): | ||
# Very simple test that checks the bindings without an NVMe disk | ||
assert xnvme.xnvme_ver_major() == 0, "Has major version been updated?" | ||
assert xnvme.xnvme_ver_minor() >= 3 | ||
assert xnvme.xnvme_ver_patch() >= 0 | ||
|
||
|
||
def test_libconf(): | ||
fd = xnvme.FILE() | ||
fd.tmpfile() | ||
xnvme.xnvme_libconf_fpr(fd, xnvme.XNVME_PR_DEF) | ||
data = fd.getvalue() | ||
print(data.decode()) | ||
assert len(data) != 0, "libconf file-stream is empty!" | ||
def test_xnvme_ver_fpr(cijoe): | ||
count = xnvme.xnvme_ver_pr(xnvme.XNVME_PR_DEF) | ||
assert count, "version file-stream is empty!" | ||
|
||
|
||
def test_xnvme_ver_fpr(): | ||
fd = xnvme.FILE() | ||
fd.tmpfile() | ||
xnvme.xnvme_ver_fpr(fd, xnvme.XNVME_PR_DEF) | ||
data = fd.getvalue() | ||
print(data.decode()) | ||
assert len(data) != 0, "version file-stream is empty!" | ||
def test_libconf(cijoe): | ||
count = xnvme.xnvme_libconf_pr(xnvme.XNVME_PR_DEF) | ||
|
||
assert count, "libconf file-stream is empty!" | ||
|
||
def test_dev(dev): | ||
|
||
def test_dev(cijoe, dev): | ||
assert dev, xnvme.xnvme_dev_pr(dev, xnvme.XNVME_PR_DEF) | ||
|
||
|
||
def test_ident(dev): | ||
def test_ident(cijoe, dev): | ||
ident = xnvme.xnvme_dev_get_ident(dev) | ||
|
||
assert ident.nsid == 1 | ||
assert ident.to_dict() | ||
|
||
|
||
def test_pointers(dev): | ||
def test_pointers(cijoe, dev): | ||
# A random xNVMe object which is easy to create | ||
ctx = xnvme.xnvme_cmd_ctx_from_dev(dev) | ||
|
||
# Verify that we are pointing to the struct cmd embedded at the origin of ctx (they will share address) | ||
assert ctx.void_pointer == ctx.cmd.void_pointer | ||
assert ctx == ctx.cmd | ||
|
||
# Verify that we are pointing to the struct cpl embedded at the origin of ctx + the size of cmd | ||
assert ctx.void_pointer + ctx.cmd.sizeof == ctx.cpl.void_pointer | ||
assert ctx + ctx.cmd.sizeof == ctx.cpl | ||
|
||
# Check pointers are well defined and stable -- i.e. not generated at each call | ||
assert ctx.dev.void_pointer == ctx.dev.void_pointer | ||
assert ctx.dev == ctx.dev | ||
|
||
# Check that a pointer from two places to the same struct shows the same address | ||
assert ctx.dev.void_pointer == xnvme.xnvme_dev_get_geo(ctx.dev).void_pointer | ||
assert ctx.dev == xnvme.xnvme_dev_get_geo(ctx.dev) |
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
cijoe/tests/bindings/test_ctypes.py → cijoe/tests/bindings/test_py_bindings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.