Skip to content

Commit

Permalink
added test readme (requested in #71)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralequi committed May 23, 2023
1 parent 0a1b773 commit 6a6ee8f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ Documentation
API documentation for ``pySMART`` was generated using ``pdoc`` and can be
found in the /docs folder within the package archive.

Development
===========
Tests are run using ``pytest``. Under [folder tests](tests), there is a
readme with instructions on how to run the tests.

Acknowledgements
================
I would like to thank the entire team behind smartmontools for creating and
Expand Down
36 changes: 36 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
**Setting Up Single Tests**
===========================

To include tests for the project, please follow the instructions below:

1. Create a new folder for your tests under `tests/singletests`, like `tests/singletests/nvme_8`. The name of the folder should be descriptive of the test you're adding. For example, if you're adding a test for NVMe devices, you can name the folder `nvme_x` where `x` is the number of the test.

2. Inside the test folder, add a file named `device.json` and include the necessary information.

The `device.json` file should have the following structure:

```json
{
"name": "/dev/nvme0"
}
```

This indicates that your device is named `/dev/nvme0`. However, if you know the interface type of the device and want to skip the initial identification call, you can include the interface type as well:

```json
{
"name": "/dev/nvme0",
"interface": "nvme"
}
```

Please note that this alone won't be sufficient to pass the tests. The tests check if `pysmart` reads the data correctly. To achieve that, there is another field called `"values"` in the `device.json` file. While you can try to fill in the values manually, it is not recommended. Instead, you should generate the `device.json` file using the `gen_devicejson.py` script located in the tests folder. Make sure to verify the contents of `device.json` manually, especially before making any commits, and ensure that other `device.json` files from different tests have not been incorrectly modified.

3. Each test should have output files for each `smartctl` call made by `pysmart`. The file naming format is as follows:

- For a `smartctl` call such as `smartctl -d nvme --all /dev/nvme0`, replace any problematic characters (e.g., whitespaces and slashes `/`) with an underscore `_`.
- For the example above, the expected file name for the dataset should be `_-d_nvme_--all__dev_nvme0`.

If you're unsure about which files you need, you can run your test. If any additional files are required, the test will raise an exception indicating the name of the file it expects, along with the underlying `smartctl` call it needs.

Please make sure to follow these guidelines when adding new tests. It will ensure that the tests are properly organized and executed, making it easier for future developers to understand and contribute to the project.

0 comments on commit 6a6ee8f

Please sign in to comment.