The friendly Operating System for the Internet of Things

This provides a framework to test the GNRC communication interface IPC calls. More...

Detailed Description

Files

file  nettest.h
 Definitions for the GNRC communication interface test framework.
 

Data Structures

struct  gnrc_nettest_opt_cbs_t
 Option callback list element. More...
 

Macros

#define GNRC_NETTEST_TIMEOUT   (1000)
 Timeout for tests in microseconds.
 
#define GNRC_NETTEST_STACK_SIZE   (THREAD_STACKSIZE_DEFAULT)
 Default stack size to use for the nettest thread.
 
#define GNRC_NETTEST_PRIO   (THREAD_PRIORITY_MAIN)
 Default priority for the nettest thread.
 
#define GNRC_NETTEST_MSG_QUEUE_SIZE   (8U)
 Default message queue size to use for the nettest thread.
 

Typedefs

typedef int(* gnrc_nettest_opt_cb_t) (uint16_t context, void *data, uint16_t data_len)
 Type for get/set callbacks. More...
 

Enumerations

enum  gnrc_nettest_res_t {
  GNRC_NETTEST_SUCCESS = 0, GNRC_NETTEST_FAIL, GNRC_NETTEST_TIMED_OUT, GNRC_NETTEST_WRONG_MSG,
  GNRC_NETTEST_WRONG_SENDER
}
 Result type for tests. More...
 

Functions

void gnrc_nettest_register_get (netopt_t opt, gnrc_nettest_opt_cb_t cb)
 Registers a getter for an option. More...
 
void gnrc_nettest_register_set (netopt_t opt, gnrc_nettest_opt_cb_t cb)
 Registers a setter for an option. More...
 
gnrc_nettest_res_t gnrc_nettest_send (kernel_pid_t pid, gnrc_pktsnip_t *in, unsigned int exp_pkts, const kernel_pid_t *exp_senders, const gnrc_pktsnip_t **exp_out, gnrc_nettype_t exp_type, uint32_t exp_demux_ctx)
 Test GNRC_NETAPI_MSG_TYPE_SND command to pid. More...
 
gnrc_nettest_res_t gnrc_nettest_send_iface (kernel_pid_t pid, gnrc_pktsnip_t *in, unsigned int exp_pkts, const kernel_pid_t *exp_senders, const gnrc_pktsnip_t **exp_out)
 Test GNRC_NETAPI_MSG_TYPE_SND command to pid with the receiving thread being an interface. More...
 
gnrc_nettest_res_t gnrc_nettest_receive (kernel_pid_t pid, gnrc_pktsnip_t *in, unsigned int exp_pkts, const kernel_pid_t *exp_senders, const gnrc_pktsnip_t **exp_out, gnrc_nettype_t exp_type, uint32_t exp_demux_ctx)
 Test GNRC_NETAPI_MSG_TYPE_RCV command to pid. More...
 
gnrc_nettest_res_t gnrc_nettest_get (kernel_pid_t pid, netopt_t opt, uint16_t context, void *data, size_t data_len, void *exp_data, int exp_res)
 Test GNRC_NETAPI_MSG_TYPE_GET command to pid. More...
 
gnrc_nettest_res_t gnrc_nettest_set (kernel_pid_t pid, netopt_t opt, uint16_t context, void *data, size_t data_len, int exp_res)
 Test GNRC_NETAPI_MSG_TYPE_SET command to pid. More...
 
int gnrc_nettest_init (void)
 Initializes the NETAPI test framework module. More...
 
void gnrc_nettest_reset (void)
 Resets gnrc_nettest_opt_cbs_t list.
 

Typedef Documentation

typedef int(* gnrc_nettest_opt_cb_t) (uint16_t context, void *data, uint16_t data_len)
Parameters
[in]context(Optional) context for the option. Compare gnrc_netapi_opt_t::context.
[in,out]dataData to set or buffer to read into. Compare gnrc_netapi_opt_t::data.
[in]data_lenSize of the data / the buffer. Compare gnrc_netapi_opt_t::data_len
Returns
The value for the GNRC_NETAPI_MSG_TYPE_ACK message.

Definition at line 79 of file nettest.h.

Enumeration Type Documentation

Enumerator
GNRC_NETTEST_SUCCESS 

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

Definition at line 92 of file nettest.h.

Function Documentation

