summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2022-11-17 14:58:45 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2022-11-17 15:50:38 +0000
commitbe34bbec6ceabeb6d89acd047d94388dbe5224b5 (patch)
treee1dda5ddcd445fa004bfd8a3dad17e7599697cbc /tests
parent2947bb73b960358653cbc478b073e388a9d42a2f (diff)
downloadalpine-conf-be34bbec6ceabeb6d89acd047d94388dbe5224b5.zip
tests: add fake modinfo
Needed to test that we get the proper firmware included in modloop with update-kernel
Diffstat (limited to 'tests')
-rwxr-xr-xtests/bin/modinfo23
-rwxr-xr-xtests/fake_modinfo_test30
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/bin/modinfo b/tests/bin/modinfo
new file mode 100755
index 0000000..14a43bb
--- /dev/null
+++ b/tests/bin/modinfo
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -k)
+ shift
+ kver="$1"
+ ;;
+ -F)
+ shift
+ field="$1"
+ ;;
+ *)
+ if [ -n "$field" ]; then
+ awk -v field="$field:" '$1==field {print $2}' "$1"
+ else
+ cat "$1"
+ fi
+ ;;
+ esac
+ shift
+done
+
diff --git a/tests/fake_modinfo_test b/tests/fake_modinfo_test
new file mode 100755
index 0000000..de72e3b
--- /dev/null
+++ b/tests/fake_modinfo_test
@@ -0,0 +1,30 @@
+#!/usr/bin/env atf-sh
+
+. $(atf_get_srcdir)/test_env.sh
+init_tests \
+ fake_modinfo
+
+fake_modinfo_body() {
+ init_env
+ kver=5.15.79-0
+ flavor=virt
+ mkdir -p "lib/modules/$kver-$flavor"/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac
+ cat >"lib/modules/$kver-$flavor"/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko <<-EOF
+ vermagic: $kver-$flavor SMP preempt mod_unload modversions aarch64
+ firmware: brcm/brcmfmac*-sdio.*.bin
+ firmware: brcm/brcmfmac*-sdio.*.txt
+ firmware: brcm/brcmfmac43752-sdio.clm_blob
+ firmware: brcm/brcmfmac43752-sdio.bin
+ EOF
+ atf_check -s exit:0 \
+ -o match:"vermagic:" \
+ -o match:"firmware:" \
+ modinfo "lib/modules/$kver-$flavor"/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko
+
+ atf_check -s exit:0 \
+ -o not-match:"vermagic:" \
+ -o not-match:"firmware:" \
+ -o match:"brcm/brcmfmac43752-sdio.clm_blob" \
+ modinfo -k 1.0 -F firmware "lib/modules/$kver-$flavor"/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko
+}
+