framework module

class framework.VppTestCase(methodName='runTest')

Bases: unittest.case.TestCase

This subclass is a base class for VPP test cases that are implemented as classes. It provides methods to create and run test case.

add_packet_info_to_list(info)

Add packet info to the testcase’s packet info list

Parameters:info – packet info
assert_equal(real_value, expected_value, name_or_class=None)
assert_in_range(real_value, expected_min, expected_max, name=None)
classmethod create_loopback_interfaces(interfaces)

Create loopback interfaces

Parameters:interfaces – iterable indexes of the interfaces
create_packet_info(src_pg_index, dst_pg_index)

Create packet info object containing the source and destination indexes and add it to the testcase’s packet info list

Parameters:
  • src_pg_index – source packet-generator index
  • dst_pg_index – destination packet-generator index
Returns:

_PacketInfo object

classmethod create_pg_interfaces(interfaces)

Create packet-generator interfaces

Parameters:interfaces – iterable indexes of the interfaces
static extend_packet(packet, size)

Extend packet to given size by padding with spaces NOTE: Currently works only when Raw layer is present.

Parameters:
  • packet – packet
  • size – target size
get_next_packet_info(info)

Iterate over the packet info list stored in the testcase Start iteration with first element if info is None Continue based on index in info if info is specified

Parameters:info – info or None
Returns:next info in list or None if no more infos
get_next_packet_info_for_interface(src_index, info)

Search the packet info list for the next packet info with same source interface index

Parameters:
  • src_index – source interface index to search for
  • info – packet info - where to start the search
Returns:

packet info or None

get_next_packet_info_for_interface2(src_index, dst_index, info)

Search the packet info list for the next packet info with same source and destination interface indexes

Parameters:
  • src_index – source interface index to search for
  • dst_index – destination interface index to search for
  • info – packet info - where to start the search
Returns:

packet info or None

static info_to_payload(info)

Convert _PacketInfo object to packet payload

Parameters:info – _PacketInfo object
Returns:string containing serialized data from packet info
classmethod instance()

Return the instance of this testcase

packet_infos

List of packet infos

static payload_to_info(payload)

Convert packet payload to _PacketInfo object

Parameters:payload – packet payload
Returns:_PacketInfo object containing de-serialized data from payload
classmethod pg_enable_capture(interfaces)

Enable capture on packet-generator interfaces

Parameters:interfaces – iterable interface indexes
classmethod pg_start()

Remove any zombie captures and enable the packet generator

classmethod quit()

Disconnect vpp-api, kill vpp and cleanup shared memory files

classmethod register_capture(cap_name)

Register a capture in the testclass

classmethod run_vpp()
setUp()

Clear trace before running each test

classmethod setUpClass()

Perform class setup before running the testcase Remove shared memory files, start vpp and connect the vpp-api

classmethod setUpConstants()

Set-up the test case class based on environment variables

classmethod set_debug_flags(d)
tearDown()

Show various debug prints after each test

classmethod tearDownClass()

Perform final cleanup after running all tests in this test-case

classmethod wait_for_enter()
class framework.VppTestResult(stream, descriptions, verbosity)

Bases: unittest.result.TestResult

@property result_string
String variable to store the test case result string.
@property errors
List variable containing 2-tuples of TestCase instances and strings holding formatted tracebacks. Each tuple represents a test which raised an unexpected exception.
@property failures
List variable containing 2-tuples of TestCase instances and strings holding formatted tracebacks. Each tuple represents a test where a failure was explicitly signalled using the TestCase.assert*() methods.
addError(test, err)

Record a test error result

Parameters:
  • test
  • err – error message
addFailure(test, err)

Record a test failed result

Parameters:
  • test
  • err – error message
addSkip(test, reason)

Record a test skipped.

Parameters:
  • test
  • reason
addSuccess(test)

Record a test succeeded result

Parameters:test
getDescription(test)

Get test description

Parameters:test
Returns:test description
printErrorList(flavour, errors)

Print error list to the output stream together with error type and test case description.

Parameters:
  • flavour – error type
  • errors – iterable errors
printErrors()

Print errors from running the test case

startTest(test)

Start a test

Parameters:test
stopTest(test)

Stop a test

Parameters:test
class framework.VppTestRunner(stream=<open file '<stderr>', mode 'w'>, descriptions=True, verbosity=1, failfast=False, buffer=False, resultclass=None)

Bases: unittest.runner.TextTestRunner

A basic test runner implementation which prints results on standard error.

resultclass

Class maintaining the results of the tests

run(test)

Run the tests

Parameters:test
framework.pump_output(out, deque)