]>
Commit | Line | Data |
---|---|---|
da3ebfe7 MV |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
549b4939 MV |
4 | ensure_n_canary_strings_in_dir() { |
5 | DIR=$1 | |
6 | CANARY_STRING=$2 | |
7 | EXPECTED_N=$3 | |
8 | ||
721b05b8 | 9 | msgtest "Testing for $EXPECTED_N canary strings '$CANARY_STRING' in in" "$DIR" |
549b4939 MV |
10 | |
11 | N=$(grep "$CANARY_STRING" $DIR/* 2>/dev/null |wc -l ) | |
12 | if [ "$N" = "$EXPECTED_N" ]; then | |
13 | msgpass | |
14 | return 0 | |
15 | else | |
16 | msgfail "Expected $EXPECTED_N canaries, got $N" | |
17 | return 1 | |
18 | fi | |
19 | } | |
20 | ||
da3ebfe7 MV |
21 | TESTDIR=$(readlink -f $(dirname $0)) |
22 | . $TESTDIR/framework | |
23 | ||
24 | setupenvironment | |
721b05b8 | 25 | configarchitecture 'native' |
da3ebfe7 | 26 | |
721b05b8 | 27 | insertpackage 'unstable' 'unrelated' 'all' '1.0' 'stable' |
da3ebfe7 MV |
28 | |
29 | setupaptarchive | |
3ce22d4f | 30 | changetowebserver --simulate-paywall |
da3ebfe7 MV |
31 | |
32 | rm -rf rootdir/var/lib/apt/lists | |
721b05b8 DK |
33 | msgtest 'excpected failure of' 'apt-get update' |
34 | aptget update -qq 2>/dev/null && msgfail || msgpass | |
35 | ||
36 | ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ 'ni ni ni' 0 | |
549b4939 | 37 | testequal 'partial' ls rootdir/var/lib/apt/lists/ |
da3ebfe7 | 38 | |
549b4939 | 39 | # again, this time with pre-existing files valid data |
721b05b8 | 40 | for f in Release Release.gpg main_binary-amd64_Packages stable_main_source_Sources; do |
549b4939 MV |
41 | echo "canary" > rootdir/var/lib/apt/lists/localhost:8080_dists_stable_${f} |
42 | done | |
da3ebfe7 | 43 | |
721b05b8 DK |
44 | # this will fail, the important part is that the canaries remain |
45 | msgtest 'excpected failure of' 'apt-get update' | |
46 | aptget update -qq 2>/dev/null && msgfail || msgpass | |
47 | ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ 'canary' 4 |