gnrc_nettest_res_t gnrc_nettest_get ( kernel_pid_t  pid,
netopt_t  opt,
uint16_t  context,
void *  data,
size_t  data_len,
void *  exp_data,
int  exp_res 
)
Parameters
[in]pidThe thread you want to test the GNRC_NETAPI_MSG_TYPE_GET command for.
[in]optThe option you want to test.
[in]contextThe context for the option.
[in]dataThe data pointer for the GNRC_NETAPI_MSG_TYPE_GET command.
[in]data_lenThe maximum length for data.
[in]exp_dataThe expected value for the returned data. May be NULL if exp_res < 0
[in]exp_resThe expected return value for the GNRC_NETAPI_MSG_TYPE_GET command.
Returns
See also
gnrc_nettest_res_t
int gnrc_nettest_init ( void  )
Returns
The PID to the nettest thread, on success.
a negative errno on error.
-EOVERFLOW, if there are too many threads running already
gnrc_nettest_res_t gnrc_nettest_receive ( kernel_pid_t  pid,
gnrc_pktsnip_t in,
unsigned int  exp_pkts,
const kernel_pid_t exp_senders,
const gnrc_pktsnip_t **  exp_out,
gnrc_nettype_t  exp_type,
uint32_t  exp_demux_ctx 
)

This registered the nettest thread to (exp_type, exp_demux_ctx) and checks if exp_pkts of exp_out were received from exp_senders. If no message was received after GNRC_NETTEST_TIMEOUT microseconds, while there are still packets expected, the function will return GNRC_NETTEST_TIMED_OUT.

Parameters
[in]pidThe thread you want to test the GNRC_NETAPI_MSG_TYPE_RCV command for.
[in]inThe packet you want to send through pid.
[in]exp_pktsThe number of packets expected to be received.
[in]exp_sendersThe PID the resulting packet should be coming from. Must be of dimension exp_pkts.
[in]exp_outThe expected packet from exp_sender. Must be of dimension exp_pkts.
[in]exp_typeThe expected receiver type for the GNRC_NETAPI_MSG_TYPE_RCV command.
[in]exp_demux_ctxThe expected receiver demux type for the GNRC_NETAPI_MSG_TYPE_RCV command.
Returns
See also
gnrc_nettest_res_t
void gnrc_nettest_register_get ( netopt_t  opt,
gnrc_nettest_opt_cb_t  cb 
)

Overrides previous registrations.

Parameters
[in]optThe option to register the getter for.
[in]cbAn option getter. NULL to delete.
void gnrc_nettest_register_set ( netopt_t  opt,
gnrc_nettest_opt_cb_t  cb 
)

Overrides previous registrations.

Parameters
[in]optThe option to register the setter for.
[in]cbAn option setter. NULL to delete.
gnrc_nettest_res_t gnrc_nettest_send ( kernel_pid_t  pid,
gnrc_pktsnip_t in,
unsigned int  exp_pkts,
const kernel_pid_t exp_senders,
const gnrc_pktsnip_t **  exp_out,
gnrc_nettype_t  exp_type,
uint32_t  exp_demux_ctx 
)

This registered the nettest thread to (exp_type, exp_demux_ctx) and checks if exp_pkts of exp_out were received from exp_senders. If no message was received after 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
[in]pidThe thread you want to test the GNRC_NETAPI_MSG_TYPE_SND command for.
[in]inThe packet you want to send through pid.
[in]exp_pktsThe number of packets expected to be received.
[in]exp_sendersThe PID the resulting packet should be coming from. Must be of dimension exp_pkts.
[in]exp_outThe expected packet from exp_sender. Must be of dimension exp_pkts.
[in]exp_typeThe expected receiver type for the GNRC_NETAPI_MSG_TYPE_SND command.
[in]exp_demux_ctxThe expected receiver demux type for the GNRC_NETAPI_MSG_TYPE_SND command.
Returns
See also
gnrc_nettest_res_t
gnrc_nettest_res_t gnrc_nettest_send_iface ( kernel_pid_t  pid,
gnrc_pktsnip_t in,
unsigned int  exp_pkts,
const kernel_pid_t exp_senders,
const gnrc_pktsnip_t **  exp_out 
)

This registered the nettest thread as an interface and checks ifx exp_pkts of exp_out were received from exp_senders. If no message was received after 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
[in]pidThe thread you want to test the GNRC_NETAPI_MSG_TYPE_SND command for.
[in]inThe packet you want to send through pid.
[in]exp_pktsThe number of packets expected to be received.
[in]exp_sendersThe PID the resulting packet should be coming from. Must be of dimension exp_pkts. May be NULL if exp_pkts == 0.
[in]exp_outThe expected packet from exp_sender. Must be of dimension exp_pkts. May be NULL if exp_pkts == 0.
Returns
See also
gnrc_nettest_res_t
gnrc_nettest_res_t gnrc_nettest_set ( kernel_pid_t  pid,
netopt_t  opt,
uint16_t  context,
void *  data,
size_t  data_len,
int  exp_res 
)
Parameters
[in]pidThe thread you want to test the GNRC_NETAPI_MSG_TYPE_SET command for.
[in]optThe option you want to test.
[in]contextThe context for the option.
[in]dataThe data pointer for the GNRC_NETAPI_MSG_TYPE_SET command.
[in]data_lenThe maximum length for data.
[in]exp_resThe expected return value for the GNRC_NETAPI_MSG_TYPE_SET command.
Returns
See also
gnrc_nettest_res_t