From de81b2e20f80bb5f42034863a9a974c815a45da5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 18 Oct 2014 17:48:55 +0200 Subject: aborted reverify restores file owner and permission If we get an IMS hit for an InRelease file we use the file we already have and pass it into reverification, but this changes the permissions and on abort of the transaction they weren't switched back. This is now done, additionally, every file in partial which hasn't failed gets permission and owner changed for root access as well, as it is very well possible that the next invocation will (re)use these files. --- test/integration/framework | 54 +++++++++++++--------- test/integration/test-apt-update-transactions | 65 +++++++++++++++++++++++---- 2 files changed, 89 insertions(+), 30 deletions(-) (limited to 'test/integration') diff --git a/test/integration/framework b/test/integration/framework index a8d6bf3d0..d692f62a9 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -23,25 +23,32 @@ if [ "$MSGCOLOR" != 'NO' ]; then CCMD="\033[1;35m" # pink fi -msgdie() { printf "${CERROR}E: $1${CNORMAL}\n" >&2; exit 1; } -msgwarn() { printf "${CWARNING}W: $1${CNORMAL}\n" >&2; } -msgmsg() { printf "${CMSG}$1${CNORMAL}\n"; } -msginfo() { printf "${CINFO}I: $1${CNORMAL}\n"; } -msgdebug() { printf "${CDEBUG}D: $1${CNORMAL}\n"; } -msgdone() { printf "${CDONE}DONE${CNORMAL}\n"; } -msgnwarn() { printf "${CWARNING}W: $1${CNORMAL}" >&2; } -msgnmsg() { printf "${CMSG}$1${CNORMAL}"; } -msgninfo() { printf "${CINFO}I: $1${CNORMAL}"; } -msgndebug() { printf "${CDEBUG}D: $1${CNORMAL}"; } -msgtest() { - while [ -n "$1" ]; do - printf "${CINFO}$1${CCMD} " - printf -- "$(echo "$2" | sed -e 's#^apt\([cgfs]\)#apt-\1#')${CINFO} " +msgprintf() { + local START="$1" + local MIDDLE="$2" + local END="$3" + shift 3 + if [ -n "$1" ]; then + printf "$START " "$1" shift - if [ -n "$1" ]; then shift; else break; fi - done - printf "…${CNORMAL} " + while [ -n "$1" ]; do + printf "$MIDDLE " "$(echo "$1" | sed -e 's#^apt\([cgfs]\)#apt-\1#')" + shift + done + fi + printf "${END}" } +msgdie() { msgprintf "${CERROR}E: %s" '%s' "${CNORMAL}\n" "$@" >&2; exit 1; } +msgwarn() { msgprintf "${CWARNING}W: %s" '%s' "${CNORMAL}\n" "$@" >&2; } +msgmsg() { msgprintf "${CMSG}%s" '%s' "${CNORMAL}\n" "$@"; } +msginfo() { msgprintf "${CINFO}I: %s" '%s' "${CNORMAL}\n" "$@"; } +msgdebug() { msgprintf "${CDEBUG}D: %s" '%s' "${CNORMAL}\n" "$@"; } +msgdone() { msgprintf "${CDONE}DONE" '%s' "${CNORMAL}\n" "$@"; } +msgnwarn() { msgprintf "${CWARNING}W: %s" '%s' "${CNORMAL}" "$@" >&2; } +msgnmsg() { msgprintf "${CMSG}%s" '%s' "${CNORMAL}" "$@"; } +msgninfo() { msgprintf "${CINFO}I: %s" '%s' "${CNORMAL}" "$@"; } +msgndebug() { msgprintf "${CDEBUG}D: %s" '%s' "${CNORMAL}" "$@"; } +msgtest() { msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@"; } msgpass() { printf "${CPASS}PASS${CNORMAL}\n"; } msgskip() { if [ $# -gt 0 ]; then printf "${CWARNING}SKIP: $*${CNORMAL}\n" >&2; @@ -1222,18 +1229,21 @@ testfailure() { fi } -testaccessrights() { - msgtest "Test that file $1 has access rights set to" "$2" - if [ "$2" = "$(stat --format '%a' "$1")" ]; then +testfilestats() { + msgtest "Test that file $1 has $2 $3" "$4" + if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then msgpass else echo >&2 ls -l >&2 "$1" - echo -n >&2 "stat(1) reports access rights: " - stat --format '%a' "$1" + echo -n >&2 "stat(1) reports for $2: " + stat --format "$2" "$1" msgfail fi } +testaccessrights() { + testfilestats "$1" '%a' '=' "$2" +} testwebserverlaststatuscode() { local DOWNLOG='rootdir/tmp/webserverstatus-testfile.log' diff --git a/test/integration/test-apt-update-transactions b/test/integration/test-apt-update-transactions index 247334991..2d5d9e721 100755 --- a/test/integration/test-apt-update-transactions +++ b/test/integration/test-apt-update-transactions @@ -1,24 +1,73 @@ #!/bin/sh set -e +# ensure that an update will only succeed entirely or not at all + TESTDIR=$(readlink -f $(dirname $0)) . $TESTDIR/framework setupenvironment -configarchitecture "i386" +configarchitecture 'i386' insertpackage 'unstable' 'foo' 'all' '1.0' +insertsource 'unstable' 'foo' 'all' '1.0' setupaptarchive --no-update -changetowebserver -# break package file -cat > aptarchive/dists/unstable/main/binary-i386/Packages < "$1" < listsdir.lst + testrun 'listsdir.lst' + + msgmsg 'Test with initial data over' "$1" + testsuccess aptget update + ls rootdir/var/lib/apt/lists > listsdir.lst + testrun 'listsdir.lst' +} + +testsetup 'file' +changetowebserver +testsetup 'http' -- cgit v1.2.3