expliot.core.tests.testsuite

Test suite handler.

Classes

Test

Representation of Test.

TestSuite

Test Suite class inherits from dict.

Module Contents

class expliot.core.tests.testsuite.Test(**kwargs)

Representation of Test.

The Base class for test cases (plugins). It defines the basic interface and basic implementation for the test cases. All test case plugins need to inherit from a test class derived from this class or this class itself depending on the purpose of the test case.

pre()

Action to take before the test.

post()

Action to take after the test.

execute()

Execute the test.

intro()

Show the intro for test.

output_dict_iter(cblog, robj, rlevel, key=None, value=None)

Callback method for recurse_list_dict().

It iterates over the dict

output passed from a plugin to output_handler(). It performs two operations on the dict

  1. If the output data is to be TLog(ged) (LOGPRETTY) on the console, then log the data recursively from the dict.

  2. Convert any bytes or bytearray objects in the dict to binary string and update the original dict object itself.

Args:
cblog (dict): Contains logging information i.e. to log the data or not?

and the Log prefix type.

robj (list or dict): The list or dict object at the specified recursion

level. This is updated by this callback i.e. bytes and bytearray objects found are converted to binary strings.

rlevel (int): The current recursion level at which this callback

instance is called.

key (str): The key if the robj is a dict. value (can be any type): 1. The value of the key if robj is a dict or

  1. A value from the robj if it is a list

Returns:

Nothing

output_handler(tlogtype=TLog.SUCCESS, msg=None, logkwargs=LOGPRETTY, **kwargs)

Handle the Test execution output data.

  • Add(append) data (dict) as an item in the TResult output (list).

  • And/or Log (print) the output

Args:
tlogtype (int): TLog prefix type to use i.e. Success, fail etc.

Check TLog class for prefix details.

msg (str): Specify a message to be logged, if any, apart from

output data.

logkwargs=LOGPRETTY(int): There are three options for kwargs logging

LOGPRETTY(0) - formatted logging for dict or list. LOGNORMAL(1) - Direct print of dict or list as is. LOGNO(2) - Do not log kwargs.

**kwargs: plugin output keyword arguments (or a **dictObject)

Returns:

Nothing.

run(arglist)

Run the test.

Args:

arglist (list): The argument list of the plugin.

Returns:
dict: The plugin result (status and output) on success,

or an empty dict in case of any error.

_assertpriv()

Raise an exception if the plugin needs root privileges.

Only if program is not executing as root.

Args:

None

Returns:

Nothing

_setid()

Set the Unique Test ID.

The ID is the plugin class name in lowercase.

Args:

None

Returns:

Nothing

_logstatus()

Handle the log status.

Args:

None

Returns:

Nothing

class expliot.core.tests.testsuite.TestSuite(pkgname='expliot.plugins')

Bases: dict

Test Suite class inherits from dict.

All the test cases from the plugins package name specified in __init__() are stored.

testcls
import_plugins(pkgname)

Import all tests from the specified package into a dict.

Parameters:

pkgname – The package to load all test case plugins from

Returns: