Skip to content

Commit 7e2bec4

Browse files
committed
test: fix tests for newer kernels
The ubuntu-latest kernel now has a 6.2 kernel. That makes the creation of a new userfault file descriptor to use path that creates the fd issuing an ioctl to /dev/userfaultfd. However, in our Github action /dev/userfaultfd is read/write only by root whereas the job is running as the "runner" user. This causes the tests to fail, because they can't open the device file to issue the ioctl. This commit does two things. First it creates a test matrix so that we run the github action both on ubuntu-latest (with a newer kerenl) and ubuntu-20.04 that uses a 5.15 kernel. That ensures that we test both file descriptor creation paths (/dev/userfaultfd and userfaultfd syscall). Second, in the case of ubuntu-latest it gives to the "runner" user access to /dev/userfaultfd file. Signed-off-by: Babis Chalios <[email protected]>
1 parent e2a9066 commit 7e2bec4

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

.github/workflows/rust.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,50 @@ on:
99
jobs:
1010
build:
1111

12-
runs-on: ubuntu-latest
12+
# ubuntu-latest runs a recent kernel with /dev/userfaultfd support whereas
13+
# ubuntu-20.04 has a 5.15 kernel. We run the job in both, so we can test
14+
# both paths for creating the file descriptor, i.e. /dev/userfaultfd ioctl
15+
# and userfaultfd syscall.
16+
runs-on: ${{ matrix.runner }}
17+
strategy:
18+
matrix:
19+
runner: [ ubuntu-latest, ubuntu-20.04 ]
1320

1421
steps:
1522
- uses: actions/checkout@v2
23+
24+
# Keep this step, so that we can check that the Linux kernel is the one we
25+
# expect, depending on the runner kernel.
26+
- name: Check Linux version
27+
run: uname -r
28+
29+
# /dev/userfaultfd is only present on ubuntu-latest.
30+
- name: Setup access to /dev/userfaultfd
31+
if: ${{ matrix.runner == 'ubuntu-latest' }}
32+
run: sudo setfacl -m u:${USER}:rw /dev/userfaultfd
33+
1634
- name: Build
1735
run: cargo build --verbose
1836

19-
# The github ubuntu-latest is now on linux 5.11 kernel,
20-
# so we can test the crate with support for each of the
21-
# kernel featuresets:
22-
2337
- name: Run tests (Linux 4.11 support)
2438
run: cargo test --verbose
2539
- name: Run tests (Linux 4.14 support)
2640
run: cargo test --verbose --features linux4_14
41+
2742
- name: Run tests (Linux 5.7 support)
43+
if: ${{ matrix.runner == 'ubuntu-latest' }}
2844
run: cargo test --verbose --features linux5_7
2945

46+
# On ubuntu-20.04 runner we need to make sure we have the proper kernel
47+
# headers for building the correct bindings
48+
- name: Run tests (Linux 5.7 support)
49+
if: ${{ matrix.runner == 'ubuntu-20.04' }}
50+
run:
51+
sudo apt update &&
52+
sudo apt install -y linux-headers-5.11.0-25-generic &&
53+
export LINUX_HEADERS=/usr/src/linux-headers-5.11.0-25-generic &&
54+
cargo test --verbose --features linux5_7
55+
3056
audit:
3157

3258
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)