]> git.saurik.com Git - apt.git/blame - test/integration/test-bug-818628-unreadable-source
CMake: Add coverage build type
[apt.git] / test / integration / test-bug-818628-unreadable-source
CommitLineData
f40fdaa4
JAK
1#!/bin/sh
2set -e
3
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6setupenvironment
fdf9eef4 7configarchitecture 'amd64'
f40fdaa4 8
fdf9eef4
DK
9if [ "$(id -u)" = '0' ]; then
10 msgskip 'Tests for unreadable files do not work as root'
f40fdaa4
JAK
11 exit 0
12fi
13
fdf9eef4
DK
14insertinstalledpackage 'foo' 'amd64' '1'
15insertpackage 'unstable' 'foo' 'amd64' '2'
f40fdaa4 16
fdf9eef4 17setupaptarchive --no-update
f40fdaa4 18
fdf9eef4
DK
19touch rootdir/etc/apt/apt.conf.d/unreadable.conf
20touch rootdir/etc/apt/preferences.d/unreadable.pref
f40fdaa4 21
fdf9eef4
DK
22addtrap 'prefix' "chmod -R +r '$(escape_shell "$TMPWORKINGDIRECTORY")/rootdir/etc/apt';"
23chmod -r rootdir/etc/apt/trusted.gpg.d
24testfailure apt update
25chmod +r rootdir/etc/apt/trusted.gpg.d
26testsuccess apt update
27testsuccess apt policy foo
28testsuccess apt search foo
29testsuccessequal "Listing...
30foo/unstable 2 amd64 [upgradable from: 1]
31N: There is 1 additional version. Please use the '-a' switch to see it" apt list --upgradable
f40fdaa4 32
fdf9eef4
DK
33runthemall() {
34 local ERR1="$1"
35 local ERR2="$1$2"
36 testfailureequal "$ERR1" aptcache policy
37 testfailureequal "$ERR1" aptcache policy foo
38 testfailureequal "$ERR2" aptcache depends foo
39 testfailureequal "$ERR2" aptcache rdepends foo
40 testfailureequal "$ERR2" aptcache search foo
41 testfailureequal "$ERR1" apt policy
42 testfailureequal "$ERR1" apt policy foo
43 testfailureequal "$ERR2" apt depends foo
44 testfailureequal "$ERR2" apt rdepends foo
45 testfailureequal "$ERR2" apt search foo
46 testfailureequal "$ERR2" apt list --upgradable
47 testfailureequal "$ERR2" apt show foo
48 testfailureequal "$ERR2" aptcache show foo --no-all-versions
49 testfailureequal "$ERR2" aptmark auto foo
50 testfailureequal "$ERR2" aptmark manual foo
51 testfailureequal "$ERR2" aptmark auto foo
52}
53echo 'Apt::Cmd::Disable-Script-Warning "true";' >> aptconfig.conf
f40fdaa4 54
fdf9eef4 55msgmsg 'Unreadable sources file'
f40fdaa4 56chmod -r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
fdf9eef4
DK
57runthemall "E: Opening $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list - ifstream::ifstream (13: Permission denied)
58E: The list of sources could not be read."
59chmod +r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
f40fdaa4 60
fdf9eef4
DK
61msgmsg 'Unreadable config file'
62chmod -r rootdir/etc/apt/apt.conf.d/unreadable.conf
63runthemall "E: Opening configuration file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/unreadable.conf - ifstream::ifstream (13: Permission denied)"
64chmod +r rootdir/etc/apt/apt.conf.d/unreadable.conf
f40fdaa4 65
fdf9eef4
DK
66msgmsg 'Unreadable preferences file'
67chmod -r rootdir/etc/apt/preferences.d/unreadable.pref
68runthemall "E: Could not open file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/unreadable.pref - open (13: Permission denied)"
69chmod +r rootdir/etc/apt/preferences.d/unreadable.pref
70
71msgmsg 'Unreadable sources directory'
72chmod -r rootdir/etc/apt/sources.list.d
73runthemall "E: Unable to read $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/ - opendir (13: Permission denied)" "
74W: You may want to run apt-get update to correct these problems
75E: The package cache file is corrupted"
76chmod +r rootdir/etc/apt/sources.list.d
77
78msgmsg 'Unreadable config directory'
79chmod -r rootdir/etc/apt/apt.conf.d
80runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/ - opendir (13: Permission denied)"
81chmod +r rootdir/etc/apt/apt.conf.d
82
83msgmsg 'Unreadable preferences directory'
84chmod -r rootdir/etc/apt/preferences.d
85runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/ - opendir (13: Permission denied)"
86chmod +r rootdir/etc/apt/preferences.d