diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2022-11-17 14:58:01 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2022-11-17 15:50:38 +0000 |
commit | 2947bb73b960358653cbc478b073e388a9d42a2f (patch) | |
tree | 1cb94d5a04e91b5533de5f7adca1dc514dead8b2 | |
parent | 2504097d53ca26b8db307a4351b3e8ab0a946a7b (diff) | |
download | alpine-conf-2947bb73b960358653cbc478b073e388a9d42a2f.zip |
tests: add fake apk
We need this to test what we get into modloop in update-kernel
-rwxr-xr-x | tests/bin/apk | 61 | ||||
-rwxr-xr-x | tests/fake_apk_test | 24 |
2 files changed, 85 insertions, 0 deletions
diff --git a/tests/bin/apk b/tests/bin/apk new file mode 100755 index 0000000..6ad3bc2 --- /dev/null +++ b/tests/bin/apk @@ -0,0 +1,61 @@ +#!/bin/sh + +arch=aarch64 + +if [ "$1" = "--print-arch" ]; then + echo $arch + exit +fi + +echo "DEBUG: fake apk" "$@" + +rootfs=. +kver=5.15.78-0 +while [ $# -gt 0 ]; do + case "$1" in + add|del) + cmd="$1" + ;; + -p|--root) + shift + rootfs="$1" + ;; + --arch) shift ;; + --repositories-file) shift ;; + --keys-dir) shift ;; + [a-z]*) + pkgs="$pkgs $1" + ;; + esac + shift +done + +for pkg in $pkgs; do + case "$pkg" in + linux-firmware*) + # simulate install firmware + mkdir -p "$rootfs"/lib/firmware/brcm + touch "$rootfs"/lib/firmware/brcm/brcmfmac43456-sdio.raspberrypi,400.bin \ + "$rootfs"/lib/firmware/brcm/brcmfmac43456-sdio.raspberrypi,400.clm_blob \ + "$rootfs"/lib/firmware/brcm/brcmfmac43456-sdio.raspberrypi,400.txt \ + "$rootfs"/lib/firmware/brcm/brcmfmac43752-sdio.bin + ;; + linux-*) + # simulate installing kernel + flavor=${pkg#linux-} + mkdir -p "$rootfs"/lib/modules/$kver-$flavor/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac \ + "$rootfs"/boot + touch "$rootfs"/boot/System.map-$flavor \ + "$rootfs"/boot/config-$flavor \ + "$rootfs"/boot/vmlinuz-$flavor + cat >"$rootfs/lib/modules/$kver-$flavor"/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko <<-EOF + vermagic: $kver-$flavor SMP preempt mod_unload modversions $arch + firmware: brcm/brcmfmac*-sdio.*.bin + firmware: brcm/brcmfmac*-sdio.*.txt + firmware: brcm/brcmfmac43752-sdio.clm_blob + firmware: brcm/brcmfmac43752-sdio.bin + EOF + gzip "$rootfs/lib/modules/$kver-$flavor"/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko + ;; + esac +done diff --git a/tests/fake_apk_test b/tests/fake_apk_test new file mode 100755 index 0000000..84c80ec --- /dev/null +++ b/tests/fake_apk_test @@ -0,0 +1,24 @@ +#!/usr/bin/env atf-sh + +. $(atf_get_srcdir)/test_env.sh +init_tests \ + fake_apk_add + +fake_apk_add_body() { + init_env + atf_check -s exit:0 \ + -o match:"DEBUG: fake apk" \ + apk add linux-rpi + + test -f boot/vmlinuz-rpi || atf_fail "boot/vmlinuz-rpi was not created" + + atf_check -s exit:0 \ + -o match:"DEBUG: fake apk" \ + apk add linux-firmware + + atf_check \ + -o match:"lib/firmware" \ + -o match:"lib/modules" \ + find +} + |