GitHub

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:

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.