diff options
| author | Julian Andres Klode <jak@debian.org> | 2025-03-04 20:57:41 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2025-03-04 20:57:41 +0000 |
| commit | b63127f956c7768c75e4b10f8f3ccecd6058066f (patch) | |
| tree | 59b3b21ce283f7b4131df76f33e7b49eb12f5af1 | |
| parent | 8dcfb1237aa16247fbe038b818d875a92a1d3c1a (diff) | |
| parent | 1b959f0129460f2267e66bc77ca9464c28c915c5 (diff) | |
Merge branch 'test-suite-grep-error-details' into 'main'
test: Grep continuation lines in error messages
See merge request apt-team/apt!456
| -rw-r--r-- | test/integration/framework | 17 | ||||
| -rwxr-xr-x | test/integration/test-apt-update-expected-size | 12 |
2 files changed, 27 insertions, 2 deletions
diff --git a/test/integration/framework b/test/integration/framework index 35c1a1032..d2570b6b2 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -2068,6 +2068,19 @@ testfailureequal() { testreturnstateequal 'testfailure' "$@" } +grepmsg() { + awk '{ + if (/^[WEN]:/) + msg=1; + else if (/^ / && msg) + msg=1; + else + msg=0; + if (msg) + print + }' +} + testfailuremsg() { msggroup 'testfailuremsg' local CMP="$1" @@ -2075,7 +2088,7 @@ testfailuremsg() { testfailure "$@" msgtest 'Check that the output of the previous failed command has expected' 'failures and warnings' local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailuremsg.comparefile" - grep '^\(W\|E\|N\):' "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" > "$COMPAREFILE" 2>&1 || true + grepmsg < "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" > "$COMPAREFILE" 2>&1 || true testoutputequal "$COMPAREFILE" echo "$CMP" msggroup } @@ -2086,7 +2099,7 @@ testwarningmsg() { testwarning "$@" msgtest 'Check that the output of the previous warned command has expected' 'warnings' local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarningmsg.comparefile" - grep '^\(W\|E\|N\):' "${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output" > "$COMPAREFILE" 2>&1 || true + grepmsg < "${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output" > "$COMPAREFILE" 2>&1 || true testoutputequal "$COMPAREFILE" echo "$CMP" msggroup } diff --git a/test/integration/test-apt-update-expected-size b/test/integration/test-apt-update-expected-size index 32fa03973..0fd2f9258 100755 --- a/test/integration/test-apt-update-expected-size +++ b/test/integration/test-apt-update-expected-size @@ -34,12 +34,18 @@ test_packagestoobig() { signreleasefiles # append junk at the end of the Packages.gz/Packages SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)" + SHA256="$(sha256sum aptarchive/dists/unstable/main/binary-i386/Packages.gz | awk '{print $1}')" + DATE="$(grep ^Date aptarchive/dists/unstable/Release | cut -f2- -d' ')" find aptarchive/dists -name 'Packages*' | while read pkg; do echo "1234567890" >> "$pkg" touch -d '+1hour' "$pkg" done NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)" testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages.gz File has unexpected size ($NEW_SIZE != $SIZE). Mirror sync in progress? + Hashes of expected file: + - Filesize:$SIZE [weak] + - SHA256:$SHA256 + Release file created at: $DATE E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0 testsuccess ls rootdir/var/lib/apt/lists/partial/*Packages*.FAILED testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED @@ -51,12 +57,18 @@ test_packagestoosmall() { signreleasefiles # replace Packages.gz/Packages with short junk SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)" + SHA256="$(sha256sum aptarchive/dists/unstable/main/binary-i386/Packages.gz | awk '{print $1}')" + DATE="$(grep ^Date aptarchive/dists/unstable/Release | cut -f2- -d' ')" find aptarchive/dists -name 'Packages*' | while read pkg; do echo "1234567890" > "$pkg" touch -d '+1hour' "$pkg" done NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)" testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages.gz File is smaller than expected ($NEW_SIZE < $SIZE). Mirror sync in progress? + Hashes of expected file: + - Filesize:$SIZE [weak] + - SHA256:$SHA256 + Release file created at: $DATE E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0 testsuccess ls rootdir/var/lib/apt/lists/partial/*Packages*.FAILED testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED |
