]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
unit: Move unit tests to a new directory
authorDaniel Wagner <dwagner@suse.de>
Tue, 3 Jan 2023 17:46:57 +0000 (18:46 +0100)
committerDaniel Wagner <dwagner@suse.de>
Tue, 3 Jan 2023 17:46:57 +0000 (18:46 +0100)
The tests directory contains a test framework for testing
real hardware and are thus no real unit tests. As these
tests are reading and writing data to /dev/nvme0 we should
disable them per default.

To distinguish between the real unit tests and the nvme test
framework move all unit test to a new directory.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
meson.build
meson_options.txt
tests/README
tests/meson.build
unit/meson.build [new file with mode: 0644]
unit/test-suffix-si-parse.c [moved from tests/test-suffix-si-parse.c with 100% similarity]
unit/test-uint128.c [moved from tests/test-uint128.c with 100% similarity]

index c83d6403f61245856bf968a07ded943473a70f58..719aa0e5f4bcaef28163ed0adcf4923ef67f0ed0 100644 (file)
@@ -249,7 +249,10 @@ sources = [
 
 subdir('ccan')
 subdir('plugins')
-subdir('tests')
+subdir('unit')
+if get_option('nvme-tests')
+    subdir('tests')
+endif
 subdir('util')
 subdir('Documentation')
 
index fd9051101f0d5ac6e1542062e13d3a14990bb06f..cba027f73514d5e7c55ef8fd11ee58420a0a1959 100644 (file)
@@ -5,6 +5,6 @@ option('dracutrulesdir', type : 'string', value : 'lib/dracut/dracut.conf.d/', d
 option('systemddir', type : 'string', value : 'lib/systemd/system', description : 'directory for systemd files')
 option('htmldir', type : 'string', value : '', description : 'directory for HTML documentation')
 option('systemctl', type : 'string', value : '/usr/bin/systemctl', description : 'path to systemctl binary')
-
+option('nvme-tests', type : 'boolean', value : false, description: 'Run tests against real hardware')
 option('docs', type : 'combo', choices : ['false', 'html', 'man', 'all'], description : 'install documentation')
 option('docs-build', type : 'boolean', value : false,  description : 'build documentation')
index 14b24e5080667e75d84daa51de4654d378dc1804..a5fa7084fdf09e2146e0718ed29778be9abfa960 100644 (file)
@@ -1,13 +1,20 @@
 nvmetests
 =========
 
-    This contains NVMe unit tests framework. The purpose of this framework
+    This contains a NVMe tests framework. The purpose of this framework
     to use nvme cli and test various supported commands and scenarios for
     NVMe device.
 
-    In current implementation this framework uses nvme cli to
+    In current implementation this framework uses nvme-cli to
     interact with underlying controller/namespace.
 
+    Note these tests expect to run against real hardware and will
+    read and write data to /dev/nvme0!
+
+    DO NOT RUN THEM IF YOU DO NOT KNOW WHAT YOU ARE DOING!
+
+    You have been warned.
+
 1. Common Package Dependencies
 ------------------------------
 
index 4095fba561170148676586970dbabec7ffb8de60..630f35db3e4af86727c7ff976c284ec377d85afb 100644 (file)
@@ -55,24 +55,6 @@ if runtests.found()
   endforeach
 endif
 
-test_uint128 = executable(
-    'test-uint128',
-    ['test-uint128.c', '../util/types.c'],
-    include_directories: [incdir, '..'],
-    dependencies: [libnvme_dep],
-)
-
-test('uint128', test_uint128)
-
-test_suffix_si_parse = executable(
-    'test-suffix-si-parse',
-    ['test-suffix-si-parse.c', '../util/suffix.c'],
-    include_directories: [incdir, '..'],
-    dependencies: [libnvme_dep],
-)
-
-test('suffix_si_parse', test_suffix_si_parse)
-
 python_module = import('python')
 
 python = python_module.find_installation('python3')
diff --git a/unit/meson.build b/unit/meson.build
new file mode 100644 (file)
index 0000000..f9d2e10
--- /dev/null
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+test_uint128 = executable(
+    'test-uint128',
+    ['test-uint128.c', '../util/types.c'],
+    include_directories: [incdir, '..'],
+    dependencies: [libnvme_dep],
+)
+
+test('uint128', test_uint128)
+
+test_suffix_si_parse = executable(
+    'test-suffix-si-parse',
+    ['test-suffix-si-parse.c', '../util/suffix.c'],
+    include_directories: [incdir, '..'],
+    dependencies: [libnvme_dep],
+)
+
+test('suffix_si_parse', test_suffix_si_parse)
similarity index 100%
rename from tests/test-uint128.c
rename to unit/test-uint128.c