From f392ba3602dc759eeeffd719d2eb16fc2d81f5e5 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 15 Oct 2024 15:22:26 +0200 Subject: test: Check that apt-ftparchive handles deep paths This checks for the previous boundaries for path sizes; but we also added a check for many files in a directory, limited to 4096. Sadly the directory check did not fail with the old code either, it's hard to actually get it to fail correctly. --- test/integration/test-apt-ftparchive-corner-cases | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 test/integration/test-apt-ftparchive-corner-cases diff --git a/test/integration/test-apt-ftparchive-corner-cases b/test/integration/test-apt-ftparchive-corner-cases new file mode 100755 index 000000000..9f56a52c8 --- /dev/null +++ b/test/integration/test-apt-ftparchive-corner-cases @@ -0,0 +1,49 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" + +setupenvironment +allowremovemanual +configarchitecture 'amd64' 'i386' + +createpkg() { + local PKG="pkg-$1" + mkdir -p ./incoming/$PKG/DEBIAN + if [ -n "$2" ]; then + echo -n "$2" >> ./incoming/$PKG/DEBIAN/control + fi + echo "Package: $PKG +Version: 0 +Priority: extra +Maintainer: No Body +Architecture: all +Depends: foo:i386 +Description: test package" >> ./incoming/$PKG/DEBIAN/control + if [ -n "$3" ]; then + echo -n "$3" >> ./incoming/$PKG/DEBIAN/control + fi + testsuccess dpkg-deb --build ./incoming/$PKG/ ./incoming + #dpkg-deb -I ./incoming/${PKG}_0_all.deb control +} + +msgmsg 'Test a deep tree' +msgtest 'Test for succesfull execution of' 'mkdir -p <1024 times x/>' +testsuccess --nomsg mkdir -p incoming/pkg-deep-tree/$(seq 1024 | sed s#.*#x# | tr '\n' '/') +msgtest 'Test for succesfull execution of' 'touch <1024 times x/>/y' +testsuccess --nomsg touch incoming/pkg-deep-tree/$(seq 1024 | sed s#.*#x# | tr '\n' '/')/y +createpkg deep-tree + +testsuccessequal "$(seq 1024 | sed s#.*#x# | tr '\n' '/')y pkg-deep-tree" valgrind aptftparchive contents ./incoming/pkg-deep-tree_0_all.deb + + +msgmsg 'Test many files in one directory' + +testsuccess mkdir -p incoming/pkg-many-files/usr/lib/many-files +testsuccess sh -c 'for i in $(seq -w 4096); do touch incoming/pkg-many-files/usr/lib/many-files/$i; done' +createpkg many-files + +# OMG, this formatting is annoying to implement +testsuccessequal "$(seq -w 4096 | xargs -IA printf "usr/lib/many-files/%s\t\t\t\t\t %s\n" "A" "pkg-many-files")" valgrind aptftparchive contents ./incoming/pkg-many-files_0_all.deb + -- cgit v1.2.3-70-g09d2