This directory contains list of testcases that use the Twister's Pytest integration to run testcases against Leshan demo server. These tests use emulated hardware (native_posix).
These tests require setup that is not done in Twister run, so follow this documentation to set up the test environment.
As with typical network samples, host machine uses IP address 192.0.2.2
and the emulated device running Zephyr is using address 192.0.2.1
.
Follow Networking with the host system from Zephyr's documentation how to set it up, or follow Create NAT and routing for Zephyr native network on Linux.
192.0.2.2
. Configure the port forwarding, if you use Docker to run Leshan.Both server can be started like this:
java -jar ./leshan-server-demo.jar -wp 8080 -vv java -jar ./leshan-bsserver-demo.jar -lp=5783 -slp=5784 -wp 8081
Or create a helper script that does everything, including download:
#!/bin/sh -eu # Download Leshan if needed if [ ! -f leshan-server-demo.jar ]; then wget https://ci.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-server-demo.jar fi if [ ! -f leshan-bsserver-demo.jar ]; then wget 'https://ci.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-bsserver-demo.jar' fi mkdir -p log start-stop-daemon --make-pidfile --pidfile log/leshan.pid --chdir $(pwd) --background --start \ --startas /bin/bash -- -c "exec java -jar ./leshan-server-demo.jar -wp 8080 -vv --models-folder objects >log/leshan.log 2>&1" start-stop-daemon --make-pidfile --pidfile log/leshan_bs.pid --chdir $(pwd) --background --start \ --startas /bin/bash -- -c "exec java -jar ./leshan-bsserver-demo.jar -lp=5783 -slp=5784 -wp 8081 -vv >log/leshan_bs.log 2>&1"
Then stopping would require similar script:
#!/bin/sh -eu start-stop-daemon --remove-pidfile --pidfile log/leshan.pid --stop start-stop-daemon --remove-pidfile --pidfile log/leshan_bs.pid --stop
These tests require extra package that is not installed when you follow the Zephyr's setup. Install with pip install CoAPthon3
twister -p native_posix -vv --enable-slow -T tests/net/lib/lwm2m/interop
Or use the Docker based testing
./scripts/net/run-sample-tests.sh tests/net/lib/lwm2m/interop
Tests are written from test spec; OMA Enabler Test Specification (Interoperability) for Lightweight M2M
Following tests are implemented: