Debian Codegraph @

tests/README

raw
1 nvmetests
2 =========
3
4 This contains a NVMe tests framework. The purpose of this framework
5 to use nvme cli and test various supported commands and scenarios for
6 NVMe device.
7
8 In current implementation this framework uses nvme-cli to
9 interact with underlying controller/namespace.
10
11 Note these tests expect to run against real hardware and will
12 read and write data to /dev/nvme0!
13
14 DO NOT RUN THEM IF YOU DO NOT KNOW WHAT YOU ARE DOING!
15
16 You have been warned.
17
18 1. Common Package Dependencies
19 ------------------------------
20
21 1. Python(>= 3.3)
22 2. nose2 (Installation guide http://nose2.readthedocs.io/)
23 3. flake8 (https://pypi.python.org/pypi/flake8)
24 4. mypy (https://pypi.org/project/mypy/)
25 5. autopep8 (https://pypi.org/project/autopep8/)
26 6. isort (https://pypi.org/project/isort/)
27
28 Python package management system pip can be used to install most of the
29 listed packages(https://pip.pypa.io/en/stable/installing/) :-
30 $ pip install nose2 flake8 mypy autopep8 isort
31
32 2. Overview
33 -----------
34
35 This framework follows simple class hierarchy. Each test file contains
36 one test. Each test is direct subclass or indirect subclass of TestNVMe
37 class which represents one testcase. To write a new testcase one can copy
38 existing template "nvme_simple_template_test.py" and start adding new
39 testcase specific functionality. For detailed information please look into
40 section 3.
41
42 For more information about tests, class hierarchy and code please refer :-
43
44 1. Documentation :- html/
45 2. Class Index :- html/index.html
46 3. Class Hierarchy :- html/class-tree.html
47
48 For each testcase it will create log directory mentioned in
49 configuration file. This directory will be used for a temporary files
50 and storing execution logs of each testcases. Current implementation stores
51 stdout and stderr for each testcase under log directory, e.g. :-
52
53 $ tree nvmetests/
54 nvmetests/
55 ├── TestNVMeAttachDetachNSCmd
56 │   ├── stderr.log
57 │   └── stdout.log
58 ├── TestNVMeFlushCmd
59 │   ├── stderr.log
60 │   └── stdout.log
61 └── TestNVMeFormatCmd
62 ├── stderr.log
63 └── stdout.log
64 .
65 .
66 .
67
68 3. Walk-Through Example for writing a new testcase
69 --------------------------------------------------
70 1. Copy simple test template file from current directory
71 with appropriate name, replace "simple_template" with testcase name
72 in new file name. Update config.json if necessary.
73 2. Write a testcase main function, make sure its name is starting with
74 test_*.
75 3. Based on the requirement one can inherit TestNVMe or TestNVMeIO
76 class.
77 4. Write test precondition code into setUp. Make sure you are calling
78 super class setUp.
79 5. Write test post condition code into tearDown. Make sure you are calling
80 super class tearDown.
81 6. Before writing a new function have a look into TestNVMe to see if it
82 can be reused.
83 7. Once testcase is ready make sure :-
84 a. Run flake8, mypy, autopep8 and isort on the testcase and fix
85 errors/warnings.
86 - Example "$ ninja -C .build lint-python" will run flake8 and
87 mypy on all the python files in current directory.
88 - Example "$ ninja -C .build format-python" will run autopep8 and
89 isort on all the python files in the current directory.
90
91 4. Running testcases with framework
92 -----------------------------------
93 1. Running single testcase (in the source tree) with nose2 :-
94 $ nose2 --verbose --start-dir tests nvme_writezeros_test
95 $ nose2 --verbose --start-dir tests nvme_read_write_test
96
97 2. Running all the testcases (in the build root directory) with ninja :-
98 $ ninja test -C .build