From 8d8b45a96ceceb015f7836cf25b99279c2f377b9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 21 Apr 2022 01:45:45 +0200 Subject: Link interactive helpers against system libapt for autopkgtest Building the library just so we can build the helpers against it is not only wasteful but as we are supposed to test the system we can use that as an additional simple smoke test before the real testing starts. --- test/integration/create-test-data | 2 - test/integration/framework | 51 ++++++++++------------ test/integration/test-apt-helper-cat-file | 2 +- .../test-no-fds-leaked-to-maintainer-scripts | 6 +-- 4 files changed, 28 insertions(+), 33 deletions(-) (limited to 'test/integration') diff --git a/test/integration/create-test-data b/test/integration/create-test-data index eff2ba530..0eca3998c 100755 --- a/test/integration/create-test-data +++ b/test/integration/create-test-data @@ -9,8 +9,6 @@ fi CHECK_ARGS='no' TESTDIR="$(readlink -f "$(dirname "$0")")" . "$TESTDIR/framework" -find_project_binary_dir -BUILDDIRECTORY="${APT_INTEGRATION_TESTS_BUILD_DIR:-"${PROJECT_BINARY_DIR}/cmdline"}" GENERATE="$1" CODENAME="$2" diff --git a/test/integration/framework b/test/integration/framework index c9559a7ba..8bb8c00d6 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -175,7 +175,7 @@ runapt() { shift case "$CMD" in sh|aptitude|*/*|command) ;; - *) CMD="${BUILDDIRECTORY}/$CMD";; + *) CMD="${APTCMDLINEBINDIR}/$CMD";; esac if [ "$CMD" = 'aptitude' ]; then MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG="$(getaptconfig)" LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}" command "$CMD" "$@" @@ -228,7 +228,7 @@ gdb() { esac shift if [ "${CMD##*/}" = "$CMD" ]; then - CMD="${BUILDDIRECTORY}/${CMD}" + CMD="${APTCMDLINEBINDIR}/${CMD}" fi runapt command gdb --quiet -ex "directory '$SOURCEDIRECTORY'" -ex run "$CMD" --args "$CMD" "$@" } @@ -248,7 +248,7 @@ valgrind() { esac shift if [ "${CMD##*/}" = "$CMD" ]; then - CMD="${BUILDDIRECTORY}/${CMD}" + CMD="${APTCMDLINEBINDIR}/${CMD}" fi runapt command valgrind "$CMD" "$@" } @@ -373,9 +373,6 @@ setupenvironment() { fi mkdir -p 'rootdir/usr/bin' 'rootdir/var/cache' 'rootdir/var/lib' 'rootdir/var/log' 'rootdir/var/crash' 'rootdir/tmp' - # Find the newest build directory (sets PROJECT_BINARY_DIR) - find_project_binary_dir - _setupprojectenvironment # create some files in /tmp and look at user/group to get what this means @@ -383,9 +380,6 @@ setupenvironment() { touch "${TMPWORKINGDIRECTORY}/test-file" TEST_DEFAULT_GROUP=$(stat --format '%G' "${TMPWORKINGDIRECTORY}/test-file") - # prefer our apt binaries over the system apt binaries - export PATH="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin" - if [ -r "${TESTDIRECTORY}/extra-environment" ]; then . "${TESTDIRECTORY}/extra-environment" fi @@ -393,19 +387,20 @@ setupenvironment() { msgdone "info" } _setupprojectenvironment() { - # allow overriding the default BUILDDIR location + # allow overriding the default BUILDDIR locations SOURCEDIRECTORY="${APT_INTEGRATION_TESTS_SOURCE_DIR:-"${TESTDIRECTORY}/../../"}" - BUILDDIRECTORY="${APT_INTEGRATION_TESTS_BUILD_DIR:-"${PROJECT_BINARY_DIR}/cmdline"}" - LIBRARYPATH="${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}/../apt-pkg"}" - METHODSDIR="${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/../methods"}" - APTHELPERBINDIR="${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}" - APTTESTHELPERSBINDIR="${APT_INTEGRATION_TESTS_HELPERS_BIN_DIR:-"${BUILDDIRECTORY}/../test/interactive-helper"}" - APTFTPARCHIVEBINDIR="${APT_INTEGRATION_TESTS_FTPARCHIVE_BIN_DIR:-"${BUILDDIRECTORY}/../ftparchive"}" - APTINTERNALSOLVER="${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/solvers/apt"}" - APTDUMPSOLVER="${APT_INTEGRATION_TESTS_DUMP_SOLVER:-"${BUILDDIRECTORY}/solvers/dump"}" - APTINTERNALPLANNER="${APT_INTEGRATION_TESTS_INTERNAL_PLANNER:-"${BUILDDIRECTORY}/planners/apt"}" + BUILDDIRECTORY="${APT_INTEGRATION_TESTS_BUILD_DIR:-"$(find_project_binary_dir; printf '%s' "$PROJECT_BINARY_DIR")"}" + LIBRARYPATH="${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}/apt-pkg"}" + METHODSDIR="${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}" + APTHELPERBINDIR="${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}/cmdline"}" + APTTESTHELPERSBINDIR="${APT_INTEGRATION_TESTS_HELPERS_BIN_DIR:-"${BUILDDIRECTORY}/test/interactive-helper"}" + APTFTPARCHIVEBINDIR="${APT_INTEGRATION_TESTS_FTPARCHIVE_BIN_DIR:-"${BUILDDIRECTORY}/ftparchive"}" + APTCMDLINEBINDIR="${APT_INTEGRATION_TESTS_CMDLINE_BIN_DIR:-"${BUILDDIRECTORY}/cmdline"}" + APTINTERNALSOLVER="${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${APTCMDLINEBINDIR}/solvers/apt"}" + APTDUMPSOLVER="${APT_INTEGRATION_TESTS_DUMP_SOLVER:-"${APTCMDLINEBINDIR}/solvers/dump"}" + APTINTERNALPLANNER="${APT_INTEGRATION_TESTS_INTERNAL_PLANNER:-"${APTCMDLINEBINDIR}/planners/apt"}" ARTIFACTSDIR="${APT_INTEGRATION_TESTS_ARTIFACTS_DIR:-"${BUILDDIRECTORY}/artifacts"}" - test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first" + test -x "${APTCMDLINEBINDIR}/apt-get" || msgdie 'You need to build tree first' echo "#x-apt-configure-index \"${SOURCEDIRECTORY}/doc/examples/configure-index\";" > aptconfig.conf mkdir aptarchive keys @@ -422,8 +417,7 @@ _setupprojectenvironment() { ln -s "${APTINTERNALPLANNER}" usr/lib/apt/planners/apt echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" >> ../aptconfig.conf echo "Dir::Bin::Planners \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/planners\";" >> ../aptconfig.conf - # use the autoremove from the BUILDDIRECTORY if its there, otherwise - # system + # use the autoremove from the BUILDDIRECTORY if its there, otherwise system if [ -z "${APT_INTEGRATION_TESTS_SOURCE_DIR}" ]; then ln -s "${SOURCEDIRECTORY}/debian/apt.conf.autoremove" etc/apt/apt.conf.d/01autoremove else @@ -452,11 +446,11 @@ _setupprojectenvironment() { echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf echo "Dir::Bin::Methods \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods\";" >> aptconfig.conf # either store apt-key were we can access it, even if we run it as a different user - #cp "${BUILDDIRECTORY}/apt-key" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/" + #cp "${APTCMDLINEBINDIR}/apt-key" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/" #chmod o+rx "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key" #echo "Dir::Bin::apt-key \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key\";" >> aptconfig.conf # destroys coverage reporting though, so we disable changing user for the calling gpgv - echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf + echo "Dir::Bin::apt-key \"${APTCMDLINEBINDIR}/apt-key\";" >> aptconfig.conf if [ "$(id -u)" = '0' ]; then echo 'Binary::gpgv::APT::Sandbox::User "root";' >> aptconfig.conf # same for the solver executables @@ -542,6 +536,9 @@ EOF # most tests just need one signed Release file, not both export APT_DONT_SIGN='Release.gpg' + + # prefer our apt binaries over the system apt binaries + export PATH="${APTCMDLINEBINDIR}:${PATH}:/usr/sbin:/sbin" } getarchitecture() { @@ -1831,12 +1828,12 @@ msgfailoutput() { if [ -s "$COREDUMP" ]; then if [ -z "$COREEXE" ]; then case "$CMD" in - apt) COREEXE="${BUILDDIRECTORY}/${CMD}";; + apt) COREEXE="${APTCMDLINEBINDIR}/${CMD}";; aptftparchive) COREEXE="${APTFTPARCHIVEBINDIR}/apt-ftparchive";; apthelper) COREEXE="${APTHELPERBINDIR}/apt-helper";; aptwebserver) COREEXE="${APTTESTHELPERSBINDIR}/aptwebserver";; - apt*) COREEXE="${BUILDDIRECTORY}/apt-${CMD##*apt}";; - *) COREEXE="${BUILDDIRECTORY}/${CMD}";; + apt*) COREEXE="${APTCMDLINEBINDIR}/apt-${CMD##*apt}";; + *) COREEXE="${APTCMDLINEBINDIR}/${CMD}";; esac fi diff --git a/test/integration/test-apt-helper-cat-file b/test/integration/test-apt-helper-cat-file index a53a6b4a3..064760c9e 100755 --- a/test/integration/test-apt-helper-cat-file +++ b/test/integration/test-apt-helper-cat-file @@ -5,7 +5,7 @@ TESTDIR="$(readlink -f "$(dirname "$0")")" . "$TESTDIR/framework" setupenvironment -TESTTOOL="${BUILDDIRECTORY}/../test/interactive-helper/test_fileutl" +TESTTOOL="${APTTESTHELPERSBINDIR}/test_fileutl" msgtest 'Check if we have build the test tool' "$TESTTOOL" if [ -x "$TESTTOOL" ]; then msgpass diff --git a/test/integration/test-no-fds-leaked-to-maintainer-scripts b/test/integration/test-no-fds-leaked-to-maintainer-scripts index 4606408fc..2b165520e 100755 --- a/test/integration/test-no-fds-leaked-to-maintainer-scripts +++ b/test/integration/test-no-fds-leaked-to-maintainer-scripts @@ -159,11 +159,11 @@ else fi rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log -testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt-get" install -y fdleaks -qq < /dev/null +testsuccess runapt command setsid -w "${APTCMDLINEBINDIR}/apt-get" install -y fdleaks -qq < /dev/null checkinstall rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log -testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt-get" purge -y fdleaks -qq +testsuccess runapt command setsid -w "${APTCMDLINEBINDIR}/apt-get" purge -y fdleaks -qq checkpurge touch rootdir/tmp/read_stdin @@ -174,6 +174,6 @@ checkinstall testequal '2' grep -c '^STDIN: ' rootdir/var/log/apt/term.log rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log -yes '' | testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt-get" purge -y fdleaks -qq +yes '' | testsuccess runapt command setsid -w "${APTCMDLINEBINDIR}/apt-get" purge -y fdleaks -qq checkpurge testequal '3' grep -c '^STDIN: ' rootdir/var/log/apt/term.log -- cgit v1.2.3-70-g09d2 From e5aa5c04ecbd3cdab611794cebf9eb3aa8cbddd4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 21 Apr 2022 12:51:20 +0200 Subject: Ignore stty failures in testcases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We use 'stty sane' to combat against stepped output and co caused by (especially) failed tests, but it does so many things that it occasionally fails to reset some bits in the parallel interaction we have with it which fails the tests without a real problem in apt… Ideally we would be better at stitching the output together, but for the time being lets ignore these failures instead to stabilize the tests. --- test/integration/run-tests | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/integration') diff --git a/test/integration/run-tests b/test/integration/run-tests index f5a39f244..c1cc780f0 100755 --- a/test/integration/run-tests +++ b/test/integration/run-tests @@ -80,9 +80,9 @@ if [ -n "$TESTTORUN" ]; then fi } >"$OUTPUT" 2>&1 # without we end up getting stepped output 'randomly' - stty sane + stty sane || true cat >&2 "$OUTPUT" - stty sane + stty sane || true if [ "$FAIL" = 'yes' ]; then exit 1 else -- cgit v1.2.3-70-g09d2