From 76e2632459410dec81337edb6a9fee33c9a660f3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 11:59:37 +0200 Subject: Adding upstream version 2.7.12. Signed-off-by: Daniel Baumann --- test/integration/test-apt-extracttemplates | 78 ++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 test/integration/test-apt-extracttemplates (limited to 'test/integration/test-apt-extracttemplates') diff --git a/test/integration/test-apt-extracttemplates b/test/integration/test-apt-extracttemplates new file mode 100755 index 0000000..a47257c --- /dev/null +++ b/test/integration/test-apt-extracttemplates @@ -0,0 +1,78 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" + +setupenvironment +configarchitecture 'amd64' + +# apt-extracttemplates needs this +insertinstalledpackage 'pkg-with-template' 'amd64' '1.0' + +# build a simple package that contains a config and a template +mkdir -p DEBIAN +CONFIG_STR="#!/bin/sh +random shell stuff +" +echo "$CONFIG_STR" > DEBIAN/config +chmod 755 DEBIAN/config + +testrun() { + local TEMPLATE_STR='Template: foo/bar +Type: string +Description: Some bar var +' + echo "$TEMPLATE_STR" > DEBIAN/templates + buildsimplenativepackage "$1" 'amd64' '0.8.15' 'stable' "$2" 'pkg with template' '' '' './DEBIAN' + + cp dpkg.status rootdir/var/lib/dpkg/status + insertinstalledpackage 'debconf' 'amd64' '3' + + # ensure we get the right stuff out of the file + rm -rf extracttemplates-out rootdir/var/cache/apt + mkdir extracttemplates-out + testsuccess aptextracttemplates -t ./extracttemplates-out incoming/${1}*.deb + OUT='rootdir/tmp/testsuccess.output' + testequal "$1" cut -f1 -d' ' $OUT + if [ -n "$2" ]; then + testequal '' cut -s -f2 -d' ' $OUT + else + testequal '1.0' cut -f2 -d' ' $OUT + fi + TEMPLATE=$(cut -f3 -d' ' $OUT) + testfileequal "$TEMPLATE" "$TEMPLATE_STR" + CONFIG=$(cut -f4 -d' ' $OUT) + testfileequal "$CONFIG" "$CONFIG_STR" + msgtest 'No extra files or directories in extraction directory' + if [ "$(find ./extracttemplates-out | wc -l)" = '3' ]; then + msgpass + else + msgfail + ls -l ./extracttemplates-out + fi + + # ensure that the format of the output string has the right number of dots + for s in "$CONFIG" "$TEMPLATE"; do + NR_DOTS=$(basename "$s" | tr -c -d '.') + testequal '..' echo $NR_DOTS + done + + if [ -n "$2" ]; then + rm -rf extracttemplates-out rootdir/var/cache/apt + mkdir extracttemplates-out + cp dpkg.status rootdir/var/lib/dpkg/status + insertinstalledpackage 'debconf' 'amd64' '1' + testempty aptextracttemplates -t ./extracttemplates-out incoming/${1}*.deb + fi +} + +cp rootdir/var/lib/dpkg/status dpkg.status +testrun 'pkg-with-template' '' +testrun 'pkg-with-template-depends' 'Depends: debconf (>= 2)' +testrun 'pkg-with-template-predepends' 'Pre-Depends: debconf (>= 2)' + +# test with no debconf installed +cp dpkg.status rootdir/var/lib/dpkg/status +testfailure aptextracttemplates -t ./extracttemplates-out incoming/pkg-with-template-depends*.deb +testfileequal 'rootdir/tmp/testfailure.output' 'E: Cannot get debconf version. Is debconf installed?' -- cgit v1.2.3