pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • PebbleOS
  • Mobile App
  • Examples
  • Index 01
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

PebbleOS

  • Overview
  • Start here
    • Getting started guide
  • Pebble Firmware
    • Overview
    • Playground
    • Application SDK
  • Development
    • The pbl CLI
    • Build system
    • Samples
    • Emulator and simulator
    • Testing
      • Unit tests
      • Integration tests
      • Network tests
    • Debugging
    • Conventions
  • System
    • Architecture overview
    • Kernel
    • Drivers
    • Subsystems
    • Libraries
    • Third-party
  • Hardware
    • Boards
    • Board Add-ons
    • Programmers
  • Community
    • Contribution Guidelines
  • Reference
    • Reference
    • Kconfig options

Network tests

The network tests run the TCP/IP stack as a native build on a Linux TAP interface and check it against the host’s own stack and tools: ping, a router advertisement daemon, and hand-made packets sent with Scapy. They live in tests/net/, written in Python with pytest.

Running them

The tests need Linux and the right to create network interfaces, so they run in a container with a network of its own, which leaves the host’s alone. On Linux or macOS, with Docker:

tests/net/run.sh

The script builds the container’s image, then builds tests/net/app for native with the address and undefined behaviour sanitizers, and runs pytest; arguments go to pytest, such as -k slaac or -x. The build is kept in a Docker volume between runs.

How they work

Each test creates the tap0 interface, with 192.0.2.1/24 on the host side, and starts the stack on it with the -e option of the native build (see Native simulator). The test application takes 192.0.2.2/24 and prints its IPv6 addresses whenever they change, which the tests wait on. The stack’s MAC address is derived from the interface name.

Tests that watch the traffic sniff the interface with Scapy, and those that need a router run radvd on it, advertising 2001:db8:1::/64.

Fuzzing

tests/fuzz/net runs the receive path of the stack under libFuzzer, with the address and undefined behaviour sanitizers, in the same container:

tests/fuzz/net/run.sh 600

The first argument is how long to fuzz, in seconds, 60 by default; the others go to libFuzzer. The harness feeds the stack frames and the passing of time, with a deterministic clock and random numbers, on an interface configured as the tests’ with a link-local address either checked or still being checked, and with checksum offload or without. Frames may have their IP length and checksums made right first, so that mutations reach past them.

Each input fails on a sanitizer error or a failed assertion in the stack, on a frame the stack sends that is malformed or whose checksums are wrong, or on a packet buffer not given back once the stack’s state is reset. tests/fuzz/net/seeds.py writes the seeds, a frame or two of each protocol the stack takes. The corpus grows in build/fuzz-net/corpus, and failing inputs land in build/fuzz-net/artifacts. Given files, the script replays them instead:

tests/fuzz/net/run.sh build/fuzz-net/artifacts/crash-…

CI fuzzes for five minutes on every change to the stack.

Generated from PebbleOS 7416f78a1. This page is maintained in the pebbleos repository: docs/development/tests/network.md.

Overview

  • Running them
  • How they work
  • Fuzzing