Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/tests/frontend/delete.sh
2065 views
1
#! /usr/bin/env atf-sh
2
3
. $(atf_get_srcdir)/test_environment.sh
4
5
tests_init \
6
delete_all \
7
delete_pkg \
8
delete_with_directory_owned \
9
simple_delete \
10
simple_delete_prefix_ending_with_slash
11
12
delete_all_body() {
13
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "foo" "foo" "1"
14
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkg" "pkg" "1"
15
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1"
16
17
atf_check -o ignore pkg register -M foo.ucl
18
atf_check -o ignore pkg register -M pkg.ucl
19
atf_check -o ignore pkg register -M test.ucl
20
21
atf_check -o ignore pkg delete -ay
22
}
23
24
delete_pkg_body() {
25
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkg" "pkg" "1"
26
atf_check -o ignore pkg register -M pkg.ucl
27
atf_check -o ignore -e ignore -s exit:3 pkg delete -y pkg
28
atf_check -o ignore -e ignore pkg delete -yf pkg
29
}
30
31
simple_delete_body() {
32
touch file1
33
mkdir dir
34
touch dir/file2
35
36
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"
37
cat << EOF >> test.ucl
38
files: {
39
${TMPDIR}/file1: "",
40
${TMPDIR}/dir/file2: "",
41
}
42
EOF
43
44
atf_check \
45
-o match:".*Installing.*\.\.\.$" \
46
-e empty \
47
-s exit:0 \
48
pkg register -M test.ucl
49
50
atf_check \
51
-o match:".*Deinstalling.*" \
52
-e empty \
53
-s exit:0 \
54
pkg delete -y test
55
56
test -f file1 && atf_fail "'file1' still present"
57
test -f dir/file2 && atf_fail "'dir/file2' still present"
58
test -d dir && atf_fail "'dir' still present"
59
test -d ${TMPDIR} || atf_fail "Prefix have been removed"
60
}
61
62
simple_delete_prefix_ending_with_slash_body() {
63
touch file1
64
mkdir dir
65
touch dir/file2
66
67
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}/"
68
cat << EOF >> test.ucl
69
files: {
70
${TMPDIR}/file1: "",
71
${TMPDIR}/dir/file2: "",
72
}
73
EOF
74
75
atf_check \
76
-o match:".*Installing.*\.\.\.$" \
77
-e empty \
78
-s exit:0 \
79
pkg register -M test.ucl
80
81
atf_check \
82
-o match:".*Deinstalling.*" \
83
-e empty \
84
-s exit:0 \
85
pkg delete -y test
86
87
test -f file1 && atf_fail "'file1' still present"
88
test -f dir/file2 && atf_fail "'dir/file2' still present"
89
test -d dir && atf_fail "'dir' still present"
90
test -d ${TMPDIR} || atf_fail "Prefix have been removed"
91
}
92
93
delete_with_directory_owned_body() {
94
touch file1
95
mkdir dir
96
touch dir/file2
97
98
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}/"
99
cat << EOF >> test.ucl
100
files: {
101
${TMPDIR}/file1: "",
102
${TMPDIR}/dir/file2: "",
103
}
104
EOF
105
106
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test2" "test2" "1" "${TMPDIR}/"
107
cat << EOF >> test2.ucl
108
directories: {
109
${TMPDIR}/dir: 'y',
110
}
111
EOF
112
atf_check \
113
-o match:".*Installing.*\.\.\.$" \
114
-e empty \
115
-s exit:0 \
116
pkg register -M test.ucl
117
118
atf_check \
119
-o match:".*Installing.*\.\.\.$" \
120
-e empty \
121
-s exit:0 \
122
pkg register -M test2.ucl
123
124
atf_check \
125
-o match:".*Deinstalling.*" \
126
-e empty \
127
-s exit:0 \
128
pkg delete -y test
129
130
test -f file1 && atf_fail "'file1' still present"
131
test -f dir/file2 && atf_fail "'dir/file2' still present"
132
test -d dir || atf_fail "'dir' has been removed"
133
134
atf_check \
135
-o match:".*Deinstalling.*" \
136
-e empty \
137
-s exit:0 \
138
pkg delete -y test2
139
140
test -d dir && atf_fail "'dir' still present"
141
test -d ${TMPDIR} || atf_fail "Prefix has been removed"
142
}
143
144