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

Commit d7c7313

Browse files
committed
meta: fundamental implementation of build-time package integrity check module
- tests/* + lib/tests.sh: more AB3 style - proc: add scripts for test module Signed-off-by: Camber Huang <camber@aosc.io>
1 parent e5cdc5f commit d7c7313

File tree

6 files changed

+84
-21
lines changed

6 files changed

+84
-21
lines changed

tests/_base.sh renamed to lib/tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
##tests/_base.sh: Basic functions of build-time package integrity check modules.
2+
##lib/tests.sh: Basic functions of build-time package integrity check modules.
33
##@copyright GPL-2.0+
44

55
abtest_non-zero-handler() {

proc/81-test_probe.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
##proc/81-test_probe.sh: TBF
3+
##FIXME: is there a better name for this?
4+
##@copyright GPL-2.0+
5+
6+
. "$AB/lib/tests.sh"
7+
8+
if bool $ABTEST_ENABLED; then
9+
if [ -z "$ABTEST_TYPE"]; then
10+
for i in $ABTEST_TESTPROBES; do
11+
if abtest_${i}_probe; then
12+
ABTEST_TYPE=$i
13+
break
14+
fi
15+
done
16+
fi
17+
else
18+
abinfo "Build-time package integrity check is disabled. Skipping ..."
19+
fi
20+

proc/82-test_exec.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
##proc/81-check.sh: TBF
3+
##@copyright GPL-2.0+
4+
5+
abtrylib tests || ablibret
6+
7+
cd "$SRCDIR"
8+
9+
abtest_${ABTEST_TYPE}_test || \
10+
abwarn "Test exited with non-zero status: $?"

tests/00-self_file.sh

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,30 @@
33
##Part of AB3 build-time package integrity check implementation.
44
##@copyright GPL-2.0+
55

6-
. "$AB/tests"/_base.sh
6+
abtrylib arch tests || ablibret
77

8-
abtest() {
9-
abwarn "ABTEST_TYPE is set to self, but no abtest() found in autobuild{,/\$ARCH}/test"
10-
return 127
8+
abtest_self_file_probe() {
9+
[ -f "$(arch_trymore=1 arch_findfile test)" ]
1110
}
1211

13-
abtest_unprivileged() {
14-
abwarn "ABTEST_TYPE is set to self, but no abtest_unprivileged() found in autobuild{,/\$ARCH}/test"
15-
return 127
16-
}
12+
abtest_self_file_test() {
13+
. "$AB/lib/tests.sh"
14+
15+
abtest() {
16+
abwarn "ABTEST_TYPE is set to self, but no abtest() found in autobuild{,/\$ARCH}/test"
17+
return 127
18+
}
19+
20+
abtest_unprivileged() {
21+
abwarn "ABTEST_TYPE is set to self, but no abtest_unprivileged() found in autobuild{,/\$ARCH}/test"
22+
return 127
23+
}
1724

18-
# Redefine
19-
arch_loadfile "$SRCDIR"/test
25+
# Redefine
26+
arch_loadfile "$SRCDIR"/test
27+
28+
abtest || abtest_non-zero-handler $1 "$SRCDIR"/test
29+
abtest_unprivileged || abtest_unprivileged_non-zero-handler $1 "$SRCDIR"/test
30+
}
2031

21-
abtest || abtest_non-zero-handler $1 "$SRCDIR"/test
22-
abtest_unprivileged || abtest_unprivileged_non-zero-handler $1 "$SRCDIR"/test
32+
ABTEST_TESTPROBES+=' self_file'

tests/01-self_files.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@
33
##Part of AB3 build-time package integrity check implementation.
44
##@copyright GPL-2.0+
55

6-
. "$AB/tests"/_base.sh
6+
abtrylib tests || ablibret
77

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
8+
abtest_self_files_probe() {
9+
[ -d "$SRCDIR"/autobuild/tests ]
10+
}
1511

12+
abtest_self_files_test() {
13+
. "$AB/lib/tests.sh"
14+
15+
for i in "$SRCDIR"/tests/T*.sh
16+
do
17+
arch_loadfile $i
18+
abtest || abtest_non-zero-handler $? $i
19+
abtest_unprivileged || abtest_non-zero-handler $? $i
20+
unset abtest abtest_unprivileged
21+
done
22+
}
23+
24+
ABTEST_TESTPROBES+=' self_files'

tests/99-notest.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
##tests/99-notest.sh: Dummy file indicates that test is not available.
3+
##Part of AB3 build-time package integrity check implementation.
4+
##@copyright GPL-2.0+
5+
6+
abtest_notest_probe() {
7+
true
8+
}
9+
10+
abtest_notest_test(){
11+
abinfo "ABTEST_TYPE is set to 'notest'. Skipping..."
12+
}
13+
14+
ABTEST_TESTPROBES+=' notest'

0 commit comments

Comments
 (0)