blob: da21c4661334f8a3da6b900059f8f380a7064713 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
title: NPTest
parent: FAQ
---
# How do the NPTest parameters work?
NPTest.pm is a perl module, originally written by Peter Bray, and provides
some basic functions for testing the plugins. It has two main helpers:
`getTestParameter` and `testCmd`.
## getTestParameter
Used to get parameters given in previous test runs. Use the 3 parameter
version (the 4 parameter version is deprecated).
Saved parameters are put in `/var/tmp/NPTest.cache`. Unfortunately, there is
no easy way of altering this - you will have to manually change this file to
edit existing parameters.
If you are adding new parameters, there are three values for the parameters
that you need to be aware of:
* default value
* the value that you check against in the test script
* an empty string, which is returned by getTestParameter when the test is run
via automated testing (technically, when no terminal is associated to the
test run)
You should try and ensure current tests are not affected when a new parameter
is added. So it may be better to say `NP_INTERNET_ACCESS`, with information
like *default "yes", disable with "no"* and check for
`NP_INTERNET_ACCESS == "no"` to skip the tests.
## testCmd
This runs a command and returns an NPTest object back. You can combine
Test::More routines with the object to get the return code, output or perf
data to test against expected values.
See `plugins/t/check_disk.t` as an example test script.
<!--% # vim:set filetype=markdown textwidth=78 joinspaces expandtab: # %-->
|