From 0b5df09d4abc178e041ad1b16204dc364a3a12ae Mon Sep 17 00:00:00 2001 From: Benjamin Zaitlen Date: Mon, 20 Nov 2023 12:16:06 -0500 Subject: [PATCH] Additional cleanup (#12) * add missing license metadata and remove skips in tests * lint * lint --- pynvjitlink/VERSION | 1 + pynvjitlink/tests/test_pynvjitlink.py | 16 +++------------- pynvjitlink/tests/test_pynvjitlink_api.py | 17 ++++------------- pyproject.toml | 6 ++++++ 4 files changed, 14 insertions(+), 26 deletions(-) create mode 100644 pynvjitlink/VERSION diff --git a/pynvjitlink/VERSION b/pynvjitlink/VERSION new file mode 100644 index 00000000..6e8bf73a --- /dev/null +++ b/pynvjitlink/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/pynvjitlink/tests/test_pynvjitlink.py b/pynvjitlink/tests/test_pynvjitlink.py index f08eb4ab..bad1ceea 100644 --- a/pynvjitlink/tests/test_pynvjitlink.py +++ b/pynvjitlink/tests/test_pynvjitlink.py @@ -49,7 +49,6 @@ 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, @@ -57,7 +56,6 @@ def test_create_no_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, @@ -65,14 +63,12 @@ def test_invalid_arch_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'): @@ -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) @@ -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 @@ -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): diff --git a/pynvjitlink/tests/test_pynvjitlink_api.py b/pynvjitlink/tests/test_pynvjitlink_api.py index ab7e615d..a7c8650b 100644 --- a/pynvjitlink/tests/test_pynvjitlink_api.py +++ b/pynvjitlink/tests/test_pynvjitlink_api.py @@ -31,7 +31,6 @@ 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, @@ -39,7 +38,6 @@ def test_create_no_arch_error(): NvJitLinker() -@pytest.mark.skip def test_invalid_arch_error(): # sm_XX is not a valid architecture with pytest.raises(NvJitLinkError, @@ -47,7 +45,6 @@ def test_invalid_arch_error(): NvJitLinker('-arch=sm_XX') -@pytest.mark.skip def test_invalid_option_type_error(): with pytest.raises(TypeError, match='Expecting only strings'): @@ -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' @@ -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' @@ -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' @@ -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 @@ -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' diff --git a/pyproject.toml b/pyproject.toml index f11ded5f..245e7509 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"}