NETAPI test framework¶
This provides a framework to test the GNRC communication interface IPC calls.
-
enum
gnrc_nettest_res_t
¶ - GNRC_NETTEST_SUCCESS
= 0
- test was successful
- GNRC_NETTEST_FAIL
- test failed
- GNRC_NETTEST_TIMED_OUT
- test timed out
- GNRC_NETTEST_WRONG_MSG
- wrong message type received
- GNRC_NETTEST_WRONG_SENDER
- wrong message type received
- GNRC_NETTEST_SUCCESS
-
int(*
gnrc_nettest_opt_cb_t
()¶ Type for get/set callbacks.
Parameters
context: (Optional) context for the option. Compare netapi.h::gnrc_netapi_opt_t::context
.data: Data to set or buffer to read into. Compare netapi.h::gnrc_netapi_opt_t::data
.data_len: Size of the data / the buffer. Compare netapi.h::gnrc_netapi_opt_t::data_len
Return values
- The value for the
netapi.h::GNRC_NETAPI_MSG_TYPE_ACK
message.
- The value for the
-
void
gnrc_nettest_register_get
(netopt.h::netopt_t
opt,nettest.h::gnrc_nettest_opt_cb_t
cb)¶ Registers a getter for an option.
Overrides previous registrations.
Parameters
opt: The option to register the getter for. cb: An option getter. NULL to delete.
-
void
gnrc_nettest_register_set
(netopt.h::netopt_t
opt,nettest.h::gnrc_nettest_opt_cb_t
cb)¶ Registers a setter for an option.
Overrides previous registrations.
Parameters
opt: The option to register the setter for. cb: An option setter. NULL to delete.
-
nettest.h::gnrc_nettest_res_t
gnrc_nettest_send
(kernel_types.h::kernel_pid_t
pid,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* in, unsigned int exp_pkts, constkernel_types.h::kernel_pid_t
* exp_senders, constinclude/net/gnrc/pkt.h::gnrc_pktsnip_t
** exp_out,nettype.h::gnrc_nettype_t
exp_type, uint32_t exp_demux_ctx)¶ Test
netapi.h::GNRC_NETAPI_MSG_TYPE_SND
command topid
.This registered the nettest thread to (
exp_type
,exp_demux_ctx
) and checks ifexp_pkts
ofexp_out
were received fromexp_senders
. If no message was received afternettest.h::GNRC_NETTEST_TIMEOUT
microseconds, while there are still packets expected, the function will return GNRC_NETTEST_TIMED_OUT.In case of success it releases all packets send by the tested module.
Parameters
pid: The thread you want to test the netapi.h::GNRC_NETAPI_MSG_TYPE_SND
command for.in: The packet you want to send through pid
.exp_pkts: The number of packets expected to be received. exp_senders: The PID the resulting packet should be coming from. Must be of dimension exp_pkts
.exp_out: The expected packet from exp_sender
. Must be of dimensionexp_pkts
.exp_type: The expected receiver type for the netapi.h::GNRC_NETAPI_MSG_TYPE_SND
command.exp_demux_ctx: The expected receiver demux type for the netapi.h::GNRC_NETAPI_MSG_TYPE_SND
command.See also
Return values
-
nettest.h::gnrc_nettest_res_t
gnrc_nettest_send_iface
(kernel_types.h::kernel_pid_t
pid,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* in, unsigned int exp_pkts, constkernel_types.h::kernel_pid_t
* exp_senders, constinclude/net/gnrc/pkt.h::gnrc_pktsnip_t
** exp_out)¶ Test
netapi.h::GNRC_NETAPI_MSG_TYPE_SND
command topid
with the receiving thread being an interface.This registered the nettest thread as an interface and checks ifx
exp_pkts
ofexp_out
were received fromexp_senders
. If no message was received afternettest.h::GNRC_NETTEST_TIMEOUT
microseconds, while there are still packets expected, the function will return GNRC_NETTEST_TIMED_OUT.In case of success it releases all packets received from the tested module.
Parameters
pid: The thread you want to test the netapi.h::GNRC_NETAPI_MSG_TYPE_SND
command for.in: The packet you want to send through pid
.exp_pkts: The number of packets expected to be received. exp_senders: The PID the resulting packet should be coming from. Must be of dimension exp_pkts
. May be NULL ifexp_pkts
== 0.exp_out: The expected packet from exp_sender
. Must be of dimensionexp_pkts
. May be NULL ifexp_pkts
== 0.See also
Return values
-
nettest.h::gnrc_nettest_res_t
gnrc_nettest_receive
(kernel_types.h::kernel_pid_t
pid,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* in, unsigned int exp_pkts, constkernel_types.h::kernel_pid_t
* exp_senders, constinclude/net/gnrc/pkt.h::gnrc_pktsnip_t
** exp_out,nettype.h::gnrc_nettype_t
exp_type, uint32_t exp_demux_ctx)¶ Test
netapi.h::GNRC_NETAPI_MSG_TYPE_RCV
command topid
.This registered the nettest thread to (
exp_type
,exp_demux_ctx
) and checks ifexp_pkts
ofexp_out
were received fromexp_senders
. If no message was received afternettest.h::GNRC_NETTEST_TIMEOUT
microseconds, while there are still packets expected, the function will return GNRC_NETTEST_TIMED_OUT.Parameters
pid: The thread you want to test the netapi.h::GNRC_NETAPI_MSG_TYPE_RCV
command for.in: The packet you want to send through pid
.exp_pkts: The number of packets expected to be received. exp_senders: The PID the resulting packet should be coming from. Must be of dimension exp_pkts
.exp_out: The expected packet from exp_sender
. Must be of dimensionexp_pkts
.exp_type: The expected receiver type for the netapi.h::GNRC_NETAPI_MSG_TYPE_RCV
command.exp_demux_ctx: The expected receiver demux type for the netapi.h::GNRC_NETAPI_MSG_TYPE_RCV
command.See also
Return values
-
nettest.h::gnrc_nettest_res_t
gnrc_nettest_get
(kernel_types.h::kernel_pid_t
pid,netopt.h::netopt_t
opt, uint16_t context, void * data,msp430_types.h::size_t
data_len, void * exp_data, int exp_res)¶ Test
netapi.h::GNRC_NETAPI_MSG_TYPE_GET
command topid
.Parameters
pid: The thread you want to test the netapi.h::GNRC_NETAPI_MSG_TYPE_GET
command for.opt: The option you want to test. context: The context for the option. data: The data pointer for the netapi.h::GNRC_NETAPI_MSG_TYPE_GET
command.data_len: The maximum length for data
.exp_data: The expected value for the returned data. May be NULL if exp_res
< 0exp_res: The expected return value for the netapi.h::GNRC_NETAPI_MSG_TYPE_GET
command.See also
Return values
-
nettest.h::gnrc_nettest_res_t
gnrc_nettest_set
(kernel_types.h::kernel_pid_t
pid,netopt.h::netopt_t
opt, uint16_t context, void * data,msp430_types.h::size_t
data_len, int exp_res)¶ Test
netapi.h::GNRC_NETAPI_MSG_TYPE_SET
command topid
.Parameters
pid: The thread you want to test the netapi.h::GNRC_NETAPI_MSG_TYPE_SET
command for.opt: The option you want to test. context: The context for the option. data: The data pointer for the netapi.h::GNRC_NETAPI_MSG_TYPE_SET
command.data_len: The maximum length for data
.exp_res: The expected return value for the netapi.h::GNRC_NETAPI_MSG_TYPE_SET
command.See also
Return values
-
int
gnrc_nettest_init
(void)¶ Initializes the NETAPI test framework module.
Return values
- The PID to the nettest thread, on success.
- a negative errno on error.
- -EOVERFLOW, if there are too many threads running already
-
void
gnrc_nettest_reset
(void)¶ Resets gnrc_nettest_opt_cbs_t list.
-
GNRC_NETTEST_TIMEOUT
¶ Timeout for tests in microseconds.
1
(1000)
-
GNRC_NETTEST_STACK_SIZE
¶ Default stack size to use for the nettest thread.
1
(THREAD_STACKSIZE_DEFAULT)
-
GNRC_NETTEST_PRIO
¶ Default priority for the nettest thread.
1
(THREAD_PRIORITY_MAIN)
-
GNRC_NETTEST_MSG_QUEUE_SIZE
¶ Default message queue size to use for the nettest thread.
1
(8U)
-
struct
gnrc_nettest_opt_cbs_t
¶ Option callback list element.
-
nettest.h::gnrc_nettest_opt_cb_t
get
¶ getter for an option
-
nettest.h::gnrc_nettest_opt_cb_t
set
¶ setter for an option
-