aboutsummaryrefslogtreecommitdiff
path: root/scripts/testing/maint-scenarios/20-cache-keep3.sh
blob: a9a6ee54912f93c7a0c3e8a64fcd39249413f7f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# shellcheck shell=bash disable=SC2034  # sourced by run-maint-scenarios.sh
# Scenario: paccache -rk3 trims an installed package's cache to 3 versions.
#
# paccache decides from filenames, so five fake versions of a package that
# IS installed (bash) stand in for a fat cache. The bootstrap may leave a
# real bash package in the cache too, so the assert uses the ordering
# invariant rather than a count: the two newest fakes survive any keep-3
# window that contains them, and the two oldest fall outside it whether or
# not a real (newer) version is cached alongside.
SCENARIO_DESC="pacman cache trimmed to three versions per package"
SCENARIO_GROUP="packages"
SCENARIO_PROFILES="any"

scenario_break() {
    mexec "for v in 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5; do touch /var/cache/pacman/pkg/bash-\$v-1-x86_64.pkg.tar.zst; done; ls /var/cache/pacman/pkg/ | grep -c '^bash-'"
}

scenario_fix() {
    mfix cache_clean
}

scenario_assert() {
    mexec "test -e /var/cache/pacman/pkg/bash-1.0.5-1-x86_64.pkg.tar.zst && test -e /var/cache/pacman/pkg/bash-1.0.4-1-x86_64.pkg.tar.zst && test ! -e /var/cache/pacman/pkg/bash-1.0.2-1-x86_64.pkg.tar.zst && test ! -e /var/cache/pacman/pkg/bash-1.0.1-1-x86_64.pkg.tar.zst"
}