[riot-notifications] [RIOT-OS/RIOT] tests/gnrc_ndp: enhance coverage (#10987)

Martine Lenders notifications at github.com
Mon Feb 11 14:38:35 CET 2019


<!--
The RIOT community cares a lot about code quality.
Therefore, before describing what your contribution is about, we would like
you to make sure that your modifications are compliant with the RIOT
coding conventions, see https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions.
-->

### Contribution description
To ensure that the bug I was trying to fix in https://github.com/RIOT-OS/RIOT/pull/10985 wasn't actually caused by the `gnrc_ndp` sending functions I enhanced the module's test coverage.
<!--
Put here the description of your contribution:
- describe which part(s) of RIOT is (are) involved
- if it's a bug fix, describe the bug that it solves and how it is solved
- you can also give more information to reviewers about how to test your changes
-->


### Testing procedure
To make sure the coverage is actually enhanced I applied the following patch

```diff
diff --git a/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c b/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c
index 899d1de..e99b283 100644
--- a/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c
+++ b/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c
@@ -287,6 +287,7 @@ void gnrc_ndp_nbr_sol_send(const ipv6_addr_t *tgt, gnrc_netif_t *netif,
                 hdr = gnrc_ndp_opt_sl2a_build(l2src, l2src_len, pkt);
 
                 if (hdr == NULL) {
+                    puts("option failed");
                     DEBUG("ndp: error allocating SL2AO.\n");
                     break;
                 }
@@ -296,6 +297,7 @@ void gnrc_ndp_nbr_sol_send(const ipv6_addr_t *tgt, gnrc_netif_t *netif,
         /* add neighbor solicitation header */
         hdr = gnrc_ndp_nbr_sol_build(tgt, pkt);
         if (hdr == NULL) {
+            puts("message failed");
             DEBUG("ndp: error allocating neighbor solicitation.\n");
             break;
         }
@@ -369,6 +371,7 @@ void gnrc_ndp_nbr_adv_send(const ipv6_addr_t *tgt, gnrc_netif_t *netif,
                 hdr = gnrc_ndp_opt_tl2a_build(l2tgt, l2tgt_len, pkt);
 
                 if (hdr == NULL) {
+                    puts("option failed");
                     DEBUG("ndp: error allocating TL2AO.\n");
                     break;
                 }
@@ -385,6 +388,7 @@ void gnrc_ndp_nbr_adv_send(const ipv6_addr_t *tgt, gnrc_netif_t *netif,
         /* add neighbor advertisement header */
         hdr = gnrc_ndp_nbr_adv_build(tgt, adv_flags, pkt);
         if (hdr == NULL) {
+            puts("message failed");
             DEBUG("ndp: error allocating neighbor advertisement.\n");
             break;
         }
@@ -434,6 +438,7 @@ void gnrc_ndp_rtr_sol_send(gnrc_netif_t *netif, const ipv6_addr_t *dst)
                 /* add source address link-layer address option */
                 pkt = gnrc_ndp_opt_sl2a_build(l2src, l2src_len, NULL);
                 if (pkt == NULL) {
+                    puts("option failed");
                     DEBUG("ndp: error allocating SL2AO.\n");
                     break;
                 }
@@ -442,6 +447,7 @@ void gnrc_ndp_rtr_sol_send(gnrc_netif_t *netif, const ipv6_addr_t *dst)
         /* add router solicitation header */
         hdr = gnrc_ndp_rtr_sol_build(pkt);
         if (hdr == NULL) {
+            puts("message failed");
             DEBUG("ndp: error allocating router solicitation.\n");
             break;
         }
@@ -518,6 +524,7 @@ void gnrc_ndp_rtr_adv_send(gnrc_netif_t *netif, const ipv6_addr_t *src,
                 hdr = gnrc_ndp_opt_sl2a_build(l2src, l2src_len, pkt);
 
                 if (hdr == NULL) {
+                    puts("option failed");
                     DEBUG("ndp: error allocating Source Link-layer address "
                           "option.\n");
                     break;
@@ -556,6 +563,7 @@ void gnrc_ndp_rtr_adv_send(gnrc_netif_t *netif, const ipv6_addr_t *src,
         hdr = gnrc_ndp_rtr_adv_build(cur_hl, flags, adv_ltime, reach_time,
                                      retrans_timer, pkt);
         if (hdr == NULL) {
+            puts("message failed");
             DEBUG("ndp: error allocating router advertisement.\n");
             break;
         }
@@ -598,6 +606,7 @@ static gnrc_pktsnip_t *_build_headers(gnrc_netif_t *netif,
     gnrc_pktsnip_t *iphdr = gnrc_ipv6_hdr_build(payload, src, dst);
 
     if (iphdr == NULL) {
+        puts("IPv6 failed");
         DEBUG("ndp: error allocating IPv6 header.\n");
         return NULL;
     }
@@ -605,6 +614,7 @@ static gnrc_pktsnip_t *_build_headers(gnrc_netif_t *netif,
     /* add netif header for send interface specification */
     l2hdr = gnrc_netif_hdr_build(NULL, 0, NULL, 0);
     if (l2hdr == NULL) {
+        puts("netif failed");
         DEBUG("ndp: error allocating netif header.\n");
         gnrc_pktbuf_remove_snip(iphdr, iphdr);
         return NULL;
```

The test should then show something like

```
option failed
message failed
IPv6 failed
netif failed
```

4 times with varying numbers periods in-between with this PR, without it it probably won't show up at all (I did not test this case). I tested the first case on `native`, `samr21-xpro`, and `iotlab-m3`


<!--
Details steps to test your contribution:
- which test/example to compile for which board and is there a 'test' command
- how to know that it was not working/available in master
- the expected success test output
-->


### Issues/PRs references
Ensurance that #10985 was the right hunch for the leak we've seen.
<!--
Examples: Fixes #1234. See also #5678. Depends on PR #9876.

Please use keywords (e.g., fixes, resolve) with the links to the issues you
resolved, this way they will be automatically closed when your pull request
is merged. See https://help.github.com/articles/closing-issues-using-keywords/.
-->

You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/10987

-- Commit Summary --

  * tests/gnrc_ndp: enhance coverage

-- File Changes --

    M tests/gnrc_ndp/main.c (264)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/10987.patch
https://github.com/RIOT-OS/RIOT/pull/10987.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10987
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190211/79a69e74/attachment-0001.html>


More information about the notifications mailing list