diff options
author | Sergey V. Lobanov <sergey@lobanov.in> | 2022-09-04 18:49:42 +0300 |
---|---|---|
committer | Sergey V. Lobanov <sergey@lobanov.in> | 2022-09-04 19:06:49 +0300 |
commit | c92ff6266b18a9655edef231391739f0479dfb3a (patch) | |
tree | 0196077cbd54c9607ba918a42cac567411197663 /.github/workflows | |
parent | 38d96b8e20608fb743d543fe3f08ad4b9d1dcd66 (diff) | |
download | accel-ppp-c92ff6266b18a9655edef231391739f0479dfb3a.tar.gz accel-ppp-c92ff6266b18a9655edef231391739f0479dfb3a.zip |
add tests and ci workflow for running tests
This commit adds tests (using python3 pytest framework):
1. Test basic accel-cmd commands (show version, show stat, etc)
2. Test ipoe shared session up (dhcpv4) without radius
3. Test pppoe discovery (without PADO delay)
4. Test pppoe discovery (without PADO delay)
5. Test pppoe session up (ipv4) without radius
6. Test vlan creation using vlan-mon (pppoe)
These tests require external utils. Please read tests/README.md how to setup
environment, how to run the tests and how to generate coverage report
Also, run-tests.yml contains step-by-step instruction how to run the tests
Signed-off-by: Sergey V. Lobanov <sergey@lobanov.in>
Diffstat (limited to '.github/workflows')
-rw-r--r-- | .github/workflows/run-tests.yml | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 00000000..dfa637c2 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,130 @@ +name: Run tests + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + +jobs: + Build-and-Test: + #if: ${{ false }} # disable for now + strategy: + fail-fast: false + matrix: + distro: ["ubuntu-22.04", "ubuntu-20.04"] + + runs-on: ${{ matrix.distro }} + steps: + - name: Install build tools (using apt) + run: > + sudo apt update && + sudo apt -y install git build-essential cmake gcc linux-headers-`uname -r` + libpcre3-dev libssl-dev liblua5.1-0-dev kmod python3-pip + iproute2 ppp pppoe isc-dhcp-client + + - name: Install testing tools (using pip) + run: > + sudo pip3 install pytest pytest-dependency gcovr + + - name: Check out repository code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: mkdir build + run: mkdir build + + - name: cmake (with coverage) + working-directory: ./build + run: > + cmake -DBUILD_IPOE_DRIVER=TRUE -DBUILD_VLAN_MON_DRIVER=TRUE -DCMAKE_INSTALL_PREFIX=/usr + -DKDIR=/usr/src/linux-headers-`uname -r` + -DLUA=TRUE -DSHAPER=TRUE -DRADIUS=TRUE .. + + - name: make && make install + working-directory: ./build + run: make && sudo make install + + - name: Insert and check kernel modules (ipoe and vlan-mon) + # if: ${{ false }} + run: | + sudo insmod build/drivers/vlan_mon/driver/vlan_mon.ko + sudo insmod build/drivers/ipoe/driver/ipoe.ko + lsmod | grep ipoe + lsmod | grep vlan_mon + + - name: Run tests + working-directory: ./tests + run: sudo python3 -m pytest -Wall -v + + Build-and-Test-With-Coverage: + #if: ${{ false }} # disable for now + strategy: + fail-fast: false + matrix: + distro: ["ubuntu-22.04", "ubuntu-20.04"] + + runs-on: ${{ matrix.distro }} + steps: + - name: Install build tools (using apt) + run: > + sudo apt update && + sudo apt -y install git build-essential cmake gcc linux-headers-`uname -r` + libpcre3-dev libssl-dev liblua5.1-0-dev kmod python3-pip + iproute2 ppp pppoe isc-dhcp-client + + - name: Install testing tools (using pip) + run: > + sudo pip3 install pytest pytest-dependency gcovr + + - name: Check out repository code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: mkdir build + run: mkdir build + + - name: cmake (with coverage) + working-directory: ./build + run: > + cmake -DBUILD_IPOE_DRIVER=TRUE -DBUILD_VLAN_MON_DRIVER=TRUE -DCMAKE_INSTALL_PREFIX=/usr + -DKDIR=/usr/src/linux-headers-`uname -r` + -DLUA=TRUE -DSHAPER=TRUE -DRADIUS=TRUE + -DCMAKE_C_FLAGS="--coverage -O0" .. + + - name: make && make install + working-directory: ./build + run: make && sudo make install + + - name: Insert and check kernel modules (ipoe and vlan-mon) + # if: ${{ false }} + run: | + sudo insmod build/drivers/vlan_mon/driver/vlan_mon.ko + sudo insmod build/drivers/ipoe/driver/ipoe.ko + lsmod | grep ipoe + lsmod | grep vlan_mon + + - name: Run tests (for coverage report) (fail is ok) + working-directory: ./tests + run: sudo python3 -m pytest -Wall -v || exit 0 + + - name: Generate coverage reports (default(txt), csv, html) + run: | + mkdir -p tests/report + gcovr --config=tests/gcovr.conf --output=tests/report/accel-ppp.txt + gcovr --config=tests/gcovr.conf --csv --output=tests/report/accel-ppp.csv + gcovr --config=tests/gcovr.conf --html --html-details --output=tests/report/accel-ppp.html + + - name: Show default coverage report + run: cat tests/report/accel-ppp.txt + + - name: Upload coverage report + # if: ${{ false }} + uses: actions/upload-artifact@v3 + with: + name: coverage-report-on-${{ matrix.distro }} + path: tests/report/ + if-no-files-found: error |