Skip to content

Commit

Permalink
add tests in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ansavin committed Aug 25, 2024
1 parent 328e7a0 commit 4871ebd
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/run_module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Run module

on:
push:
pull_request:
schedule:
- cron: '0 12 * * 0'

jobs:
run:
runs-on: ubuntu-22.04
steps:
### DEPENDENCIES ###

# Hard turn-off interactive mode
- run: echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections

# Install dependencies
- run: sudo apt update
- run: sudo apt -y install bison busybox-static coreutils cpio elfutils file flex gcc gcc-multilib git iproute2 jq kbd kmod libcap-dev libelf-dev libunwind-dev libvirt-clients libzstd-dev linux-headers-generic linux-tools-common linux-tools-generic make pahole pkg-config python3-dev python3-pip python3-requests qemu-kvm rsync udev zstd curl
### END DEPENDENCIES ###

# Install virtme-ng
- run: pip install virtme-ng

# Checkout git repository
- uses: actions/checkout@v4

# Get the latest linux kernel
- run: git clone --single-branch -b master --depth 1 https://github.com/torvalds/linux.git

# Print the latest commit of the checked out linux kernel
- run: cd linux && git log -1 --pretty=format:"%h %ad %s" --date=short

# Build kernel
- run: cd linux && vng -v --build

# Generate kernel headers
- run: cd linux && make headers

# Print CPU model before running the tests (this can be useful for
# debugging purposes)
- run: grep 'model name' /proc/cpuinfo | head -1

# Setup KVM support
- name: "KVM support"
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
# Run VM & test that module loads & unloads
- run: cd linux && vng -v -- 'cd .. && ls && make KSRC=linux && insmod mod-webserver.ko && rmmod mod-webserver.ko && echo OK' | grep OK

# Run VM & test that webserver is NOT working if we didn't enable it
- run: cd linux && vng -v -- 'cd .. && ls && make KSRC=linux && insmod mod-webserver.ko && (curl 127.0.0.1:2000 || echo OK)' | grep OK

# Run VM & test that webserver is working if we enable it
- run: cd linux && vng -v -- 'cd .. && ls && make KSRC=linux && insmod mod-webserver.ko && echo 1 > /sys/kernel/webserver/net/data/status && curl 127.0.0.1:2000' | grep PONG

# Run VM & test that webserver is able to work on custom port
- run: cd linux && vng -v -- 'cd .. && ls && make KSRC=linux && insmod mod-webserver.ko port=3000 && echo 1 > /sys/kernel/webserver/net/data/status && curl 127.0.0.1:3000' | grep PONG

0 comments on commit 4871ebd

Please sign in to comment.