Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
245 changes: 245 additions & 0 deletions kernel_kselftest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
#!/bin/sh
set -e

# So we can detect what version of Rocky we are running on
. /etc/os-release

if [ ! -f .config ] ; then
echo "No .config found. Please configure before testing"
exit 1
fi

if [ $# -eq 1 ] ; then
runs=$1
else
runs=1
fi

install_kselftest_deps_8() {
echo
echo "Installing kselftest deps for Rocky 8"
echo
sudo dnf -y groupinstall 'Development Tools'
sudo dnf -y install epel-release
sudo dnf -y install --enablerepo=devel \
VirtualGL \
alsa-lib-devel \
bc \
clang \
curl \
dropwatch \
dwarves \
glibc \
iperf3 \
jq \
kernel-devel \
libasan \
libcap-devel \
libcap-ng-devel \
libmnl-devel \
libreswan \
libubsan \
llvm \
ncurses-devel \
net-tools \
netsniff-ng \
nmap-ncat \
numactl-devel \
openssl-devel \
perf \
popt-devel \
python3-pip \
rsync \
socat \
tcpdump \
wget

# Doesn't work for 8.6?
sudo dnf -y install --enablerepo=devel \
fuse-devel \
gcc-toolset-13-libasan-devel \
glibc-static \
kernel-selftests-internal

pip3 install --user \
netaddr \
packaging \
pyftpdlib \
pyparsing \
pytest \
scapy \
tftpy
}

install_kselftest_deps_9() {
echo
echo "Installing kselftest deps for Rocky 9"
echo
sudo dnf -y groupinstall 'Development Tools'
sudo dnf -y install epel-release
sudo dnf -y install --enablerepo=crb,devel \
VirtualGL \
alsa-lib-devel \
bc \
clang \
curl \
dropwatch \
dwarves \
fuse-devel \
gcc-toolset-13-libasan-devel \
glibc \
glibc-static \
iperf3 \
jq \
kernel-devel \
kernel-selftests-internal \
libasan \
libcap-devel \
libcap-ng-devel \
libmnl-devel \
libreswan \
libubsan \
llvm \
ncurses-devel \
net-tools \
netsniff-ng \
nmap-ncat \
numactl-devel \
openssl-devel \
packetdrill \
perf \
popt-devel \
python3-pip \
rsync \
socat \
tcpdump \
virtme-ng \
wget

pip3 install --user \
netaddr \
packaging \
pyftpdlib \
pyparsing \
pytest \
scapy \
tftpy \
wheel
}

install_kselftest_deps_10() {
echo
echo "Installing kselftest deps for Rocky 10"
echo
sudo dnf -y groupinstall 'Development Tools'
sudo dnf -y install epel-release
sudo dnf -y install --enablerepo=crb,devel \
alsa-lib-devel \
bc \
clang \
curl \
dropwatch \
dwarves \
fuse-devel \
glibc \
glibc-static \
iperf3 \
kernel-devel \
kernel-selftests-internal \
libasan \
libasan-static \
libcap-devel \
libcap-ng-devel \
libmnl-devel \
libreswan \
libubsan \
llvm \
ncurses-devel \
net-tools \
nmap-ncat \
numactl-devel \
openssl-devel \
packetdrill \
perf \
popt-devel \
python3-pip \
rsync \
socat \
tcpdump \
virtme-ng \
wget

pip3 install --user \
netaddr \
packaging \
pyftpdlib \
pyparsing \
pytest \
scapy \
tftpy \
wheel
}

run_kselftest() {
SUDO_TARGETS=$1
SKIP_TARGETS=$2
make -C tools/testing/selftests clean
make -C tools/testing/selftests SKIP_TARGETS="$SKIP_TARGETS"
for run in $(seq 1 $runs) ; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yesterday I triggered another run by mistake and I wish I saved the previous log.
If you also think it's valuable, I would check if a file with the same name exists and adjust the run var accordingly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe timestamping logs makes more sense than numbering?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way, I will not know easily which one is which if they have long names. Not sure here which one is the best at the moment. Maybe this is over engineering at the moment.

make -C tools/testing/selftests SKIP_TARGETS="$SUDO_TARGETS $SKIP_TARGETS" run_tests | tee ~/selftest-$(uname -r)-$run.log
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~/selftest-$(uname -r)-$run.log does not work for me. And I believe it would be a bit hard to differentiate between logs if we save all of them in the same place, even though we do include the version in the name.

The folder structure for each vm (kernel type) I have is:

kernel-dist-git
kernel-src-tree
kernel-src-tree-tools -> /home/rnicolescu/ciq/kernel-src-tree-tools
kernel-tools -> /home/rnicolescu/ciq/kernel-tools
build-logs
kselftests-logs

So for me ../kselftests-logs/selftest-$(uname -r)-$run.log would work. Or something similar, happy to adjust it.

We can also add a param for this, but I would keep it simple. I think it would be super easier for our tooling if we all have the same tree structure for kernels.
What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, ../kselftests-logs makes sense. or....err... ../kselftest-logs I never know whether to use kselftest or kselftests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also bad at naming. Pick one and stick with it :)

sudo make -C tools/testing/selftests TARGETS="$SUDO_TARGETS" run_tests | tee -a ~/selftest-$(uname -r)-$run.log
done
}

case "$ROCKY_SUPPORT_PRODUCT" in
Rocky-Linux-10)
install_kselftest_deps_10
;;
Rocky-Linux-9)
install_kselftest_deps_9
;;
Rocky-Linux-8)
install_kselftest_deps_8
;;
esac

case $(uname -r) in
*3.10.0*)
echo
echo "Running 3.10.0 kselftests"
echo
SUDO_TARGETS="x86"
SKIP_TARGETS=""
;;
*4.18.0*)
echo
echo "Running 4.18.0 kselftests"
echo
SUDO_TARGETS="capabilities cpu-hotplug cpufreq efivars efivarfs fpu ipc intel_pstate kexec lib livepatch memfd memory-hotplug mptcp mqueue net netfilter sync sysctl timens timers vm x86 zram"
SKIP_TARGETS=""
;;
*5.14.0*)
echo
echo "Running 5.14.0 kselftests"
echo
SUDO_TARGETS="binderfs capabilities cgroup cpu-hotplug cpufreq efivars efivarfs firmware fpu gpio ipc intel_pstate ir kexec lib livepatch memfd memory-hotplug mptcp mqueue net netfilter sync sysctl timens timers vm x86 zram"
SKIP_TARGETS="lkdtm proc"
;;
*6.12.*)
echo
echo "Running 6.12 kselftests"
echo
SUDO_TARGETS="binderfs capabilities cgroup clone3 cpu-hotplug cpufreq damon drivers/net efivars efivarfs exec firmware fpu gpio ipc intel_pstate ir kexec lib livepatch memfd memory-hotplug mptcp mqueue net netfilter sync sysctl timens timers vm x86 zram"
SKIP_TARGETS="lkdtm"
;;
*)
echo
echo "Warning: Unknown kernel version ($(uname -r)). No kselftest targets defined."
echo "SUDO_TARGETS and SKIP_TARGETS will be empty."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I would exit here. Because otherwise it will run the kselftests for an unknown version.

I would imagine we run into this if we test a new kernel. So an early exit would catch this and then the person running this would add a case here for the new kernel version. Otherwise the kselftests would run and this warning may be missed.

What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I almost made it exit here. I could go either way.

SUDO_TARGETS=""
SKIP_TARGETS=""
;;
esac

run_kselftest "$SUDO_TARGETS" "$SKIP_TARGETS"