Skip to content

Commit 3fcbb8e

Browse files
authored
Improve CI pipeline to automate module testing (#95)
The script executes insmod/rmmod twice with available kernel modules. Close #72
1 parent 148fb01 commit 3fcbb8e

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

.ci/build-n-run.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
function build_example()
4+
{
5+
make -C examples || exit 1
6+
}
7+
8+
function list_mod()
9+
{
10+
#following list will contain all file names which are not specified in file non-working.
11+
echo `ls examples/*.ko | awk -F "[/|.]" '{print $2}' | grep -vFxf .ci/non-working`
12+
}
13+
14+
#test module 2 times
15+
function run_mod()
16+
{
17+
( sudo insmod "examples/$1.ko" && sudo rmmod "$1" ) || exit 1;
18+
( sudo insmod "examples/$1.ko" && sudo rmmod "$1" ) || exit 1;
19+
}
20+
21+
function run_examples()
22+
{
23+
for module in $(list_mod); do
24+
echo "$module"
25+
run_mod "$module"
26+
done
27+
}
28+
29+
build_example
30+
run_examples

.ci/non-working

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bottomhalf
2+
intrpt
3+
kbleds

.github/workflows/generate_doc.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ jobs:
3636
tag_name: "latest"
3737
prerelease: true
3838

39-
coding_style:
39+
validate:
4040
runs-on: ubuntu-20.04
4141
steps:
4242
- name: checkout code
4343
uses: actions/checkout@v2
44-
- name: style check
44+
- name: validate coding style and functionality
4545
run: |
4646
sudo apt-get install -q -y clang-format-11
4747
sh .ci/check-format.sh
48-
shell: bash
48+
bash .ci/build-n-run.sh
49+
shell: bash

examples/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ obj-m += hello-2.o
33
obj-m += hello-3.o
44
obj-m += hello-4.o
55
obj-m += hello-5.o
6-
obj-m += start.o
7-
obj-m += stop.o
6+
obj-m += startstop.o
7+
startstop-objs := start.o stop.o
88
obj-m += chardev.o
99
obj-m += procfs1.o
1010
obj-m += procfs2.o
@@ -30,6 +30,8 @@ obj-m += example_mutex.o
3030
obj-m += bottomhalf.o
3131
obj-m += ioctl.o
3232

33+
PWD := $(CURDIR)
34+
3335
all:
3436
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
3537

0 commit comments

Comments
 (0)