summaryrefslogtreecommitdiffstats
path: root/test/integration/test-frontend-lock
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:00:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:00:48 +0000
commit851b6a097165af4d51c0db01b5e05256e5006896 (patch)
tree5f7c388ec894a7806c49a99f3bdb605d0b299a7c /test/integration/test-frontend-lock
parentInitial commit. (diff)
downloadapt-851b6a097165af4d51c0db01b5e05256e5006896.tar.xz
apt-851b6a097165af4d51c0db01b5e05256e5006896.zip
Adding upstream version 2.6.1.upstream/2.6.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/test-frontend-lock')
-rwxr-xr-xtest/integration/test-frontend-lock80
1 files changed, 80 insertions, 0 deletions
diff --git a/test/integration/test-frontend-lock b/test/integration/test-frontend-lock
new file mode 100755
index 0000000..939344a
--- /dev/null
+++ b/test/integration/test-frontend-lock
@@ -0,0 +1,80 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+setupenvironment
+configarchitecture 'i386'
+
+insertinstalledpackage 'package1' 'i386' '1.0'
+insertinstalledpackage 'package2' 'i386' '1.0'
+insertinstalledpackage 'package3' 'i386' '1.0'
+insertinstalledpackage 'package4' 'i386' '1.0'
+insertinstalledpackage 'package5' 'i386' '1.0'
+insertinstalledpackage 'package6' 'i386' '1.0'
+buildsimplenativepackage 'foo' 'all' '1'
+
+setupaptarchive
+
+buildsimplenativepackage 'bar' 'all' '1'
+
+
+# Checks that the correct variable is set
+msgmsg 'Post-Invoke script has DPKG_FRONTEND_LOCKED set'
+testsuccess aptget -q -y -o Dpkg::Post-Invoke::="echo DPKG_FRONTEND_LOCKED=\$DPKG_FRONTEND_LOCKED" remove package1
+cp rootdir/tmp/testsuccess.output install.output
+testsuccess grep DPKG_FRONTEND_LOCKED=true install.output
+
+msgmsg 'Pre-Invoke script has DPKG_FRONTEND_LOCKED set'
+testsuccess aptget -q -y -o Dpkg::Pre-Invoke::="echo DPKG_FRONTEND_LOCKED=\$DPKG_FRONTEND_LOCKED" remove package2
+cp rootdir/tmp/testsuccess.output install.output
+testsuccess grep DPKG_FRONTEND_LOCKED=true install.output
+
+msgmsg 'Pre-Install-Pkgs script has DPKG_FRONTEND_LOCKED set'
+testsuccess aptget -q -y -o DPkg::Pre-Install-Pkgs::="echo DPKG_FRONTEND_LOCKED=\$DPKG_FRONTEND_LOCKED" remove package3
+cp rootdir/tmp/testsuccess.output install.output
+testsuccess grep DPKG_FRONTEND_LOCKED=true install.output
+
+
+# Check that the frontend lock is hold by apt-get
+msgmsg 'Post-Invoke script runs while frontend is locked'
+testfailure aptget -q -y -o Dpkg::Post-Invoke::="apt-get remove" remove package4
+cp rootdir/tmp/testfailure.output install.output
+testsuccess grep "E: Unable to acquire the dpkg frontend lock (${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/lock-frontend), is another process using it?" install.output
+testsuccess grep "E: Problem executing scripts DPkg::Post-Invoke 'apt-get remove'" install.output
+
+msgmsg 'Pre-Invoke script runs while frontend is locked'
+testfailure aptget -q -y -o Dpkg::Pre-Invoke::="apt-get remove" remove package5
+cp rootdir/tmp/testfailure.output install.output
+testsuccess grep "E: Unable to acquire the dpkg frontend lock (${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/lock-frontend), is another process using it?" install.output
+testsuccess grep "E: Problem executing scripts DPkg::Pre-Invoke 'apt-get remove'" install.output
+
+msgmsg 'Pre-Install-Pkgs runs while frontend is locked'
+testfailure aptget -q -y -o DPkg::Pre-Install-Pkgs::="apt-get remove" remove package6
+cp rootdir/tmp/testfailure.output install.output
+testsuccess grep "E: Unable to acquire the dpkg frontend lock (${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/lock-frontend), is another process using it?" install.output
+testsuccess grep "E: Sub-process apt-get remove returned an error code (100)" install.output
+testsuccess grep "Failure running script apt-get remove" install.output
+
+
+# Applied test case from DonKult
+msgmsg 'Applied case of frontend locking'
+cat > ./post-invoke <<EOF
+#!/bin/sh
+set -e
+#export DPKG_FRONTEND_LOCKED=true
+${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg -i ${TMPWORKINGDIRECTORY}/incoming/bar_1_all.deb
+EOF
+chmod +x ./post-invoke
+echo "dpkg::post-invoke:: \"${TMPWORKINGDIRECTORY}/post-invoke\";" > rootdir/etc/apt/apt.conf.d/01dpkgpostinvoke
+
+testdpkgnotinstalled 'foo' 'bar'
+testsuccess apt show foo
+testfailure apt show bar
+
+testsuccess apt install foo -s
+testdpkgnotinstalled 'foo' 'bar'
+
+testsuccess apt install foo
+testdpkginstalled 'foo' 'bar'