RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

gnrc: improve unittest coverage

Open OlegHahm opened this issue 11 years ago • 23 comments

This a list of modules that are part of the gnrc network stack and there state concerning unittest:

  • [ ] Netdev Ethernet
    • No Unittests
  • [ ] Device drivers
    • [ ] ng_at86rf2xx
      • No Unittests
    • [ ] ng_nativenet
      • No Unittests
    • [ ] xbee
      • No Unittests
    • [ ] kw2xrf
      • No Unittests
  • [ ] Network Interfaces
    • 19 unittests exist in tests/unittests
    • Coverage: medium
    • [ ] Generic Network Interface Header
      • No Unittests
  • [ ] Network Protocol Registry
    • 12 unittests exist in tests/unittests
    • Coverage: low (interface has 8 functions with various parameters)
  • [ ] Packet Buffer
    • 38 unittests exist in tests/unittests
    • Coverage: low to medium (this module is very complex and powerful and has 9 functions)
  • [ ] NETAPI
    • No Unittests
    • [ ] NETAPI Test Framework
      • No Unittests
  • [ ] Nomac
    • No Unittests
  • [ ] SLIP
    • No Unittests
  • [ ] NDP
    • No Unittests
  • [ ] 6LoWPAN (@OlegHahm is working on this)
    • No Unittests
    • [ ] 6LoWPAN Contexts
      • 11 unittests exist in tests/unittests
      • Coverage: medium
    • [ ] 6LoWPAN Fragmentation (@OlegHahm is working on this)
      • No Unittests
    • [ ] 6LoWPAN Header Compression
      • No Unittests
    • [ ] 6LoWPAN Network Interfaces (@OlegHahm is working on this)
      • No Unittests
  • [ ] IPv6 (@A-Paul is working on this)
    • No Unittests
    • [ ] netapi interface
      • No Unittests
    • [ ] IPv6 Address
      • 67 unittests exist in tests/unittests
      • Coverage: medium (The interface contains many functions and macros.)
    • [ ] IPv6 Header (@A-Paul is working on this)
      • 17 unittests exist in tests/unittests
      • Coverage: low (The interface has ~15 functions.)
    • [ ] IPv6 Extension Header (@A-Paul is working on this)
      • No Unittests
      • [ ] IPv6 Extension Routing Header
        • No Unittests
    • [ ] IPv6 Neighbor Cache
      • 27 unittests exist in tests/unittests
      • Coverage: medium
    • [ ] IPv6 Network Interfaces
      • 34 unitttests exist in tests/unittests
      • Coverage: low to medium (The interface contains many functions.)
  • [ ] ICMPv6
    • No Unittests
    • [ ] ECHO
      • No Unittests
  • [ ] Upper Layer/Inet Checksum
    • 5 unittests exist in tests/unittests
    • Coverage: low (Much more input values should be checked)
  • [ ] FIB
    • 16 unitests exist in test/unittests
    • Coverage: low (The FIB interface contains 10 non-debugging functions with many parameters.)
  • [ ] RPL
    • No Unittests
    • [ ] RPL Source Routing Header
      • No Unittests
  • [ ] UDP
    • No Unittests
    • [ ] netapi interface
      • 5 unittests exist in #3248 (tests/udp)
  • [ ] NHDP
    • No Unittests

The intention of this issue is to keep track of the coverage of unittests per module and improve it.

OlegHahm avatar Jun 24 '15 12:06 OlegHahm

Please note: currently I only counted the number of the existing unittests without stating anything about their quality or coverage. I will update this information ASAP.

OlegHahm avatar Jun 24 '15 12:06 OlegHahm

At least for the netapi part of UDP there is #3248. There is still need for ng_udp_hdr_build() and such.

miri64 avatar Jun 24 '15 12:06 miri64

Some unittests based on pexpect or similar modules for the network device drivers are also thinkable. We can use the driver's test apps as a starting point.

miri64 avatar Jun 24 '15 12:06 miri64

@A-Paul may be interested in this list.

PeterKietzmann avatar Jun 24 '15 12:06 PeterKietzmann

@authmillenon, feel free to edit the list and add links to PRs etc. We can also change the format if someone has a better idea. So far, it's more or less a dump.

OlegHahm avatar Jun 24 '15 12:06 OlegHahm

@PeterKietzmann, yes he is. Thanks. :-)

By now (still no familiar with the structure and history of RIOT) I'm confused by figuring out:

  1. How the list entries map to the header files in sys/include/net.
  2. Where to find the specific untittests for the new network stack in "tests/unittests/" and other directories under "tests/" (Unsure if "tests/udp" is the only exception).
  3. And again, how those map to the modules and/or header files.

@OlegHahm or @authmillenon can you give me some advice in this?

