summaryrefslogtreecommitdiffstats
path: root/test/integration/test-apt-get-clean
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 18:07:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 18:07:13 +0000
commit636c7dc17286d93d788c741d15fd756aeda066d5 (patch)
treee7ae158cc54f591041a061b9865bcae51854f15c /test/integration/test-apt-get-clean
parentInitial commit. (diff)
downloadapt-636c7dc17286d93d788c741d15fd756aeda066d5.tar.xz
apt-636c7dc17286d93d788c741d15fd756aeda066d5.zip
Adding upstream version 1.8.2.3.upstream/1.8.2.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/test-apt-get-clean')
-rwxr-xr-xtest/integration/test-apt-get-clean88
1 files changed, 88 insertions, 0 deletions
diff --git a/test/integration/test-apt-get-clean b/test/integration/test-apt-get-clean
new file mode 100755
index 0000000..d050732
--- /dev/null
+++ b/test/integration/test-apt-get-clean
@@ -0,0 +1,88 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+setupenvironment
+configarchitecture 'amd64'
+
+insertpackage 'testing' 'foo' 'all' '1'
+insertpackage 'unstable' 'foo' 'all' '2'
+insertpackage 'experimental' 'foo' 'all' '1:1'
+insertinstalledpackage 'foo' 'all' '3'
+
+setupaptarchive --no-update
+
+mkdir -p rootdir/var/lib/apt/lists/lost+found
+testsuccess apt update
+
+# nothing to do always works
+testsuccess aptget clean
+testsuccess aptget clean -s
+
+# generate some dirt and clean it up
+generatedirt() {
+ touch rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
+ mkdir -p rootdir/var/cache/apt/archives/lost+found
+ touch rootdir/var/cache/apt/archives/foo_1_all.deb
+ touch rootdir/var/cache/apt/archives/foo_1%3a1_all.deb
+ touch rootdir/var/cache/apt/archives/foo_2%3a1_all.deb
+ touch rootdir/var/cache/apt/archives/foo_2_all.deb
+ touch rootdir/var/cache/apt/archives/foo_3_all.deb
+ touch rootdir/var/cache/apt/archives/foo_4_all.deb
+}
+
+generatedirt
+testsuccess aptget autoclean
+testsuccess test -e rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
+testsuccess test -e rootdir/var/cache/apt/archives/foo_1_all.deb
+testsuccess test -e rootdir/var/cache/apt/archives/foo_1%3a1_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_2%3a1_all.deb
+testsuccess test -e rootdir/var/cache/apt/archives/foo_2_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_3_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_4_all.deb
+
+generatedirt
+testsuccess aptget clean
+testfailure test -e rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
+testfailure test -e rootdir/var/cache/apt/archives/foo_1_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_1%3a1_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_2%3a1_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_2_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_3_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_4_all.deb
+
+if [ "$(id -u)" != '0' ]; then
+ msgmsg 'No clean if lock can not be acquired'
+ touch rootdir/var/cache/apt/archives/foo_4_all.deb
+ touch rootdir/var/cache/apt/archives/lock
+ chmod 444 rootdir/var/cache/apt/archives/lock
+ testfailure apt clean
+ testsuccess test -e rootdir/var/cache/apt/archives/foo_4_all.deb
+ chmod 644 rootdir/var/cache/apt/archives/lock
+fi
+
+directorygone() {
+ rm -rf "$1"
+ testsuccess apt autoclean
+ testfailure test -d "$1"
+ testsuccess apt clean
+ # clean creates an empty partial directory via GetLock
+ if [ "$(basename "$1")" = 'partial' ]; then
+ testsuccess test -d "$1"
+ else
+ testfailure test -d "$1"
+ fi
+}
+msgmsg 'Partial directory missing'
+directorygone 'rootdir/var/cache/apt/archives/partial'
+directorygone 'rootdir/var/lib/apt/lists/partial'
+
+msgmsg 'Archives directory missing'
+directorygone 'rootdir/var/cache/apt/archives'
+directorygone 'rootdir/var/lib/apt/lists'
+
+msgmsg 'apt directory missing'
+directorygone 'rootdir/var/cache/apt'
+directorygone 'rootdir/var/lib/apt'