]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | set -e | |
3 | ||
4 | ensure_n_canary_strings_in_dir() { | |
5 | DIR=$1 | |
6 | CANARY_STRING=$2 | |
7 | EXPECTED_N=$3 | |
8 | ||
9 | msgtest "Testing for $EXPECTED_N canary strings '$CANARY_STRING' in in" "$DIR" | |
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 | ||
21 | TESTDIR=$(readlink -f $(dirname $0)) | |
22 | . $TESTDIR/framework | |
23 | ||
24 | setupenvironment | |
25 | configarchitecture 'native' | |
26 | ||
27 | insertpackage 'unstable' 'unrelated' 'all' '1.0' 'stable' | |
28 | ||
29 | setupaptarchive | |
30 | changetowebserver --simulate-paywall | |
31 | ||
32 | rm -rf rootdir/var/lib/apt/lists | |
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 | |
37 | testequal 'partial' ls rootdir/var/lib/apt/lists/ | |
38 | ||
39 | # again, this time with pre-existing files valid data | |
40 | for f in Release Release.gpg main_binary-amd64_Packages stable_main_source_Sources; do | |
41 | echo "canary" > rootdir/var/lib/apt/lists/localhost:8080_dists_stable_${f} | |
42 | done | |
43 | ||
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 |