A-Paul avatar Jun 28 '15 21:06 A-Paul

  1. @A-Paul, currently it's a bit confusing as we have both the old and the new network stack in master. Modules related to the new stack are prefixed with ng_. In sys/include/net there are only header files related to the new stack. Except the device driver interfaces you should find all relevant headers there. For example: "Netdev Ethernet" relates to ng_netdev_eth.h, "Packet Bufferrelates tong_pktbuf.h`. .. Which module do you have in mind to work on?
  2. Unittests are placed in tests/unittests/__. The tests placed in *tests/* are more to understand as demo of a module.
  3. For example: As stated above, the module "IPv6 Address" already has some unit tests. You can find them in RIOT/tests/unittests/tests-ipv6_addr/. If you feel insecure if a tests relates to the new network stack, you can have a look inside the Makefile.include. There you can see that a ng_-prefixed module is included.

Did I answer your questions?

PeterKietzmann avatar Jun 29 '15 07:06 PeterKietzmann

  1. Unittests are placed in tests/unittests/. The tests placed in tests/ are more to understand as demo of a module.

That is not true, IMHO. tests/ contains what it says: test application. Most of them utilize the shell and are missing a proper execution script, but they are still tests. Anyway my rational behind creating a new test application for every netapi integration test was, that tests/unittests is to be used only for tests not involving threads, timers, IPC etc. (because those things are hard to map in simple unittests) and threads/IPC related tests to use seperate test applications. The unittests are already quite big and don't fit in total on all of our supported boards, so adding thread-stacks to it the situation wouldn't get better.

  1. For example: As stated above, the module "IPv6 Address" already has some unit tests. You can find them in RIOT/tests/unittests/tests-ipv6_addr/. If you feel insecure if a tests relates to the new network stack, you can have a look inside the Makefile.include. There you can see that a ng_-prefixed module is included.

Maybe it is helpful, if someone™ with some insight into the network stack can update the list with the according header files and test locations ;-)

miri64 avatar Jun 29 '15 08:06 miri64

@authmillenon naming them as "demo" was a bit imprecise, I agree. I was thinking about driver tests I guess. Anyway, in this issue we are talking about the bare unittest, right? This should be the location that we are focusing on. IMO that's something where "not-so-gnrc-experienced" people can support.

PeterKietzmann avatar Jun 29 '15 08:06 PeterKietzmann

Anyway, in this issue we are talking about the bare unittest, right? This should be the location that we are focusing on. IMO that's something where "not-so-gnrc-experienced" people can support.

@PeterKietzmann Yes, but they are the least interesting in terms of complexity for the stack. The netapi calls are really what glues everything together/where the most seems to go wrong ;-).

miri64 avatar Jun 29 '15 09:06 miri64

@authmillenon naming them as "demo" was a bit imprecise, I agree. I was thinking about driver tests I guess.

@A-Paul was referring to these tests as Smoke Tests

OlegHahm avatar Jun 29 '15 09:06 OlegHahm

@authmillenon I never wanted to say that they are not interesting :-) ! @OlegHahm I'm not sure I got what you wanted to tell me. Anyway, it would be nice if you manage this testing, I'll better keep me out to avoid inconsistencies. @katezilla could also be interested

PeterKietzmann avatar Jun 29 '15 10:06 PeterKietzmann

@PeterKietzmann, I just think that "smoke testing" seems to be the most correct term for most of the applications located directly under tests/.

OlegHahm avatar Jun 29 '15 15:06 OlegHahm

Can someone shed some light on how the coverage is defined?

miri64 avatar Jun 30 '15 09:06 miri64

In theory, see https://en.wikipedia.org/wiki/Code_coverage. In practice, as I wrote, this is for now just a very rough estimation based on the number of functions per interface and the number and range of parameters.

OlegHahm avatar Jun 30 '15 13:06 OlegHahm

@authmillenon, am I right to assume that network interface PIDs are not checked when added to IPv6 or 6LoWPAN (e.g. in ng_sixlowpan_netif_add())? If yes, we should document this behavior.

OlegHahm avatar Jul 02 '15 17:07 OlegHahm

What do you mean with "checked"? Usually they are called by ng_netif_add so there is no need to check if they are an interface.

miri64 avatar Jul 02 '15 17:07 miri64

What happens if a I call, for instance, ng_sixlowpan_netif_add() with a random ID? Will it check if this ID is a valid PID or just add the (potentially not existing) interface to 6lowpan?

OlegHahm avatar Jul 02 '15 18:07 OlegHahm

Will add it.

miri64 avatar Jul 02 '15 19:07 miri64

While looking through the existing tests I've seen a lot of locallly defined data stubs. I may be usefull if those who are sufficient for other test could go into into unittests-constants.h. Ideally including a short comment which special state/case they represent.

A-Paul avatar Jul 06 '15 06:07 A-Paul