Skip to content

Commit

Permalink
Additional cleanup (#12)
Browse files Browse the repository at this point in the history
* add missing license metadata and remove skips in tests

* lint

* lint
  • Loading branch information
quasiben authored Nov 20, 2023
1 parent e583cc7 commit 0b5df09
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 26 deletions.
1 change: 1 addition & 0 deletions pynvjitlink/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
16 changes: 3 additions & 13 deletions pynvjitlink/tests/test_pynvjitlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,26 @@ def undefined_extern_cubin():
return read_test_file('undefined_extern.cubin')


@pytest.mark.skip
def test_create_no_arch_error():
# nvjitlink expects at least the architecture to be specified.
with pytest.raises(RuntimeError,
match='NVJITLINK_ERROR_MISSING_ARCH error'):
_nvjitlinklib.create()


@pytest.mark.skip('Causes fatal error and exit(1)')
def test_invalid_arch_error():
# sm_XX is not a valid architecture
with pytest.raises(RuntimeError,
match='NVJITLINK_ERROR_UNRECOGNIZED_OPTION error'):
_nvjitlinklib.create('-arch=sm_XX')


@pytest.mark.skip
def test_unrecognized_option_error():
with pytest.raises(RuntimeError,
match='NVJITLINK_ERROR_UNRECOGNIZED_OPTION error'):
_nvjitlinklib.create('-fictitious_option')


@pytest.mark.skip
def test_invalid_option_type_error():
with pytest.raises(TypeError,
match='Expecting only strings'):
Expand Down Expand Up @@ -100,9 +96,7 @@ def test_complete_empty():
marks=pytest.mark.xfail),
('device_functions_ptx', InputType.PTX),
('device_functions_object', InputType.OBJECT),
# XXX: Archive type needs debugging - results in a segfault.
pytest.param('device_functions_archive', InputType.LIBRARY,
marks=pytest.mark.skip),
('device_functions_archive', InputType.LIBRARY),
])
def test_add_file(input_file, input_type, request):
filename, data = request.getfixturevalue(input_file)
Expand All @@ -112,7 +106,6 @@ def test_add_file(input_file, input_type, request):
_nvjitlinklib.destroy(handle)


@pytest.mark.skip
def test_get_error_log(undefined_extern_cubin):
handle = _nvjitlinklib.create('-arch=sm_75')
filename, data = undefined_extern_cubin
Expand All @@ -122,11 +115,8 @@ def test_get_error_log(undefined_extern_cubin):
_nvjitlinklib.complete(handle)
error_log = _nvjitlinklib.get_error_log(handle)
_nvjitlinklib.destroy(handle)
# XXX: The error message in the log is strange. The actual expected error
# message appears on the terminal:
# error : Undefined reference to '_Z5undefff' in
# 'undefined_extern.cubin'
assert "ERROR 9: finish" in error_log
assert "Undefined reference to '_Z5undefff' " \
"in 'undefined_extern.cubin'" in error_log


def test_get_info_log(device_functions_cubin):
Expand Down
17 changes: 4 additions & 13 deletions pynvjitlink/tests/test_pynvjitlink_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,20 @@ def undefined_extern_cubin():
return f.read()


@pytest.mark.skip
def test_create_no_arch_error():
# nvlink expects at least the architecture to be specified.
with pytest.raises(NvJitLinkError,
match='NVJITLINK_ERROR_MISSING_ARCH error'):
NvJitLinker()


@pytest.mark.skip
def test_invalid_arch_error():
# sm_XX is not a valid architecture
with pytest.raises(NvJitLinkError,
match='NVJITLINK_ERROR_UNRECOGNIZED_OPTION error'):
NvJitLinker('-arch=sm_XX')


@pytest.mark.skip
def test_invalid_option_type_error():
with pytest.raises(TypeError,
match='Expecting only strings'):
Expand All @@ -65,7 +62,6 @@ def test_add_cubin(device_functions_cubin):
nvjitlinker.add_cubin(device_functions_cubin, name)


@pytest.mark.skip
def test_add_incompatible_cubin_arch_error(device_functions_cubin):
nvjitlinker = NvJitLinker('-arch=sm_70')
name = 'test_device_functions.cubin'
Expand All @@ -86,7 +82,6 @@ def test_add_fatbin_sm70(device_functions_fatbin):
nvjitlinker.add_fatbin(device_functions_fatbin, name)


@pytest.mark.skip
def test_add_incompatible_fatbin_arch_error(device_functions_fatbin):
nvjitlinker = NvJitLinker('-arch=sm_80')
name = 'test_device_functions.fatbin'
Expand All @@ -95,7 +90,6 @@ def test_add_incompatible_fatbin_arch_error(device_functions_fatbin):
nvjitlinker.add_fatbin(device_functions_fatbin, name)


@pytest.mark.skip
def test_add_cubin_with_fatbin_error(device_functions_fatbin):
nvjitlinker = NvJitLinker('-arch=sm_75')
name = 'test_device_functions.fatbin'
Expand All @@ -104,16 +98,14 @@ def test_add_cubin_with_fatbin_error(device_functions_fatbin):
nvjitlinker.add_cubin(device_functions_fatbin, name)


@pytest.mark.skip
def test_add_fatbin_with_cubin(device_functions_cubin):
# Adding a cubin with add_fatbin seems to work - this may be expected
# behaviour.
def test_add_fatbin_with_cubin_error(device_functions_cubin):
nvjitlinker = NvJitLinker('-arch=sm_75')
name = 'test_device_functions.cubin'
nvjitlinker.add_fatbin(device_functions_cubin, name)
with pytest.raises(NvJitLinkError,
match='NVJITLINK_ERROR_INVALID_INPUT error'):
nvjitlinker.add_fatbin(device_functions_cubin, name)


@pytest.mark.skip
def test_duplicate_symbols_cubin_and_fatbin(device_functions_cubin,
device_functions_fatbin):
# This link errors because the cubin and the fatbin contain the same
Expand Down Expand Up @@ -145,7 +137,6 @@ def test_get_linked_cubin(device_functions_cubin):
assert cubin[:4] == b'\x7fELF'


@pytest.mark.skip
def test_get_error_log(undefined_extern_cubin):
nvjitlinker = NvJitLinker('-arch=sm_75')
name = 'undefined_extern.cubin'
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ authors = [
]
license = { text = "Apache 2.0" }
requires-python = ">=3.9"

[tool.setuptools]
license-files = ["LICENSE"]

[tool.setuptools.dynamic]
version = {file = "pynvjitlink/VERSION"}

0 comments on commit 0b5df09

Please sign in to comment.