From 5ba048a475cfd728906875327ddceed4614a1c9d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 24 Dec 2017 10:31:29 +0100 Subject: do not remap current files if nullptrs in cache generation If the cache needs to grow to make room to insert volatile files like deb files into the cache we were remapping null-pointers making them non-null-pointers in the process causing trouble later on. Only the current Releasefile pointer can currently legally be a nullpointer as volatile files have no release file they belong to, but for safety the pointer to the current Packages file is equally guarded. The option APT::Cache-Start can be used to workaround this problem. Reported-By: Mattia Rizzolo on IRC --- test/integration/test-apt-cache-remapping | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 test/integration/test-apt-cache-remapping (limited to 'test') diff --git a/test/integration/test-apt-cache-remapping b/test/integration/test-apt-cache-remapping new file mode 100755 index 000000000..31a406c57 --- /dev/null +++ b/test/integration/test-apt-cache-remapping @@ -0,0 +1,47 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" + +setupenvironment +configarchitecture 'amd64' + +buildsimplenativepackage 'foo' 'amd64' '1' + +# the default is 1MB – too much for our simple tests +echo 'APT::Cache-Grow "1000";' > rootdir/etc/apt/apt.conf.d/limit-cachegrow.conf + +# experiment with cache remapping +rm -f rootdir/var/cache/apt/*.bin +testsuccess apt install ./incoming/foo_1_amd64.deb -s +msgtest 'Cache files are generated in tests' +if [ ! -e rootdir/var/cache/apt/srcpkgcache.bin -o ! -e rootdir/var/cache/apt/pkgcache.bin ]; then + msgfail 'files do not exist' + ls -l rootdir/var/cache/apt/*.bin + exit 1 +else + msgpass +fi + +SLSIZE="$(stat -c '%s' rootdir/var/cache/apt/srcpkgcache.bin)" +STSIZE="$(stat -c '%s' rootdir/var/cache/apt/pkgcache.bin)" +rm -f rootdir/var/cache/apt/*.bin +testfailure apt install ./incoming/foo_1_amd64.deb -s -o APT::Cache-Start="$SLSIZE" -o APT::Cache-Grow=0 +testfailure test -e rootdir/var/cache/apt/pkgcache.bin +rm -f rootdir/var/cache/apt/*.bin +testfailure apt install ./incoming/foo_1_amd64.deb -s -o APT::Cache-Start="$SLSIZE" -o APT::Cache-Limit="$SLSIZE" +testfailure test -e rootdir/var/cache/apt/pkgcache.bin +rm -f rootdir/var/cache/apt/*.bin +testsuccess apt install ./incoming/foo_1_amd64.deb -s -o APT::Cache-Start="$SLSIZE" +testsuccess test -e rootdir/var/cache/apt/srcpkgcache.bin -a -e rootdir/var/cache/apt/pkgcache.bin + +rm -f rootdir/var/cache/apt/*.bin +testfailure apt install ./incoming/foo_1_amd64.deb -s -o APT::Cache-Start="$STSIZE" -o APT::Cache-Grow=0 +rm -f rootdir/var/cache/apt/*.bin +testfailure apt install ./incoming/foo_1_amd64.deb -s -o APT::Cache-Start="$STSIZE" -o APT::Cache-Limit="$SLSIZE" +rm -f rootdir/var/cache/apt/*.bin +testfailure apt install ./incoming/foo_1_amd64.deb -s -o APT::Cache-Start="$STSIZE" -o APT::Cache-Limit="$STSIZE" +rm -f rootdir/var/cache/apt/*.bin +testsuccess apt install ./incoming/foo_1_amd64.deb -s -o APT::Cache-Start="$STSIZE" +testsuccess test -e rootdir/var/cache/apt/srcpkgcache.bin -a -e rootdir/var/cache/apt/pkgcache.bin -- cgit v1.2.3