Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/tests/frontend/check.sh
2648 views
1
#! /usr/bin/env atf-sh
2
3
. $(atf_get_srcdir)/test_environment.sh
4
5
tests_init \
6
basic \
7
dirs
8
9
basic_body() {
10
atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1"
11
12
user=$(id -un)
13
if [ "${OS}" = "FreeBSD" ]; then
14
group=$(stat -f "%Sg" .)
15
else
16
group=$(id -gn)
17
fi
18
cat <<__EOF__ >> test.ucl
19
files: {
20
${TMPDIR}/a: {
21
uname: "${user}"
22
gname: "${group}"
23
perm: 0644
24
},
25
}
26
__EOF__
27
28
echo a > a
29
atf_check pkg create -M test.ucl
30
atf_check mkdir -p target
31
atf_check pkg -o REPOS_DIR=/dev/null -r target install -qfy ${TMPDIR}/test-1.pkg
32
atf_check pkg -r target check -q
33
atf_check -s exit:0 pkg -r target check -mq
34
echo b > ${TMPDIR}/target/${TMPDIR}/a
35
touch -r ./a ${TMPDIR}/target/${TMPDIR}/a
36
atf_check -s not-exit:0 -e inline:"test-1: checksum mismatch for ${TMPDIR}/a\n" \
37
pkg -r target check -q
38
atf_check -s exit:0 pkg -r target check -mq
39
touch -t 197001010000.01 ${TMPDIR}/target/${TMPDIR}/a
40
atf_check -s exit:1 -e match:"\[mtime\]" pkg -r target check -mq
41
touch -r ./a ${TMPDIR}/target/${TMPDIR}/a
42
atf_check -s exit:0 pkg -r target check -mq
43
ln -sf b ${TMPDIR}/target/${TMPDIR}/a
44
atf_check -s exit:1 -e match:"\[symlink\]" -e match:"\[perm\]" pkg -r target check -mq
45
chmod -h 0644 ${TMPDIR}/target/${TMPDIR}/a
46
touch -hr ./a ${TMPDIR}/target/${TMPDIR}/a
47
# linux mangles perms on symlinks
48
if [ "${OS}" = "FreeBSD" -o ${OS} = "Darwin" ]; then
49
atf_check -s exit:1 -e match:"\[symlink\]" -e not-match:"\[perm\]" -e not-match:"\[mtime\]" pkg -r target check -mq
50
else
51
atf_check -s exit:1 -e match:"\[symlink\]" -e match:"\[perm\]" -e not-match:"\[mtime\]" pkg -r target check -mq
52
fi
53
rm ${TMPDIR}/target/${TMPDIR}/a
54
mkdir ${TMPDIR}/target/${TMPDIR}/a
55
touch -r a ${TMPDIR}/target/${TMPDIR}/a
56
chmod 0644 ${TMPDIR}/target/${TMPDIR}/a
57
atf_check -s exit:1 -e match:"\[type\]" pkg -r target check -mq
58
}
59
60
dirs_body() {
61
atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1"
62
63
user=$(id -un)
64
if [ "${OS}" = "FreeBSD" ]; then
65
group=$(stat -f "%Sg" .)
66
else
67
group=$(id -gn)
68
fi
69
cat <<__EOF__ >> test.ucl
70
directories: {
71
${TMPDIR}/a: {
72
uname: "${user}"
73
gname: "${group}"
74
perm: 0644
75
},
76
}
77
__EOF__
78
79
mkdir a
80
atf_check pkg create -M test.ucl
81
atf_check mkdir -p target
82
atf_check pkg -o REPOS_DIR=/dev/null -r target install -qfy ${TMPDIR}/test-1.pkg
83
atf_check pkg -r target check -mq
84
# mtime is not checked for directories
85
touch -t 197001010000.01 ${TMPDIR}/target/${TMPDIR}/a
86
atf_check pkg -r target check -mq
87
chmod 0600 ${TMPDIR}/target/${TMPDIR}/a
88
atf_check -s exit:1 -e match:"\[perm\]" pkg -r target check -mq
89
chmod 0644 ${TMPDIR}/target/${TMPDIR}/a
90
atf_check -s exit:0 pkg -r target check -mq
91
rmdir ${TMPDIR}/target/${TMPDIR}/a
92
touch ${TMPDIR}/target/${TMPDIR}/a
93
atf_check -s exit:1 -e match:"\[type\]" pkg -r target check -mq
94
}
95
96