[go: up one dir, main page]

Skip to content

Commit

Permalink
Improve CI pipeline to automate module testing (sysprog21#95)
Browse files Browse the repository at this point in the history
The script executes insmod/rmmod twice with available kernel modules.

Close sysprog21#72
  • Loading branch information
fennecJ authored Sep 8, 2021
1 parent 148fb01 commit 3fcbb8e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
30 changes: 30 additions & 0 deletions .ci/build-n-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

function build_example()
{
make -C examples || exit 1
}

function list_mod()
{
#following list will contain all file names which are not specified in file non-working.
echo `ls examples/*.ko | awk -F "[/|.]" '{print $2}' | grep -vFxf .ci/non-working`
}

#test module 2 times
function run_mod()
{
( sudo insmod "examples/$1.ko" && sudo rmmod "$1" ) || exit 1;
( sudo insmod "examples/$1.ko" && sudo rmmod "$1" ) || exit 1;
}

function run_examples()
{
for module in $(list_mod); do
echo "$module"
run_mod "$module"
done
}

build_example
run_examples
3 changes: 3 additions & 0 deletions .ci/non-working
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bottomhalf
intrpt
kbleds
7 changes: 4 additions & 3 deletions .github/workflows/generate_doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ jobs:
tag_name: "latest"
prerelease: true

coding_style:
validate:
runs-on: ubuntu-20.04
steps:
- name: checkout code
uses: actions/checkout@v2
- name: style check
- name: validate coding style and functionality
run: |
sudo apt-get install -q -y clang-format-11
sh .ci/check-format.sh
shell: bash
bash .ci/build-n-run.sh
shell: bash
6 changes: 4 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ obj-m += hello-2.o
obj-m += hello-3.o
obj-m += hello-4.o
obj-m += hello-5.o
obj-m += start.o
obj-m += stop.o
obj-m += startstop.o
startstop-objs := start.o stop.o
obj-m += chardev.o
obj-m += procfs1.o
obj-m += procfs2.o
Expand All @@ -30,6 +30,8 @@ obj-m += example_mutex.o
obj-m += bottomhalf.o
obj-m += ioctl.o

PWD := $(CURDIR)

all:
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

Expand Down

0 comments on commit 3fcbb8e

Please sign in to comment.