]> git.saurik.com Git - apt.git/blobdiff - test/integration/test-apt-get-clean
Allow lowering trust level of a hash via config
[apt.git] / test / integration / test-apt-get-clean
index 00f9d4e60cae7bc7026df1a84d9bc968e3dfda2f..6bf20c8d7bafcb7ded0b0572f7acc4a59c4bd667 100755 (executable)
@@ -1,8 +1,8 @@
 #!/bin/sh
 set -e
 
-TESTDIR=$(readlink -f $(dirname $0))
-. $TESTDIR/framework
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
 
 setupenvironment
 configarchitecture 'amd64'
@@ -36,4 +36,36 @@ 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'