Skip to content

Commit

Permalink
FFI test: Add modprobe_module tool
Browse files Browse the repository at this point in the history
The script will run inside the QM partition. And it won't be possible to access /lib/modules to load any module via modprobe.

Jira-URL: https://issues.redhat.com/browse/VROOM-19336
Signed-off-by: weiwang <[email protected]>
  • Loading branch information
weiwang-linda committed May 22, 2024
1 parent 2e577bd commit bb36431
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/e2e/lib/ContainerFile.template
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ RUN dnf install -y \
npm \
rpm-build \
ruby \
ruby-devel \
sed \
vim-enhanced \
systemd-devel \
Expand Down
18 changes: 18 additions & 0 deletions tests/e2e/tools/FFI/module/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# What is modprobe_module?

modprobe_module is a simple script that validates it won't be possible to access /lib/modules to load any module via modprobe inside the QM partition.

# How to use it?

It must be executed inside the QM partition to validate it won't be possible to modprobe any module under /lib/modules.

Example:
```
my-host# podman exec -it qm bash
bash-5.1# ./modprobe_module
modprobe: FATAL: Module ext4 not found in directory /lib/modules/5.14.0-447.400.el9iv.x86_64
ls: cannot access '/lib/modules/5.14.0-447.400.el9iv.x86_64': No such file or directory
done
```
19 changes: 19 additions & 0 deletions tests/e2e/tools/FFI/module/modprobe_module
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

if [ ! -d /lib/modules ]; then
echo "FATAL: /lib/modules: No such file or directory"
exit 1
fi

if [ -n "$(ls -A /lib/modules)" ]; then
echo "This folder should be empty, any modules cannot load via modprobe"
exit 1
fi

# Modprobe module ext4
modprobe ext4

# Access module file
ls $(modprobe ext4 2>&1 >/dev/null | cut -d ' ' -f 9)

echo "done"

0 comments on commit bb36431

Please sign in to comment.