]> git.saurik.com Git - apt.git/blame - test/integration/test-debsrc-hashes
test/integration/test-debsrc-hashes: add integration test, thanks to Daniel Hartwig
[apt.git] / test / integration / test-debsrc-hashes
CommitLineData
30c54ac8
MV
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6
7setupenvironment
8configarchitecture "i386"
9
10# pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is
11# checking the best available hash (as it should), this will trigger
12# a hash mismatch.
13
14cat > aptarchive/Sources <<EOF
15Package: pkg-md5-ok
16Binary: pkg-md5-ok
17Version: 1.0
18Maintainer: Joe Sixpack <joe@example.org>
19Architecture: i386
20Files:
21 d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-ok_1.0.dsc
22 d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-ok_1.0.tar.gz
23
24Package: pkg-sha256-ok
25Binary: pkg-sha256-ok
26Version: 1.0
27Maintainer: Joe Sixpack <joe@example.org>
28Architecture: i386
29Files:
30 d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-ok_1.0.dsc
31 d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-ok_1.0.tar.gz
32Checksums-Sha1:
33 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-ok_1.0.dsc
34 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-ok_1.0.tar.gz
35Checksums-Sha256:
36 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-ok_1.0.dsc
37 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-ok_1.0.tar.gz
38
39Package: pkg-sha256-bad
40Binary: pkg-sha256-bad
41Version: 1.0
42Maintainer: Joe Sixpack <joe@example.org>
43Architecture: i386
44Files:
45 d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-bad_1.0.dsc
46 d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-bad_1.0.tar.gz
47Checksums-Sha1:
48 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-bad_1.0.dsc
49 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-bad_1.0.tar.gz
50Checksums-Sha256:
51 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0 pkg-sha256-bad_1.0.dsc
52 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0 pkg-sha256-bad_1.0.tar.gz
53EOF
54
55# create fetchable files
56for x in "pkg-md5-ok" "pkg-sha256-ok" "pkg-sha256-bad"; do
57 touch aptarchive/${x}_1.0.dsc
58 touch aptarchive/${x}_1.0.tar.gz
59done
60
61testok() {
62 msgtest "Test for hash ok of" "$*"
63 $* 2>&1 | grep "Download complete" > /dev/null && msgpass || msgfail
64}
65
66testmismatch() {
67 msgtest "Test for hash mismatch of" "$*"
68 $* 2>&1 | grep "Hash Sum mismatch" > /dev/null && msgpass || msgfail
69}
70
71setupaptarchive
72changetowebserver
73aptget update -qq
74
75testok aptget source -d pkg-md5-ok
76testok aptget source -d pkg-sha256-ok
77testmismatch aptget source -d pkg-sha256-bad