sysunit:apis:fakesmocksstubs

SysUnit Fakes, Mocks and Stubs

Note: A number of the libraries here currently implement only a subset of the functions associated with the KPI. Please feel free to extend a library with more functions as test suites require them.

KPIs Provided:

  • atomic_add_int
  • atomic_fetchadd_int

Notes:

  • As SysUnit tests are not multithreaded, these implementations are not atomic

KPIs Provided:

  • malloc(9)
  • free(9)

Notes:

  • These symbol names collide with those from malloc(3) in incompatible ways. This incompatibility has been resolved by renaming the KPI symbols to prepend a k (e.g. malloc(9) becomes kmalloc). This is automatically performed by the build infrastructure when building C code for SysUnit.

KPIs Provided:

  • Everything in mbuf(9)

KPIs Provided:

  • All top-level sysctl nodes (e.g. _hw, _dev, _kern, etc)

KPIs Provided:

  • mtx_lock
  • mtx_unlock

Notes:

  • These implementations are not actual mutexes as SysUnit tests are not multithreaded. The tests will detect lock recursion or releasing an unowned mutex and fail the test for it
    • The MTX_RECURSE flag is currently not handled

KPIs Provided:

  • kassert_panic
  • panic
  • vpanic

Note:

  • Any panic calls will result in the panic message being printed to stderr followed by abort() being called.

KPIs Provided:

  • uma_zcreate
  • uma_zdestroy
  • uma_zalloc
  • uma_zalloc_arg
  • uma_zfree
  • uma_zfree_arg

Notes:

  • uma zones will perform leak detection when each test case completes. Tests will fail if memory is leaked from a uma zone

Header:

  • #include “mock/UpperIfnet.h”

KPIs Provided:

  • if_input

MockUpperIfnet is used to mock ifnet methods that are implemented by the protocol (upper) layer of the ifnet. It should be used when testing code that runs on the network driver side of the stack.

Header:

  • #include “mock/time.h”

KPIs Provided:

  • getmicrotime
  • sysunit/apis/fakesmocksstubs.txt
  • Last modified: 2018/03/29 04:19
  • by MarkLinimon