mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
ng_nettest: some fixes
This commit is contained in:
parent
0103fa2e91
commit
871a6f9cde
@ -193,6 +193,7 @@ ifneq (,$(filter ng_nettest,$(USEMODULE)))
|
||||
USEMODULE += ng_netreg
|
||||
USEMODULE += ng_netif
|
||||
USEMODULE += ng_pktbuf
|
||||
USEMODULE += vtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_netbase,$(USEMODULE)))
|
||||
|
@ -125,6 +125,8 @@ void ng_nettest_register_set(ng_netconf_opt_t opt, ng_nettest_opt_cb_t cb);
|
||||
* If no message was received after @ref NG_NETTEST_TIMEOUT microseconds, while
|
||||
* there are still packets expected, the function will return NG_NETTEST_TIMED_OUT.
|
||||
*
|
||||
* In case of success it releases all packets send by the tested module.
|
||||
*
|
||||
* @param[in] pid The thread you want to test the
|
||||
* @ref NG_NETAPI_MSG_TYPE_SND command for.
|
||||
* @param[in] in The packet you want to send through @p pid.
|
||||
@ -154,6 +156,8 @@ ng_nettest_res_t ng_nettest_send(kernel_pid_t pid, ng_pktsnip_t *in,
|
||||
* was received after @ref NG_NETTEST_TIMEOUT microseconds, while there are
|
||||
* still packets expected, the function will return NG_NETTEST_TIMED_OUT.
|
||||
*
|
||||
* In case of success it releases all packets received from the tested module.
|
||||
*
|
||||
* @param[in] pid The thread you want to test the
|
||||
* @ref NG_NETAPI_MSG_TYPE_SND command for.
|
||||
* @param[in] in The packet you want to send through @p pid.
|
||||
|
@ -61,38 +61,39 @@ static ng_nettest_res_t _pkt_test(uint16_t cmd_type, kernel_pid_t pid, ng_pktsni
|
||||
msg.content.ptr = (char *)in;
|
||||
|
||||
msg_send(&msg, pid);
|
||||
timex_normalize(&t);
|
||||
|
||||
for (unsigned int i = 0; i < exp_pkts; i++) {
|
||||
ng_pktsnip_t *out;
|
||||
ng_pktsnip_t *out, *exp = exp_out[i];
|
||||
|
||||
if ((vtimer_msg_receive_timeout(&msg, t) < 0) && res == NG_NETTEST_SUCCESS) {
|
||||
res = NG_NETTEST_TIMED_OUT;
|
||||
if (vtimer_msg_receive_timeout(&msg, t) < 0) {
|
||||
return NG_NETTEST_TIMED_OUT;
|
||||
}
|
||||
|
||||
if (msg.type != NG_NETAPI_MSG_TYPE_SND && (res == NG_NETTEST_SUCCESS)) {
|
||||
res = NG_NETTEST_WRONG_MSG;
|
||||
if (msg.type != cmd_type) {
|
||||
return NG_NETTEST_WRONG_MSG;
|
||||
}
|
||||
|
||||
if (msg.sender_pid != exp_senders[i] && (res == NG_NETTEST_SUCCESS)) {
|
||||
res = NG_NETTEST_WRONG_SENDER;
|
||||
if (msg.sender_pid != exp_senders[i]) {
|
||||
return NG_NETTEST_WRONG_SENDER;
|
||||
}
|
||||
|
||||
out = (ng_pktsnip_t *)msg.content.ptr;
|
||||
|
||||
if ((out == NULL) && (res == NG_NETTEST_SUCCESS)) {
|
||||
res = NG_NETTEST_FAIL;
|
||||
if (out == NULL) {
|
||||
return NG_NETTEST_FAIL;
|
||||
}
|
||||
|
||||
while (out) {
|
||||
if ((res == NG_NETTEST_SUCCESS) &&
|
||||
((out->users != exp_out[i]->users) ||
|
||||
(out->size != exp_out[i]->size) ||
|
||||
(out->type != exp_out[i]->type) ||
|
||||
(memcmp(out->data, exp_out[i]->data, out->size) != 0))) {
|
||||
res = NG_NETTEST_FAIL;
|
||||
while (out && exp) {
|
||||
if ((out->users != exp->users) ||
|
||||
(out->size != exp->size) ||
|
||||
(out->type != exp->type) ||
|
||||
(memcmp(out->data, exp->data, out->size) != 0)) {
|
||||
return NG_NETTEST_FAIL;
|
||||
}
|
||||
|
||||
out = out->next;
|
||||
exp = exp->next;
|
||||
}
|
||||
|
||||
ng_pktbuf_release((ng_pktsnip_t *)msg.content.ptr);
|
||||
|
Loading…
Reference in New Issue
Block a user