summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* tests: don't do boundless string compares with data()David Kalnischkies2016-08-121-9/+11
| | | | Git-Dch: Ignore
* ensure a good clock() value for usage and testsDavid Kalnischkies2016-08-121-1/+9
| | | | | | | | | | | We use clock() as a very cheap way of getting a "random" value, but the manpage warns that this could return -1, so we should be dealing with this. Additionally, e.g. on hurd-i386 the value increases only slowly – to slow for our fast running tests for randomness hence producing the same range in both samples, so we introduce a simple busy-wait loop (as clock is counting processor time used by the program) in the test which delays the second sample just enough making our randomness a bit more predictable.
* don't perform int<float in progress bar drawingDavid Kalnischkies2016-08-121-1/+6
| | | | | | | | Comparing floating numbers is always fun and in this instance a 9 < 9.0 is "somehow" true on hurd-i386 letting the tests fail by reporting that too much progress achieved. A bit mysterious, but with some rework we can use code which avoids dealing with the floats in this way entirely and make our testcases happy.
* tests: copy 01autoremove from the right placeDavid Kalnischkies2016-08-111-2/+2
| | | | | | | | | | | | With cmake using BUILDDIRECTORY at this place is not only as wrong as it was before, but it might not even work always copying the system provided one which might or might not be current and hence fails tests needing it to be current like ./test-apt-move-and-forget-manual-sections We don't want to always use the one from the source directory through either like in autopkgtests. Gbp-Dch: Ignore
* Merge branch 'feature/apt-dpkg-comm'David Kalnischkies2016-08-1119-79/+160
|\
| * disable explicit configuration of all packages at the endDavid Kalnischkies2016-08-1013-75/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With b4450f1dd6bca537e60406b2383ab154a3e1485f we dropped what we calculated here later on and now that we don't need it in the meantime either we can just skip the busy work by default and expect dpkg to do the right thing dropping also our little "last explicit configures" removal trick introduced in b4450f1dd6bca537e60406b2383ab154a3e1485f. This enables the last of a bunch of previously experimental options, some of them existing still, but are very special and hence not really worth documenting anymore (especially as it would need to be rewritten now entirely) which is why the documentation is nearly completely dropped. The order of configuration stanzas in the simulation code changes slightly as it isn't concerning itself with finding the 'right' order, but any order is valid anyhow as long as the entire set happens in the same call.
| * try to avoid removal of crossgraded packagesDavid Kalnischkies2016-08-101-0/+49
| | | | | | | | | | | | | | | | The user has to approve the removal of a crossgraded package as it might be needed to remove it (temporarily) in the process, but in most cases we can happily avoid it and let dpkg unpack over it skipping the remove. This has some effects on progress reporting and how deal with selections through which makes this a tiny bit complicated.
| * don't purge directly, but remove and do purge at the endDavid Kalnischkies2016-08-101-2/+2
| | | | | | | | | | | | | | | | | | | | If we want a package to be purged from the system tell dpkg in the ordering (if it has to touch it explicitly) to remove it and cover the purging of the config files at the end with a --purge --pending call. That should help packages move conffiles around between packages correctly even if the user is purging packages directly in big actions like dist-upgrades involving many packages.
| * select remove/purge packages early on for dpkgDavid Kalnischkies2016-08-101-1/+1
| | | | | | | | | | | | | | Telling dpkg early on that we are going to remove these packages later helps it with auto-deconfiguration decisions and its another area where a planner can ignore the nitty gritty details and let dpkg decide the course of action if there are no special requirements.
| * save and restore selection states before/after calling dpkgDavid Kalnischkies2016-08-101-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | dpkg decides certain things on its own based on selections and especially if we want to call --pending on purge/remove actions, we need to ensure a clean slate or otherwise we surprise the user by removing packages we weren't allowed to remove by the user in this run (the selection might be an overarching plan for the not-yet "future"). Ideally dpkg would have some kind of temporal selection interface for this case, but it hasn't, so we make it temporal with the risk of loosing state if we don't manage to restore them.
| * use dpkg --unpack --recursive to avoid long cmdlinesDavid Kalnischkies2016-08-101-1/+1
| | | | | | | | | | | | | | | | | | | | Having long commandlines split into two is a huge problem if it happens and additionally if we want to introduce planners which perform less micromanagment its a good idea to leave the details for dpkg to decide. In practice this doesn't work yet unconditionally as a bug is hiding in the ordering code of dpkg, but it works if apt imposes its ordering so this commit allows for now at least to solve the first problem.
| * pass --force-remove-essential to dpkg only if neededDavid Kalnischkies2016-08-102-0/+7
| | | | | | | | | | | | APT (usually) knows which package is essential or not, so we can avoid passing this force flag to dpkg unconditionally if the user hasn't chosen a non-default essential handling obscuring the information.
* | Merge branch 'feature/methods'David Kalnischkies2016-08-1110-42/+242
|\ \
| * | block direct connections to .onion domains (RFC7687)David Kalnischkies2016-08-111-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Doing a direct connect to an .onion address (if you don't happen to use it as a local domain, which you shouldn't) is bound to fail and does leak the information that you do use Tor and which hidden service you wanted to connect to to a DNS server. Worse, if the DNS is poisoned and actually resolves tricking a user into believing the setup would work correctly… This does block also the usage of wrappers like torsocks with apt, but with native support available and advertised in the error message this shouldn't really be an issue. Inspired-by: https://bugzilla.mozilla.org/show_bug.cgi?id=1228457
| * | allow methods to be disabled and redirected via configDavid Kalnischkies2016-08-104-37/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To prevent accidents like adding http-sources while using tor+http it can make sense to allow disabling methods. It might even make sense to allow "redirections" and adding "symlinked" methods via configuration. This could e.g. allow using different options for certain sources by adding and configuring a "virtual" new method which picks up the config based on the name it was called with like e.g. http does if called as tor+http.
| * | implement socks5h proxy support for http methodDavid Kalnischkies2016-08-101-0/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Socks support is a requested feature in sofar that the internet is actually believing Acquire::socks::Proxy would exist. It doesn't and this commit isn't adding it as that isn't how our configuration works, but it allows Acquire::http::Proxy="socks5h://…". The HTTPS method was changed already to support socks proxies (all versions) via curl. This commit implements only SOCKS5 (RFC1928) with no auth or pass&user auth (RFC1929), but not GSSAPI which is required by the RFC. The 'h' in the protocol name further indicates that DNS resolution is delegated to the socks proxy rather than performed locally. The implementation works and was tested with Tor as socks proxy for which implementing socks5h only can actually be considered a feature. Closes: 744934
| * | implement generic config fallback for methodsDavid Kalnischkies2016-08-103-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The https method implemented for a long while now a hardcoded fallback to the same options in http, which, while it works, is rather inflexible if we want to allow the methods to use another name to change their behavior slightly, like apt-transport-tor does to https – most of the diff being s#https#tor#g which then fails to do the full circle fallthrough tor -> https -> http for https sources. With this config infrastructure this could be implemented now.
| * | use the same redirection handling for http and httpsDavid Kalnischkies2016-08-102-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | cURL which backs our https implementation can handle redirects on its own, but by dealing with them on our own we gain finer control over which redirections will be performed (we don't like https → http) and by whom so that redirections to other hosts correctly spawn a new https method dealing with these instead of letting the current one deal with it.
| * | detect redirection loops in acquire instead of workersDavid Kalnischkies2016-08-101-0/+23
| | | | | | | | | | | | | | | | | | | | | Having the detection handled in specific (http) workers means that a redirection loop over different hostnames isn't detected. Its also not a good idea have this implement in each method independently even if it would work
| * | fail on unsupported http/https proxy settingsDavid Kalnischkies2016-08-101-0/+33
| |/ | | | | | | Closes: #623443
* / allow user@host (aka: no password) in URI parsingDavid Kalnischkies2016-08-101-0/+12
|/ | | | If the URI had no password the username was ignored
* Do not set the binary dir in run-tests, it breaks stuffJulian Andres Klode2016-08-101-6/+0
| | | | | | | This breaks -j and does all sort of other weird stuff I did not notice in the previous (non-parallel) runs. Gbp-Dch: ignore
* test: Automatically discover CMake build directoryJulian Andres Klode2016-08-102-1/+27
| | | | | | | Look at the project root, and all directories directly below it and pick the directory with the newest CMakeCache.txt file. Gbp-Dch: ignore
* Get rid of the old buildsystemJulian Andres Klode2016-08-104-163/+0
| | | | Bye, bye, old friend.
* CMake: Add unit testsJulian Andres Klode2016-08-104-8/+31
| | | | | | | | Add support for our GTest based unit tests. By default, CMake will look in /usr/src/gtest for the external GTest project, but this can be overriden by defining GTEST_ROOT when invoking cmake. Gbp-Dch: ignore
* CMake: Switch integration tests and travis overJulian Andres Klode2016-08-064-9/+21
| | | | | | This early support seems a bit hacky, but it's a hard switch: The integration tests do not understand the old build system anymore afterwards. I don't really like that.
* test: Pass -maxdepth 1 when running find in methods dirJulian Andres Klode2016-08-063-3/+3
| | | | | This fixes a test failures in the cmake branch which contains sub directories in the methods output dir.
* (error) va_list 'args' was opened but not closed by va_end()David Kalnischkies2016-07-271-1/+1
| | | | | Reported-By: cppcheck Gbp-Dch: Ignore
* rred: truncate result file before writing to itDavid Kalnischkies2016-07-272-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | If another file in the transaction fails and hence dooms the transaction we can end in a situation in which a -patched file (= rred writes the result of the patching to it) remains in the partial/ directory. The next apt call will perform the rred patching again and write its result again to the -patched file, but instead of starting with an empty file as intended it will override the content previously in the file which has the same result if the new content happens to be longer than the old content, but if it isn't parts of the old content remain in the file which will pass verification as the new content written to it matches the hashes and if the entire transaction passes the file will be moved the lists/ directory where it might or might not trigger errors depending on if the old content which remained forms a valid file together with the new content. This has no real security implications as no untrusted data is involved: The old content consists of a base file which passed verification and a bunch of patches which all passed multiple verifications as well, so the old content isn't controllable by an attacker and the new one isn't either (as the new content alone passes verification). So the best an attacker can do is letting the user run into the same issue as in the report. Closes: #831762
* use a configurable location for apport report storageDavid Kalnischkies2016-07-222-1/+5
| | | | | Hardcoding /var/crash means we can't test it properly and it isn't really our style.
* support dpkg debug mode in APT::StateChangesDavid Kalnischkies2016-07-221-1/+1
| | | | Gbp-Dch: Ignore
* create non-existent files in edit-sources with 644 instead of 640David Kalnischkies2016-07-221-0/+39
| | | | | | | | | | If the sources file we want to edit doesn't exist yet GetLock will create it with 640, which for a generic lockfile might be okay, but as this is a sources file more relaxed permissions are in order – and actually required as it wont be readable for unprivileged users causing warnings/errors in apt calls. Reported-By: J. Theede (musca) on IRC
* tests: avoid time-dependent rebuild of cachesDavid Kalnischkies2016-07-221-0/+4
| | | | | | | | | The tests changes the sources.list and the modification time of this file is considered while figuring out if the cache can be good. Usually this isn't an issue, but in that case we have the cache generation produce warnings which appear twice in this case. Gbp-Dch: Ignore
* clean up default-stanzas from extended_states on writeDavid Kalnischkies2016-07-221-0/+8
| | | | | | | | | | The existing cleanup was happening only for packages which had a status change (install -> uninstalled) which is the most frequent but no the only case – you can e.g. set autobits explicitly with apt-mark. This would leave stanzas in the states file declaring a package to be manually installed – which is the default value for a package not listed at all, so we can just as well drop it from the file.
* tests: skip over -flags for first option in autotestsDavid Kalnischkies2016-07-221-1/+9
| | | | | | | Otherwise calls like "apt -q install" end up calling "aptautotest_apt_q" instead of "aptautotest_apt_install" Gbp-Dch: Ignore
* support "install ./foo.changes"David Kalnischkies2016-07-221-4/+5
| | | | | | | | | | | | We support installing ./foo.deb (and ./foo.dsc for source) for a while now, but it can be a bit clunky to work with those directly if you e.g. build packages locally in a 'central' build-area. The changes files also include hashsums and can be signed, so this can also be considered an enhancement in terms of security as a user "just" has to verify the signature on the changes file then rather than checking all deb files individually in these manual installation procedures.
* allow arch=all to override No-Support-for-Architecture-allDavid Kalnischkies2016-07-223-3/+38
| | | | | | | | | | | | | If a user explicitly requests the download of arch:all apt shouldn't get in the way and perform its detection dance if arch:all packages are (also) in arch:any files or not. This e.g. allows setting arch=all on a source with such a field (or one which doesn't support all at all, but has the arch:all files like Debian itself ATM) to get only the arch:all packages from there instead of behaving like a no-op. Reported-By: Helmut Grohne on IRC
* don't hardcode /var/lib/dpkg/status as dir::state::statusDavid Kalnischkies2016-07-191-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Theoretically it should be enough to change the Dir setting and have apt pick the dpkg/status file from that. Also, it should be consistently effected by RootDir. Both wasn't really the case through, so a user had to explicitly set it too (or ignore it and have or not have expected sideeffects caused by it). This commit tries to guess better the location of the dpkg/status file by setting dir::state::status to a naive "../dpkg/status", just that this setting would be interpreted as relative to the CWD and not relative to the dir::state directory. Also, the status file isn't really relative to the state files apt has in /var/lib/apt/ as evident if we consider that apt/ could be a symlink to someplace else and "../dpkg" not effected by it, so what we do here is an explicit replace on apt/ – similar to how we create directories if it ends in apt/ – with dpkg/. As this is a change it has the potential to cause regressions in so far as the dpkg/status file of the "host" system is no longer used if you set a "chroot" system via the Dir setting – but that tends to be intended and causes people to painfully figure out that they had to set this explicitly before, so that it now works more in terms of how the other Dir settings work (aka "as expected"). If using the host status file is really intended it is in fact easier to set this explicitely compared to setting the new "magic" location explicitely.
* ensure Cnf::FindFile doesn't return files below /dev/nullDavid Kalnischkies2016-07-191-0/+28
| | | | | | | Very unlikely, but if the parent is /dev/null, the child empty and the grandchild a value we returned /dev/null/value which doesn't exist, so hardly a problem, but for best operability we should be consistent in our work and return /dev/null always.
* tests: activate dpkg multi-arch even if test is single archDavid Kalnischkies2016-07-152-33/+36
| | | | | | | | | | | | | | Most tests are either multiarch, do not care for the specific architecture or do not interact with dpkg, so really effect by this is only test-external-installation-planner-protocol, but its a general issue that while APT can be told to treat any architecture as native dpkg has the native architecture hardcoded so if we run tests we must make sure that dpkg knows about the architecture we will treat as "native" in apt as otherwise dpkg will refuse to install packages from such an architecture. This reverts f883d2c3675eae2700e4cd1532c1a236cae69a4e as it complicates the test slightly for no practical gain after the generic fix.
* Use native arch in test-external-installation-planner-protocolJulian Andres Klode2016-07-151-22/+23
| | | | Hardcoding amd64 broke the tests.
* tests: fix external solver/planner directory setupDavid Kalnischkies2016-07-081-10/+7
| | | | | The setup didn't prepare the directories as expected by newer version of tthe external tests in an autopkgtests environment.
* Add kernels with "+" in the package name to APT::NeverAutoRemoveAndrew Patterson2016-07-081-3/+9
| | | | | | | | | Escape "+" in kernel package names when generating APT::NeverAutoRemove list so it is not treated as a regular expression meta-character. [Changed by David Kalnischkies: let test actually test the change] Closes: #830159
* don't change owner/perms/times through file:// symlinksDavid Kalnischkies2016-07-063-1/+21
| | | | | | | | | | | | | If we have files in partial/ from a previous invocation or similar such those could be symlinks created by file:// sources. The code is expecting only real files through and happily changes owner, modification times and permission on the file the symlink points to which tend to be files we have no business in touching in this way. Permissions of symlinks shouldn't be changed, changing owner is usually pointless to, but just to be sure we pick the easy way out and use lchown, check for symlinks before chmod/utimes. Reported-By: Mattia Rizzolo on IRC
* tests: disable EIPP logging in test-compressed-indexesDavid Kalnischkies2016-07-051-1/+2
| | | | | | | | | | | The test makes heavy use of disabling compression types which are usually available some way or another like xz which is how the EIPP logs are compressed by default. Instead of changing this test to change the filename according to the compression we want to test we just disable EIPP logging for this test as that is easier and has the same practical effect. Gbp-Dch: Ignore
* tests: allow setting environment in extra fileDavid Kalnischkies2016-07-051-0/+4
| | | | | | | | It can be handy to set apt options for the testcases which shouldn't be accidentally committed like external planner testing or workarounds for local setups. Gbp-Dch: Ignore
* Make the test case executableJulian Andres Klode2016-07-051-0/+0
| | | | Gbp-Dch: ignore
* indextargets: Check that cache could be built before using itJulian Andres Klode2016-07-051-0/+27
| | | | | | This caused a crash because the cache was a nullptr. Closes: #829651
* use +0000 instead of UTC by default as timezone in outputDavid Kalnischkies2016-07-022-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | All apt versions support numeric as well as 3-character timezones just fine and its actually hard to write code which doesn't "accidently" accepts it. So why change? Documenting the Date/Valid-Until fields in the Release file is easy to do in terms of referencing the datetime format used e.g. in the Debian changelogs (policy §4.4). This format specifies only the numeric timezones through, not the nowadays obsolete 3-character ones, so in the interest of least surprise we should use the same format even through it carries a small risk of regression in other clients (which encounter repositories created with apt-ftparchive). In case it is really regressing in practice, the hidden option -o APT::FTPArchive::Release::NumericTimezone=0 can be used to go back to good old UTC as timezone. The EDSP and EIPP protocols use this 'new' format, the text interface used to communicate with the acquire methods does not for compatibility reasons even if none of our methods would be effected and I doubt any other would (in these instances the timezone is 'GMT' as that is what HTTP/1.1 requires). Note that this is only true for apt talking to methods, (libapt-based) methods talking to apt will respond with the 'new' format. It is therefore strongly adviced to support both also in method input.
* warn if apt-key is used in scripts/its output parsedDavid Kalnischkies2016-07-012-2/+11
| | | | | | | | | apt-key needs gnupg for most of its operations, but depending on it isn't very efficient as apt-key is hardly used by users – and scripts shouldn't use it to begin with as it is just a silly wrapper. To draw more attention on the fact that e.g. 'apt-key add' should not be used in favor of "just" dropping a keyring file into the trusted.gpg.d directory this commit implements the display of warnings.