Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit 15634a8

Browse files
committed
tests/*: fundamental implementation of build-time package integrity check modules
Signed-off-by: Camber Huang <camber@aosc.io>
1 parent e6e1158 commit 15634a8

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

tests/00-self_file.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
##tests/00-self_file.sh: invoke testing function defined in `autobuild/test`
3+
##Part of AB3 build-time package integrity check implementation.
4+
##@copyright GPL-2.0+
5+
6+
. "$AB/tests"/_base.sh
7+
8+
abtest() {
9+
abwarn "ABTEST_TYPE is set to self, but no abtest() found in autobuild{,/\$ARCH}/test"
10+
return 127
11+
}
12+
13+
abtest_unprivileged() {
14+
abwarn "ABTEST_TYPE is set to self, but no abtest_unprivileged() found in autobuild{,/\$ARCH}/test"
15+
return 127
16+
}
17+
18+
# Redefine
19+
arch_loadfile "$SRCDIR"/test
20+
21+
abtest || abtest_non-zero-handler $1 "$SRCDIR"/test
22+
abtest_unprivileged || abtest_unprivileged_non-zero-handler $1 "$SRCDIR"/test

tests/01-self_files.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
##tests/01-self_files.sh: invoke testing function defined in `autobuild/tests/T*.sh`
3+
##Part of AB3 build-time package integrity check implementation.
4+
##@copyright GPL-2.0+
5+
6+
. "$AB/tests"/_base.sh
7+
8+
for i in "$SRCDIR"/tests/T*.sh
9+
do
10+
arch_loadfile $i
11+
abtest || abtest_non-zero-handler $? $i
12+
abtest_unprivileged || abtest_non-zero-handler $? $i
13+
unset abtest abtest_unprivileged
14+
done
15+

tests/_base.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
##tests/_base.sh: Basic functions of build-time package integrity check modules.
3+
##@copyright GPL-2.0+
4+
5+
abtest_non-zero-handler() {
6+
case $1 in
7+
0) return 0;;
8+
127) abwarn "No abtest() available in file ${2}";;
9+
*) abwarn "Non-zero returned: ${1}!";;
10+
esac
11+
}
12+
13+
abtest_unprivileged_non-zero-handler() {
14+
case $1 in
15+
127) abwarn "No abtest_unprivileged() available in file ${2}";;
16+
*) abtest_non-zero-handler $1 $2;;
17+
esac
18+
}

0 commit comments

Comments
 (0)