diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-05 18:23:30 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-05 18:23:30 +0000 |
commit | 4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7 (patch) | |
tree | 866986558761a9709a7af1940ba607128a45f775 /tests | |
parent | Releasing debian version 2.1.2-2. (diff) | |
download | nvme-cli-4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7.tar.xz nvme-cli-4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7.zip |
Merging upstream version 2.2.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/meson.build | 19 | ||||
-rw-r--r-- | tests/nvme_copy_test.py | 2 | ||||
-rw-r--r-- | tests/nvme_dsm_test.py | 2 | ||||
-rw-r--r-- | tests/nvme_get_lba_status_test.py | 2 | ||||
-rw-r--r-- | tests/nvme_lba_status_log_test.py | 2 | ||||
-rw-r--r-- | tests/nvme_verify_test.py | 2 | ||||
-rw-r--r-- | tests/test-uint128.c | 62 |
7 files changed, 84 insertions, 7 deletions
diff --git a/tests/meson.build b/tests/meson.build index bc49d05..6f17137 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -32,6 +32,12 @@ tests = [ runtests = find_program('nose2', required : false) +if meson.version().version_compare('>= 0.56') + nvmecli_path = meson.project_build_root() +else + nvmecli_path = meson.build_root() +endif + if runtests.found() foreach file : infra + tests configure_file( @@ -43,12 +49,21 @@ if runtests.found() foreach t : tests t_name = t.split('.')[0] test(t_name, runtests, - args: ['--verbose', '--start-dir', meson.build_root() + '/tests', t_name], - env: ['PATH=' + meson.build_root() + ':/usr/bin:/usr/sbin'], + args: ['--verbose', '--start-dir', meson.current_build_dir(), t_name], + env: ['PATH=' + nvmecli_path + ':/usr/bin:/usr/sbin'], timeout: 500) endforeach endif +test_uint128 = executable( + 'test-uint128', + ['test-uint128.c', '../util/types.c'], + include_directories: [incdir, '..'], + dependencies: [libnvme_dep], +) + +test('uint128', test_uint128) + python_module = import('python') python = python_module.find_installation('python3') diff --git a/tests/nvme_copy_test.py b/tests/nvme_copy_test.py index 12676ea..d84a6d2 100644 --- a/tests/nvme_copy_test.py +++ b/tests/nvme_copy_test.py @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of nvme-cli # diff --git a/tests/nvme_dsm_test.py b/tests/nvme_dsm_test.py index 7d5e477..d92bf58 100644 --- a/tests/nvme_dsm_test.py +++ b/tests/nvme_dsm_test.py @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of nvme-cli # diff --git a/tests/nvme_get_lba_status_test.py b/tests/nvme_get_lba_status_test.py index 924a7ce..539c493 100644 --- a/tests/nvme_get_lba_status_test.py +++ b/tests/nvme_get_lba_status_test.py @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of nvme-cli # diff --git a/tests/nvme_lba_status_log_test.py b/tests/nvme_lba_status_log_test.py index 90bfe91..c91d1e5 100644 --- a/tests/nvme_lba_status_log_test.py +++ b/tests/nvme_lba_status_log_test.py @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of nvme-cli # diff --git a/tests/nvme_verify_test.py b/tests/nvme_verify_test.py index 68e5165..7c30828 100644 --- a/tests/nvme_verify_test.py +++ b/tests/nvme_verify_test.py @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of nvme-cli # diff --git a/tests/test-uint128.c b/tests/test-uint128.c new file mode 100644 index 0000000..6301a38 --- /dev/null +++ b/tests/test-uint128.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +#include "../util/types.h" + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + +/* create a uint128_t from four uint32_ts. w0 is the most significant value, + * w2 the least */ +#define U128(w0, w1, w2, w3) { .words = { w0, w1, w2, w3 } } + +static int test_rc; + +static void check_str(nvme_uint128_t val, const char *exp, const char *res) +{ + if (!strcmp(res, exp)) + return; + + printf("ERROR: printing {%08x.%08x.%08x.%08x}, got '%s', expected '%s'\n", + val.words[3], val.words[2], val.words[1], val.words[0], + res, exp); + + test_rc = 1; +} + +struct tostr_test { + nvme_uint128_t val; + const char *exp; +}; + +static struct tostr_test tostr_tests[] = { + { U128(0, 0, 0, 0), "0" }, + { U128(0, 0, 0, 1), "1" }, + { U128(0, 0, 0, 10), "10" }, + { U128(4, 3, 2, 1), "316912650112397582603894390785" }, + { + U128(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), + "340282366920938463463374607431768211455" + }, +}; + +void tostr_test(struct tostr_test *test) +{ + char *str; + str = uint128_t_to_string(test->val); + check_str(test->val, test->exp, str); +} + +int main(void) +{ + unsigned int i; + + test_rc = 0; + + for (i = 0; i < ARRAY_SIZE(tostr_tests); i++) + tostr_test(&tostr_tests[i]); + + return test_rc ? EXIT_FAILURE : EXIT_SUCCESS; +} |