summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2023-01-23 19:28:28 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2023-01-24 10:41:58 +0000
commitf62775fc697446d1d969faa55adcdeca5400b8ea (patch)
tree59b945aa3dcd06915adda27a0b544b5667e917b9
parentea460f60dc63c6a41b510fdecef03b7a2e1af9a2 (diff)
downloadalpine-conf-f62775fc697446d1d969faa55adcdeca5400b8ea.zip
tests: move fake audit to fake apk
So we can re-use it
-rwxr-xr-xtests/bin/apk15
-rwxr-xr-xtests/fake_apk_test7
-rwxr-xr-xtests/lbu_test16
3 files changed, 18 insertions, 20 deletions
diff --git a/tests/bin/apk b/tests/bin/apk
index 8f2a945..df1711c 100755
--- a/tests/bin/apk
+++ b/tests/bin/apk
@@ -9,6 +9,7 @@ fi
rootfs=.
kver=5.15.78-0
+audit_prefix="U "
while [ $# -gt 0 ]; do
case "$1" in
add|del)
@@ -16,13 +17,15 @@ while [ $# -gt 0 ]; do
cmd="$1"
;;
audit)
- echo "U etc/hostname"
- exit 0
+ cmd="$1"
;;
-p|--root)
shift
rootfs="$1"
;;
+ --quiet)
+ audit_prefix=""
+ shift ;;
--arch) shift ;;
--repositories-file) shift ;;
--keys-dir) shift ;;
@@ -33,6 +36,14 @@ while [ $# -gt 0 ]; do
shift
done
+if [ "$cmd" = audit ]; then
+ mkdir -p etc
+ touch etc/hosts etc/localtime
+ echo "${audit_prefix}etc/hosts"
+ echo "${audit_prefix}etc/localtime"
+ exit 0
+fi
+
for pkg in $pkgs; do
case "$pkg" in
linux-firmware*)
diff --git a/tests/fake_apk_test b/tests/fake_apk_test
index 8ceba87..8dd140b 100755
--- a/tests/fake_apk_test
+++ b/tests/fake_apk_test
@@ -24,10 +24,13 @@ fake_apk_add_body() {
fake_apk_audit_body() {
init_env
- mkdir etc
- echo "foo" > etc/hostname
atf_check -s exit:0 \
-o no-match:"DEBUG: fake apk" \
-o match:"U etc/hostname" \
apk audit
+
+ atf_check -s exit:0 \
+ -o no-match:"DEBUG: fake apk" \
+ -o match:"etc/hostname" \
+ apk audit --quiet
}
diff --git a/tests/lbu_test b/tests/lbu_test
index 73f0e65..6f9a537 100755
--- a/tests/lbu_test
+++ b/tests/lbu_test
@@ -160,22 +160,8 @@ lbu_st_usage_body() {
lbu st -h
}
-create_fake_apk_audit() {
- mkdir -p bin etc
- cat >bin/apk<<-EOF
- #!/bin/sh
- # mock apk
- echo etc/localtime
- echo etc/hosts
- EOF
- chmod +x bin/apk
- touch etc/localtime etc/hosts
- export PATH="$PWD/bin:$PATH"
-}
-
lbu_package_body() {
init_env
- create_fake_apk_audit
atf_check \
lbu package
@@ -204,7 +190,6 @@ lbu_package_encrypted_body() {
echo 'ENCRYPTION=$DEFAULT_CIPHER'
echo 'PASSWORD=foobar'
) > "$PWD/$sysconfdir/lbu.conf"
- create_fake_apk_audit
atf_check \
-e match:"WARNING" \
@@ -218,7 +203,6 @@ lbu_package_encrypted_body() {
lbu_package_pre_post_hooks_body() {
init_env
get_sysconfdir
- create_fake_apk_audit
mkdir -p "$PWD/$sysconfdir/pre-package.d" \
"$PWD/$sysconfdir/post-package.d"