这是indexloc提供的服务,不要输入任何密码
Skip to content

Ansuel/openwrt-tests

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenWrt Testing

With great many support devices comes great many tests

OpenWrt Testing is a framework to run tests on OpenWrt devices, emulated or real. Using labgrid to control the devices, the framework offers a simple way to write tests and run them on different hardware.

Requirements

  • An OpenWrt firmware image
  • Python and poetry

Setup

pip install -U poetry # optional
poetry install

Run tests

Use this command to run tests on malta/be image:

pytest tests/ \
    --lg-env tests/qemu.yaml \
    --lg-log \
    --lg-colored-steps \
    --target malta-be \
    --firmware ../../openwrt/bin/targets/malta/be/openwrt-malta-be-vmlinux-initramfs.elf

Using the Makefile

The Makefile offers a simple way to run tests directly from the openwrt.git repository:

First create a link of this repositories Makefile to the openwrt.git repository:

ln -s $(pwd)/Makefile /path/to/openwrt.git/Makefile.tests

Second, make sure that Makefile.tests is included in the openwrt.git repository. Add the following line to the top of openwrt.git/Makefile:

include Makefile.tests

Then run the tests:

cd /path/to/openwrt.git
make test-x86-64

Adding tests

The framework uses pytest to execute commands and evaluate the output. Test cases use the two fixture ssh_command or shell_command. The object offers the function run(cmd) and returns stdout, stderr (SSH only) and the exit code.

The example below runs uname -a and checks that the device is running GNU/Linux

def test_uname(shell_command):
    assert "GNU/Linux" in shell_command.run("uname -a")[0][0]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 81.1%
  • Shell 10.4%
  • Makefile 8.5%