summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2010-07-30 12:45:00 +0200
committerMichael Vogt <mvo@debian.org>2010-07-30 12:45:00 +0200
commitb5cabd30cc1be1c6c1ca675ceb359bab577c1905 (patch)
tree2872bb0149a8123c9abb0c80462f9bb151d11d91 /test
parent3000cb123abe00418ccc2e388b6f93b76fe5514d (diff)
parente3326595301fc7bd1ee025a9dbb09ca51a08f5fa (diff)
* merge of the debian-expermental-ma branch
* debian/control: - add dependency on zlib-dev for libapt-pkg-dev * apt-pkg/cacheset.cc: - [ABI BREAK] add an ErrorType option to CacheSetHelper * cmdline/apt-cache.cc: - use Notice instead of Error in the CacheSetHelper messages for compat reasons. Otherwise tools like sbuild blow up - return success in show if a virtual package was given * debian/control: - remove libcurl3-gnutls-dev alternative as the package is gone - increase needed version of libcurl4-gnutls-dev to >= 7.19.0 as we use CURLOPT_{ISSUERCERT,CRLFILE} (Closes: #589642) * apt-pkg/deb/dpkgpm.cc: - Write architecture information to history file. - Add to history whether a change was automatic or not. * apt-pkg/contrib/fileutl.cc: - Add FileFd::OpenDescriptor() (needed for python-apt's #383617). * cmdline/apt-get.cc: - Support large filesystems by using statvfs64() instead of statvfs() and statfs64() instead of statfs() (Closes: #590513). * apt-pkg/cdrom.cc: - Use link() instead of rename() for creating the CD database backup; otherwise there would be a short time without any database. * apt-pkg/depcache.cc: - handle "circular" conflicts for "all" packages correctly * cmdline/apt-cache.cc: - be able to omit dependency types in (r)depends (Closes: #319006) - show in (r)depends the canidate per default instead of newest - share the (r)depends code instead of codecopy * apt-pkg/cacheset.cc: - move them back to the library as they look stable now - add a 'newest' pseudo target release as in pkg/newest * apt-pkg/pkgcache.cc: - prefer non-virtual packages in FindPreferredPkg (Closes: #590041) * test/integration/*: - add with bug#590041 testcase a small test "framework" * apt-pkg/orderlist.cc: - try to install another or-group member in DepRemove before breaking the or group (Closes: #590438) - configure also the replacement before remove by adding Immediate flag * apt-pkg/contrib/error.{cc,h} - docstring cleanup - add inline DumpError() to avoid subtle API break * apt-pkg/contrib/error.{cc,h}: - remove constness of va_list parameter to fix build on amd64 and co Thanks Eric Valette! (Closes: #588610) * apt-pkg/deb/debmetaindex.cc: - do not query each architecture for flat file archives - fix typo preventing display of architecture in Info() * methods/bzip2.cc: - add a copycat of the old gzip.cc as we need it for bzip2 and lzma * debian/rules: - Make DEB_BUILD_OPTIONS=noopt actually work by passing the right CXXFLAGS. * apt-pkg/contrib/fileutl.{h,cc}: - Add support for reading of gzipped files with the new "ReadOnlyGzip" OpenMode. (Closes: #188407) - Link against zlib (in apt-pkg/makefile) and add zlib build dependency. - [ABI BREAK] This adds a new private member to FileFd, but its initialization is in the public header file. * configure.in: - Check for zlib library and headers. * apt-pkg/acquire-item.cc, apt-pkg/deb/debindexfile.cc, apt-pkg/deb/debrecords.cc, apt-pkg/deb/debsrcrecords.h, cmdline/apt-cache.cc: - Open Packages, Sources, and Translations indexes in "ReadOnlyGzip" mode. * apt-pkg/deb/debindexfile.cc: - If we do not find uncompressed package/source/translation indexes, look for gzip compressed ones. * apt-pkg/acquire-item.cc: - If the Acquire::GzipIndexes option is true and we download a gzipped index file, keep it as it is (and rename to .gz) instead of uncompressing it. * doc/apt.conf.5.xml: - Document the new Acquire::GzipIndexes option. * doc/po/apt-doc.pot, doc/po/de.po: - German translation of new Acquire::GzipIndexes option. * Add test/test-indexes.sh: - Test behaviour of index retrieval and usage, in particular with uncompressed and gzip compressed indexes. * methods/gzip.cc: With FileFd now being able to read gzipped files, there is no need for the gzip method any more to spawn an external gzip process. Rewrite it to use FileFd directly, which makes the code a lot simpler, and also using less memory and overhead. * doc/apt.conf.5.xml: - add and document APT::Cache-{Start,Grow,Limit} options for mmap control * apt-pkg/contrib/fileutl.cc: - do not fail von double close() * cmdline/cacheset.cc: - doesn't include it in the library for now as it is too volatile - get the candidate either from an already built depcache or use the policy which is a bit faster than depcache generation - get packages by task^ with FromTask() - only print errors if all tries to get a package by string failed - factor out code to get a single package FromName() - check in Grouped* first without modifier interpretation * cmdline/apt-get.cc: - use the cachsets in the install commands - make the specify order of packages irrelevant (Closes: #196021) * apt-pkg/orderlist.cc: - untouched packages are never missing * apt-pkg/packagemanager.cc: - packages that are not touched doesn't need to be unpacked * debian/control: - remove intltool's dependency as it is an ubuntu artefact * apt-pkg/depcache.cc: - SetCandidateVer for all pseudo packages - SetReInstall for the "all" package of a pseudo package - use the new MatchAgainstConfig for the DefaultRootSetFunc - always mark the all package if a pseudo package is marked for install * apt-pkg/contrib/error.{cc,h}: - complete rewrite but use the same API - add NOTICE and DEBUG as new types of a message - add a simple stack handling to be able to delay error handling * apt-pkg/aptconfiguration.cc: - show a deprecation notice for APT::Acquire::Translation * apt-pkg/contrib/configuration.{cc,h}: - add a wrapper to match strings against configurable regex patterns * apt-pkg/contrib/fileutl.cc: - show notice about ignored file instead of being always silent - add a Dir::Ignore-Files-Silently list option to control the notice * apt-pkg/policy.h: - add another round of const& madness as the previous round accidentally NOT overrides the virtual GetCandidateVer() method (Closes: #587725) * apt-pkg/pkgcachegen.{cc,h}: - make the used MMap moveable (and therefore dynamic resizeable) by applying (some) mad pointer magic (Closes: #195018) * apt-pkg/deb/dpkgpm.cc: - make the apt/term.log output unbuffered (thanks to Matt Zimmerman) * methods/ftp.h: - Handle different logins on the same server (Closes: #586904). * apt-pkg/deb/deblistparser.cc: - Handle architecture wildcards (Closes: #547724). * apt-pkg/versionmatch.cc: - Support matching pins by regular expressions or glob() like patterns, regular expressions have to be put between to slashes; for example, /.*/. * apt-pkg/contrib/fileutl.cc: - Make FileFd replace files atomically in WriteTemp mode (for cache, etc). * debian/control: - Set Standards-Version to 3.9.0 * apt-pkg/cachefile.h: - make pkgPolicy public again, libapt-pkg-perl (and probably others) get unhappy without that * merge the remaining Ubuntu change: - on gpg verification failure warn and restore the last known good state - on failure display the IP of the server (useful for servers that use round robin DNS) - support Original-Maintainer in RewritePackageOrder - enable cdrom autodetection via libudev by default - show message about Vcs in use when apt-get source is run for packages maintained in a Vcs - better support transitional packages with mark auto-installed. when the transitional package is in "oldlibs" the new package is not marked auto installed (same is true for section metapackages) - provide new "deb mirror://archive.foo/mirrors.list sid main" method expects a list of mirrors (generated on the server e.g. via geoip) and will use that, including cycle on failure - write apport crash file on package failure (disabled by default on debian until apport is available) - support mirror failure reporting (disabled by default on debian) * apt-pkg/deb/dpkgpm.cc: - write Disappeared also to the history.log - forward manual-installed bit on package disappearance * apt-pkg/deb/debsystem.cc: - add better config item for extended_states file * apt-pkg/pkgcache.h: - switch {,Install-}Size to unsigned long long * apt-pkg/depcache.cc: - do the autoremove mark process also for required packages to handle these illegally depending on lower priority packages (Closes: #583517) - try harder to find the other pseudo versions for autoremove multiarch - correct "Dangerous iterator usage" pointed out by cppcheck - deal with long long, not with int to remove 2GB Limit (LP: #250909) - deprecate AddSize with Multiplier as it is unused and switch to boolean instead to handle the sizes more gracefully. - switch i{Download,Usr}Size from double to (un)signed long long * apt-pkg/aptconfiguration.cc: - remove duplicate architectures in getArchitectures() * apt-pkg/indexrecords.{cc,h}: - backport forgotten Valid-Until patch from the obsolete experimental branch to prevent replay attacks better, thanks to Thomas Viehmann for the initial patch! (Closes: #499897) - add a constant Exists check for MetaKeys * apt-pkg/acquire-item.cc: - do not try PDiff if it is not listed in the Meta file - sent Last-Modified header also for Translation files * apt-pkg/cacheiterator.h: - let pkgCache::Iterator inherent std::iterator * ftparchive/writer.h: - add a virtual destructor to FTWScanner class (for cppcheck) * apt-pkg/cacheset.{cc,h}: - add simple wrapper around std::set for cache structures - move regex magic from apt-get to new FromRegEx method - move cmdline parsing from apt-cache to new FromCommandLine method - support special release-modifier 'installed' and 'candidate' * apt-pkg/contrib/cmdline.cc: - fix segfault in SaveInConfig caused by writing over char[] sizes * apt-pkg/pkgcache.cc: - get the best matching arch package from a group with FindPreferredPkg * cmdline/apt-cache.cc: - make the search multiarch compatible by using GrpIterator instead - use pkgCacheFile and the new CacheSets all over the place - add --target-release option (Closes: #115520) - accept pkg/release and pkg=version in show and co. (Closes: #236270) - accept package versions in the unmet command * cmdline/apt-get.cc: - use unsigned long long instead of double to store values it gets * apt-pkg/cachefile.{cc,h}: - split Open() into submethods to be able to build only parts - make the OpProgress optional in the Cache buildprocess - store also the SourceList we use internally for export * doc/apt.conf.5.xml: - document the new Valid-Until related options * apt-pkg/contrib/strutl.cc: - split StrToTime() into HTTP1.1 and FTP date parser methods and use strptime() instead of some self-made scanf mangling - use the portable timegm shown in his manpage instead of a strange looking code copycat from wget * ftparchive/writer.cc: - add ValidTime option to generate a Valid-Until header in Release file * apt-pkg/policy.cc: - get the candidate right for a not-installed pseudo package if his non-pseudo friend is installed * apt-pkg/indexcopy.cc: - move the gpg codecopy to a new method and use it also in methods/gpgv.cc * cmdline/apt-get.cc: - rerun dpkg-source in source if --fix-broken is given (Closes: #576752) - don't suggest held packages as they are installed (Closes: #578135) - handle multiple --{tar,diff,dsc}-only options correctly - show at the end of the install process a list of disappeared packages * cmdline/apt-cache.cc: - use GroupCount for package names in stats and add a package struct line * methods/rred.cc: - use the patchfile modification time instead of the one from the "old" file - thanks to Philipp Weis for noticing! (Closes: #571541) * debian/rules: - remove targets referring to CVS or arch as they are useless - use $(CURDIR) instead of $(pwd) - use dpkg-buildflags if available for CXXFLAGS * README.arch: - remove the file completely as it has no use nowadays * apt-pkg/depcache.cc: - be doublesure that the killer query is empty before starting reinstall * methods/gpgv.cc: - remove the keyrings count limit by using vector magic * contrib/mmap.cc: - clarify "MMap reached size limit" error message, thanks Ivan Masár! * doc/apt.ent - add entities for the current oldstable/stable/testing codenames * doc/sources.list.5.xml: - use stable-codename instead of stable in the examples (Closes: #531492) * doc/apt_preferences.5.xml: - adapt some examples here to use current codenames as well - add "NotAutomatic: yes" handling, thanks Osamu Aoki (Closes: #490347) * debian/libapt-pkg-doc.doc-base.cache: - remove yet another reference to the removed cache.sgml * doc/apt-get.8.xml: - do not say explicit target_release_{name,version,codename}, it should be clear by itself and 'man' can break lines again (Closes: #566166) - remove the gnome-apt reference as it is removed from unstable * apt-pkg/deb/dpkgpm.cc: - add 'disappear' to the known processing states, thanks Jonathan Nieder * apt-pkg/packagemanager.h: - export info about disappeared packages with GetDisappearedPackages() * methods/http.{cc,h}: - code cleanup, use enums instead of magic ints * debian/rules: - spell out some less known options to reduce manpage consultation-rate - Use POSIX command substitution: $(<command sequence>) - Remove EOL whitespace (Closes: #577804) * apt-pkg/acquire-item.cc: - Fix pkgAcqFile::Custom600Headers() to always return something. * apt-pkg/depcache.cc: - rewrite the pseudo package reinstaller to be more intelligent in his package choices * apt-pkg/packagemanager.cc: - don't try to "unpack" pseudo packages twice * apt-pkg/contrib/fileutl.cc: - add a parent-guarded "mkdir -p" as CreateDirectory() * apt-pkg/acquire.{cc,h}: - add a delayed constructor with Setup() for success reporting - check for and create directories in Setup if needed instead of error out unfriendly in the Constructor (Closes: #523920, #525783) - optional handle a lock file in Setup() * apt-pkg/acquire-item.cc: - Acquire::ForceHash to force method for expected hash * cmdline/apt-get.cc: - remove the lock file handling and let Acquire take care of it instead - display MD5Sum in --print-uris if not forced to use another method instead of displaying the strongest available (Closes: #576420) - regex for package names executed on Grp- not PkgIterator - show non-candidates as fallback for virtual packages (Closes: #578385) - set also "all" to this version for pseudo packages in TryToChangeVer * apt-pkg/deb/dpkgpm.cc: - remove Chroot-Directory from files passed to install commands. Thanks to Kel Modderman for report & patch! (Closes: #577226) * ftparchive/writer.cc: - remove 999 chars Files and Checksums rewrite limit (Closes: #577759) * cmdline/apt-cache.cc: - align Installed and Candidate Version in policy so they can be compared easier, thanks Ralf Gesellensetter for the pointer! (Closes: #578657) * doc/apt.ent: - Add a note about APT_CONFIG in the -c description (Closes: #578267) * doc/po/de.po: - correct typos in german apt_preferences manpage, thanks Chris Leick! * apt-pkg/sourcelist.cc: - be less strict and accept [option=value] as well * apt-pkg/contrib/configuration.cc: - error out if #clear directive has no argument * doc/files.sgml: - sync documentation with status quo, regarding files/directories in use, extended_states and uri schemes. * doc/cache.sgml: - drop the file in favor of inplace documentation with doxygen * apt-pkg/pkgcache.h: - enhance the Groups ABI by providing a ID as the other structs does - check also the size of the Group struct then checking for the others * cmdline/apt-get.cc: - replace backticks with single quotes around fix-broken command in the broken packages message. (Closes: #577168) * dselect/install: - modernize if-statements not to use 'x' (Closes: #577117) - replace backticks with POSIX $() (Closes: #577116) * cmdline/apt-get.cc: - fix crash when pkg.VersionList() is empty - install html doxygen in libapt-pkg-doc * debian/control: - build-depend on doxygen * apt-pkg/contrib/weakptr.h: - add a class WeakPointable which allows one to register weak pointers to an object which will be set to NULL when the object is deallocated. * [ABI break] apt-pkg/acquire{-worker,-item,}.h: - subclass pkgAcquire::{Worker,Item,ItemDesc} from WeakPointable. * apt-pkg/pkgcache.cc: - Merge fix from David to correct handling in single-arch environments. * cmdline/apt-cache.cc: - Add a showauto command to apt-cache. * cmdline/apt-get.cc: - Add apt-get markauto and unmarkauto commands. * [BREAK] merge MultiArch-ABI. We don't support MultiArch, but we support the usage of the new ABI so libapt users can start to prepare for MultiArch (Closes: #536029) * Ignore :qualifiers after package name in build dependencies in the library by default, but try to honour them in apt-get as we have some sort of MultiArch support ready (Closes: #558103) * add translation of the manpages to PT (portuguese) Thanks to Américo Monteiro! * Switch to dpkg-source 3.0 (native) format * apt-pkg/depcache.cc: - remove Auto-Installed information from extended_states together with the package itself (Closes: #572364) * cmdline/apt-mark: - don't crash if no arguments are given (Closes: #570962) * debian/control: - remove some years old and obsolete Replaces - add automake/conf build-depends/conflicts as recommend by the autotools-dev README (Closes: #572615) * apt-pkg/contrib/mmap.{h,cc}: - add char[] fallback for filesystems without shared writable mmap() like JFFS2. Thanks to Marius Vollmer for writing and to Loïc Minier for pointing to the patch! (Closes: #314334) * doc/apt_preferences.5.xml: - fix two typos and be more verbose in the novice warning. Thanks to Osamu Aoki for pointing it out! (Closes: #567669) - fix a=sid vs. n=sid typo, thanks Ansgar Burchardt! - origin can be used to match a hostname (Closes: #352667) - remove wrong pin-priority is optional remark (Closes: #574944) * apt-pkg/deb/dpkgpm.cc: - fix error message construction in OpenLog() - if available store the Commandline in the history * cmdline/apt-get.cc: - add a --only-upgrade flag to install command (Closes: #572259) - fix memory leaks in error conditions in DoSource() - try version match in FindSrc first exact than fuzzy (LP: #551178) * apt-pkg/contrib/cmndline.cc: - save Commandline in Commandline::AsString for logging * apt-pkg/deb/debversion.cc: - consider absent of debian revision equivalent to 0 (Closes: #573592) * doc/makefile, doc/*: - generate subdirectories for building the manpages in on the fly depending on the po files we have. * apt-pkg/pkgcachegen.cc: - merge versions correctly even if multiple different versions with the same version number are available. Thanks to Magnus Holmgren for the patch! (Closes: #351056) * ftparchive/writer.cc: - write LongDescriptions if they shouldn't be included in Packages file into i18n/Translation-en by default. * doc/po/de.po: - correct a few typos in the german manpage translation. Thanks to Chris Leick and Georg Koppen! (Closes: #574962) * apt-pkg/contrib/strutl.cc: - convert all toupper calls to tolower_ascii for a little speedup * apt-pkg/contrib/strutl.cc: - always escape '%' (LP: #130289) (Closes: #500560) - unescape '%' sequence only if followed by 2 hex digit - username/password are urlencoded in proxy string (RFC 3986)
Diffstat (limited to 'test')
-rw-r--r--test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages25
-rw-r--r--test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release13
-rw-r--r--test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg7
-rw-r--r--test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages25
-rw-r--r--test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release13
-rw-r--r--test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg7
-rw-r--r--test/authReliability/sources.list.failure2
-rw-r--r--test/authReliability/sources.list.good2
-rw-r--r--test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order67
-rw-r--r--test/integration/framework201
-rwxr-xr-xtest/integration/run-tests8
-rw-r--r--test/integration/status-bug-590438-broken-provides-thanks-to-remove-order97
-rwxr-xr-xtest/integration/test-bug-590041-prefer-non-virtual-packages51
-rwxr-xr-xtest/integration/test-bug-590438-broken-provides-thanks-to-remove-order98
-rw-r--r--test/libapt/commandlineasstring_test.cc39
-rw-r--r--test/libapt/compareversion_test.cc123
-rw-r--r--test/libapt/getarchitectures_test.cc61
-rw-r--r--test/libapt/globalerror_test.cc77
-rw-r--r--test/libapt/makefile23
-rw-r--r--test/libapt/parsedepends_test.cc68
-rwxr-xr-xtest/libapt/run-tests (renamed from test/libapt/run-tests.sh)10
-rw-r--r--test/makefile15
-rwxr-xr-xtest/pre-upload-check.py118
-rwxr-xr-xtest/test-indexes.sh226
-rw-r--r--test/testsources.list/sources.list.all-validuntil-broken1
-rw-r--r--test/versions.lst64
-rw-r--r--test/versiontest.cc233
27 files changed, 1419 insertions, 255 deletions
diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages
new file mode 100644
index 000000000..3e7265438
--- /dev/null
+++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages
@@ -0,0 +1,25 @@
+Package: libglib2.0-data
+Priority: optional
+Section: misc
+Installed-Size: 2288
+Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com>
+Original-Maintainer: Loic Minier <lool@dooz.org>
+Architecture: all
+Source: glib2.0
+Version: 2.13.6-1ubuntu1
+Replaces: libglib1.3, libglib1.3-data
+Depends: libglib2.0-0 (>= 2.13.6-1ubuntu1)
+Conflicts: libglib1.3-data
+Filename: ./libglib2.0-data_2.13.6-1ubuntu1_all.deb
+Size: 958
+MD5sum: 803fc5e2e31a4345b3e9c771e1eae49f
+SHA1: 75b2c62b21bae60c58e694dd40ed6d4df946e304
+SHA256: 142d8466eac252f06bc957d76fe1bb87f86f2d3512b99c8d4b08c1ad79fbe59e
+Description: Common files for GLib library
+ GLib is a library containing many useful C routines for things such
+ as trees, hashes, lists, and strings. It is a useful general-purpose
+ C library used by projects such as GTK+, GIMP, and GNOME.
+ .
+ This package is needed for the runtime libraries to display messages in
+ languages other than English.
+
diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release
new file mode 100644
index 000000000..7ecd4cd19
--- /dev/null
+++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release
@@ -0,0 +1,13 @@
+Date: Fri, 27 Jul 2007 14:39:41 UTC
+MD5Sum:
+ 4672dadea6a144839f823c9f3d5fd44b 934 Packages
+ 82ebcf09a8d78a2b9cf7759349da4936 603 Packages.gz
+ d41d8cd98f00b204e9800998ecf8427e 0 Release
+SHA1:
+ fa0f294aa30789529371066b10e9497be1284d26 934 Packages
+ f4032808663b2810d87b4a4dab6f5ae4a1e8fa8e 603 Packages.gz
+ da39a3ee5e6b4b0d3255bfef95601890afd80709 0 Release
+SHA256:
+ 92c9b605480dc74e6be79c0ddc24738bfcbd6dd3148af531acd68717de528049 934 Packages
+ 659ccc0d07ff21f0247f9fa5abe149221c90d5e17da52c7afddb035b93c23d39 603 Packages.gz
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 Release
diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg
new file mode 100644
index 000000000..85c356e6f
--- /dev/null
+++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg
@@ -0,0 +1,7 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+iD8DBQBGqgOwliSD4VZixzQRAs6jAJ9p7Aiob9gzkUNCtoW8UPrBo0E/YwCdEaz0
+CQJszU6fRYX5jGWXSWzfc5c=
+=ugH0
+-----END PGP SIGNATURE-----
diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages
new file mode 100644
index 000000000..3e7265438
--- /dev/null
+++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages
@@ -0,0 +1,25 @@
+Package: libglib2.0-data
+Priority: optional
+Section: misc
+Installed-Size: 2288
+Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com>
+Original-Maintainer: Loic Minier <lool@dooz.org>
+Architecture: all
+Source: glib2.0
+Version: 2.13.6-1ubuntu1
+Replaces: libglib1.3, libglib1.3-data
+Depends: libglib2.0-0 (>= 2.13.6-1ubuntu1)
+Conflicts: libglib1.3-data
+Filename: ./libglib2.0-data_2.13.6-1ubuntu1_all.deb
+Size: 958
+MD5sum: 803fc5e2e31a4345b3e9c771e1eae49f
+SHA1: 75b2c62b21bae60c58e694dd40ed6d4df946e304
+SHA256: 142d8466eac252f06bc957d76fe1bb87f86f2d3512b99c8d4b08c1ad79fbe59e
+Description: Common files for GLib library
+ GLib is a library containing many useful C routines for things such
+ as trees, hashes, lists, and strings. It is a useful general-purpose
+ C library used by projects such as GTK+, GIMP, and GNOME.
+ .
+ This package is needed for the runtime libraries to display messages in
+ languages other than English.
+
diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release
new file mode 100644
index 000000000..7ecd4cd19
--- /dev/null
+++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release
@@ -0,0 +1,13 @@
+Date: Fri, 27 Jul 2007 14:39:41 UTC
+MD5Sum:
+ 4672dadea6a144839f823c9f3d5fd44b 934 Packages
+ 82ebcf09a8d78a2b9cf7759349da4936 603 Packages.gz
+ d41d8cd98f00b204e9800998ecf8427e 0 Release
+SHA1:
+ fa0f294aa30789529371066b10e9497be1284d26 934 Packages
+ f4032808663b2810d87b4a4dab6f5ae4a1e8fa8e 603 Packages.gz
+ da39a3ee5e6b4b0d3255bfef95601890afd80709 0 Release
+SHA256:
+ 92c9b605480dc74e6be79c0ddc24738bfcbd6dd3148af531acd68717de528049 934 Packages
+ 659ccc0d07ff21f0247f9fa5abe149221c90d5e17da52c7afddb035b93c23d39 603 Packages.gz
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 Release
diff --git a/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg
new file mode 100644
index 000000000..85c356e6f
--- /dev/null
+++ b/test/authReliability/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg
@@ -0,0 +1,7 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+iD8DBQBGqgOwliSD4VZixzQRAs6jAJ9p7Aiob9gzkUNCtoW8UPrBo0E/YwCdEaz0
+CQJszU6fRYX5jGWXSWzfc5c=
+=ugH0
+-----END PGP SIGNATURE-----
diff --git a/test/authReliability/sources.list.failure b/test/authReliability/sources.list.failure
new file mode 100644
index 000000000..110f31884
--- /dev/null
+++ b/test/authReliability/sources.list.failure
@@ -0,0 +1,2 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/gpg-package-broken/ /
+
diff --git a/test/authReliability/sources.list.good b/test/authReliability/sources.list.good
new file mode 100644
index 000000000..2e9a4458a
--- /dev/null
+++ b/test/authReliability/sources.list.good
@@ -0,0 +1,2 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/gpg-package-ok/ /
+
diff --git a/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order
new file mode 100644
index 000000000..75a769e1a
--- /dev/null
+++ b/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order
@@ -0,0 +1,67 @@
+Package: gawk
+Priority: optional
+Section: interpreters
+Installed-Size: 2084
+Maintainer: Arthur Loiret <aloiret@debian.org>
+Architecture: i386
+Version: 1:3.1.7.dfsg-5
+Provides: awk
+Pre-Depends: libc6 (>= 2.3)
+Filename: pool/main/g/gawk/gawk_3.1.7.dfsg-5_i386.deb
+Size: 766008
+MD5sum: 6459a02cfc1b9eafb3c0415e4ff4e252
+SHA1: ac033488dae4b7e8167d610e490319c047edf7e4
+SHA256: a2337dfe1cc82aeae46f2c722e5cc7be9ecefdea4aaf13f540cfe70bd8b1d627
+Description-de: GNU awk, eine Mustererkennungs- und Verarbeitungssprache
+Homepage: http://www.gnu.org/software/gawk/
+Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, use::filtering, use::scanning, works-with::text
+
+Package: aawk
+Priority: optional
+Section: interpreters
+Installed-Size: 2084
+Maintainer: Arthur Loiret <aloiret@debian.org>
+Architecture: i386
+Version: 1:3.1.7.dfsg-5
+Provides: awk
+Pre-Depends: libc6 (>= 2.3)
+Filename: pool/main/a/aawk/aawk_3.1.7.dfsg-5_i386.deb
+Size: 766008
+MD5sum: 6459a02cfc1b9eafb3c0415e4ff4e252
+SHA1: ac033488dae4b7e8167d610e490319c047edf7e4
+SHA256: a2337dfe1cc82aeae46f2c722e5cc7be9ecefdea4aaf13f540cfe70bd8b1d627
+Description-de: GNU awk, eine Mustererkennungs- und Verarbeitungssprache
+Homepage: http://www.gnu.org/software/gawk/
+Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, use::filtering, use::scanning, works-with::text
+
+Package: gawk2
+Priority: optional
+Section: interpreters
+Installed-Size: 2084
+Maintainer: Arthur Loiret <aloiret@debian.org>
+Architecture: i386
+Version: 1:3.1.7.dfsg-5
+Provides: awk
+Pre-Depends: libc6 (>= 2.3)
+Depends: coolstuff
+Filename: pool/main/g/gawk/gawk_3.1.7.dfsg-5_i386.deb
+Size: 766008
+MD5sum: 6459a02cfc1b9eafb3c0415e4ff4e252
+SHA1: ac033488dae4b7e8167d610e490319c047edf7e4
+SHA256: a2337dfe1cc82aeae46f2c722e5cc7be9ecefdea4aaf13f540cfe70bd8b1d627
+Description-de: GNU awk, eine Mustererkennungs- und Verarbeitungssprache
+Homepage: http://www.gnu.org/software/gawk/
+Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, use::filtering, use::scanning, works-with::text
+
+Package: coolstuff
+Priority: optional
+Section: cool
+Installed-Size: 10
+Maintainer: David Kalnischkies <kalnischkies+debian@gmail.com>
+Architecture: all
+Version: 1-1
+Filename: pool/main/c/coolstuff/coolstuff_1-1_all.deb
+Size: 7608
+MD5sum: 6459aa2efc139eafb323ac3f4f5aeb22
+Description: We all need cool stuff
+
diff --git a/test/integration/framework b/test/integration/framework
new file mode 100644
index 000000000..b4e9302e8
--- /dev/null
+++ b/test/integration/framework
@@ -0,0 +1,201 @@
+#!/bin/sh -- # no runable script, just for vi
+
+# we all like colorful messages
+CERROR="" # red
+CWARNING="" # yellow
+CMSG="" # green
+CINFO="" # light blue
+CDEBUG="" # blue
+CNORMAL="" # default system console color
+CDONE="" # green
+CPASS="" # green
+CFAIL="" # red
+CCMD="" # pink
+
+msgdie() { echo "${CERROR}E: $1${CNORMAL}" >&2; exit 1; }
+msgwarn() { echo "${CWARNING}W: $1${CNORMAL}" >&2; }
+msgmsg() { echo "${CMSG}$1${CNORMAL}" >&2; }
+msginfo() { echo "${CINFO}I: $1${CNORMAL}" >&2; }
+msgdebug() { echo "${CDEBUG}D: $1${CNORMAL}" >&2; }
+msgdone() { echo "${CDONE}DONE${CNORMAL}" >&2; }
+msgnwarn() { echo -n "${CWARNING}W: $1${CNORMAL}" >&2; }
+msgnmsg() { echo -n "${CMSG}$1${CNORMAL}" >&2; }
+msgninfo() { echo -n "${CINFO}I: $1${CNORMAL}" >&2; }
+msgndebug() { echo -n "${CDEBUG}D: $1${CNORMAL}" >&2; }
+msgtest() { echo -n "${CINFO}$1 ${CCMD}$(echo "$2" | sed -e 's/^aptc/apt-c/' -e 's/^aptg/apt-g/' -e 's/^aptf/apt-f/')${CINFO} …${CNORMAL} " >&2; }
+msgpass() { echo "${CPASS}PASS${CNORMAL}" >&2; }
+msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
+msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; }
+
+# enable / disable Debugging
+msginfo() { true; }
+msgdebug() { true; }
+msgninfo() { true; }
+msgndebug() { true; }
+msgdone() { if [ "$1" = "debug" -o "$1" = "info" ]; then true; else echo "${CDONE}DONE${CNORMAL}" >&2; fi }
+
+runapt() {
+ msgdebug "Executing: ${CCMD}$*${CDEBUG} "
+ APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+}
+aptconfig() { runapt apt-config $*; }
+aptcache() { runapt apt-cache $*; }
+aptget() { runapt apt-get $*; }
+aptftparchive() { runapt apt-ftparchive $*; }
+
+setupenvironment() {
+ local TMPWORKINGDIRECTORY=$(mktemp -d)
+ local TESTDIR=$(readlink -f $(dirname $0))
+ msgninfo "Preparing environment for ${CCMD}$0${CINFO} in ${TMPWORKINGDIRECTORY}… "
+ BUILDDIRECTORY="${TESTDIR}/../../build/bin"
+ test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
+ local OLDWORKINGDIRECTORY=$(pwd)
+ trap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+ cd $TMPWORKINGDIRECTORY
+ mkdir rootdir aptarchive
+ cd rootdir
+ mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d var/cache var/lib/dpkg
+ mkdir -p var/cache/apt/archives/partial var/lib/apt/lists/partial
+ local STATUSFILE=$(echo "$(basename $0)" | sed 's/^test-/status-/')
+ if [ -f "${TESTDIR}/${STATUSFILE}" ]; then
+ cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status
+ else
+ touch var/lib/dpkg/status
+ fi
+ mkdir -p usr/lib/apt
+ ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods
+ cd ..
+ local PACKAGESFILE=$(echo "$(basename $0)" | sed 's/^test-/Packages-/')
+ if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then
+ cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages
+ else
+ touch var/lib/dpkg/status
+ fi
+ echo "RootDir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
+ echo "Debug::NoLocking \"true\";" >> aptconfig.conf
+ echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
+ export LC_ALL=C
+ msgdone "info"
+}
+
+configarchitecture() {
+ local CONFFILE=rootdir/etc/apt/apt.conf.d/01multiarch.conf
+ echo "APT::Architecture \"$1\";" > $CONFFILE
+ shift
+ while [ -n "$1" ]; do
+ echo "APT::Architectures:: \"$1\";" >> $CONFFILE
+ shift
+ done
+}
+
+buildflataptarchive() {
+ msginfo "Build APT archive for ${CCMD}$0${CINFO}…"
+ cd aptarchive
+ APTARCHIVE=$(readlink -f .)
+ if [ -f Packages ]; then
+ msgninfo "\tPackages file… "
+ cat Packages | gzip > Packages.gz
+ cat Packages | bzip2 > Packages.bz2
+ cat Packages | lzma > Packages.lzma
+ msgdone "info"
+ fi
+ if [ -f Sources ]; then
+ msgninfo "\tSources file… "
+ cat Sources | gzip > Sources.gz
+ cat Sources | bzip2 > Sources.bz2
+ cat Sources | lzma > Sources.lzma
+ msgdone "info"
+ fi
+ cd ..
+ aptftparchive release . > Release
+}
+
+setupflataptarchive() {
+ buildflataptarchive
+ APTARCHIVE=$(readlink -f ./aptarchive)
+ if [ -f ${APTARCHIVE}/Packages ]; then
+ msgninfo "\tadd deb sources.list line… "
+ echo "deb file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
+ msgdone "info"
+ else
+ rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
+ fi
+ if [ -f ${APTARCHIVE}/Sources ]; then
+ msgninfo "\tadd deb-src sources.list line… "
+ echo "deb-src file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
+ msgdone "info"
+ else
+ rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
+ fi
+ aptget update -qq
+}
+
+diff() {
+ local DIFFTEXT="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
+ if [ -n "$DIFFTEXT" ]; then
+ echo
+ echo "$DIFFTEXT"
+ return 1
+ else
+ return 0
+ fi
+}
+
+testequal() {
+ local COMPAREFILE=$(mktemp)
+ echo "$1" > $COMPAREFILE
+ shift
+ msgtest "Test for equality of" "$*"
+ $* 2>&1 | diff $COMPAREFILE - && msgpass || msgfail
+ rm $COMPAREFILE
+}
+
+testequalor2() {
+ local COMPAREFILE1=$(mktemp)
+ local COMPAREFILE2=$(mktemp)
+ local COMPAREAGAINST=$(mktemp)
+ echo "$1" > $COMPAREFILE1
+ echo "$2" > $COMPAREFILE2
+ shift 2
+ msgtest "Test for equality OR of" "$*"
+ $* 2>&1 1> $COMPAREAGAINST
+ (diff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null ||
+ diff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null) && msgpass ||
+ ( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(diff $COMPAREFILE1 $COMPAREAGAINST)" \
+ "\n${CINFO}Diff against OR 2${CNORMAL}" "$(diff $COMPAREFILE2 $COMPAREAGAINST)" &&
+ msgfail )
+ rm $COMPAREFILE1 $COMPAREFILE2 $COMPAREAGAINST
+}
+
+testshowvirtual() {
+ local VIRTUAL="E: Can't select versions from package '$1' as it purely virtual"
+ local PACKAGE="$1"
+ shift
+ while [ -n "$1" ]; do
+ VIRTUAL="${VIRTUAL}
+E: Can't select versions from package '$1' as it purely virtual"
+ PACKAGE="${PACKAGE} $1"
+ shift
+ done
+ msgtest "Test for virtual packages" "apt-cache show $PACKAGE"
+ VIRTUAL="${VIRTUAL}
+E: No packages found"
+ local COMPAREFILE=$(mktemp)
+ local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH_CPU)
+ eval `apt-config shell ARCH APT::Architecture`
+ echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
+ aptcache show $PACKAGE 2>&1 | diff $COMPAREFILE - && msgpass || msgfail
+ rm $COMPAREFILE
+}
+
+testnopackage() {
+ msgtest "Test for non-existent packages" "apt-cache show $*"
+ local SHOWPKG="$(aptcache show $* 2>&1 | grep '^Package: ')"
+ if [ -n "$SHOWPKG" ]; then
+ echo
+ echo "$SHOWPKG"
+ msgfail
+ return 1
+ fi
+ msgpass
+}
diff --git a/test/integration/run-tests b/test/integration/run-tests
new file mode 100755
index 000000000..cb74f21e7
--- /dev/null
+++ b/test/integration/run-tests
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+local DIR=$(readlink -f $(dirname $0))
+for testcase in $(run-parts --list $DIR | grep '/test-'); do
+ echo "\033[1;32mRun Testcase \033[1;35m$(basename ${testcase})\033[0m"
+ ${testcase}
+done
diff --git a/test/integration/status-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/status-bug-590438-broken-provides-thanks-to-remove-order
new file mode 100644
index 000000000..c2c03c0e4
--- /dev/null
+++ b/test/integration/status-bug-590438-broken-provides-thanks-to-remove-order
@@ -0,0 +1,97 @@
+Package: libc-bin
+Status: install ok installed
+Priority: required
+Section: libs
+Installed-Size: 1516
+Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org>
+Architecture: i386
+Source: eglibc
+Version: 2.11.2-2
+Replaces: libc0.1, libc0.3, libc6, libc6.1
+Breaks: libc0.1 (<< 2.10), libc0.3 (<< 2.10), libc6 (<< 2.10), libc6.1 (<< 2.10)
+Filename: pool/main/e/eglibc/libc-bin_2.11.2-2_i386.deb
+Size: 703542
+MD5sum: f554ec34c092bb8e52e3d917bec7b46c
+SHA1: 4d5ba53b50937b1d50e3234e45335de5ea97b84b
+SHA256: 4f1e6430a730321209bb6b9cf89ba8a72c95f5c93f3e263a982251b3cc8beb14
+Description-de: Die »Embedded GNU C Library«: Binärdateien
+Homepage: http://www.eglibc.org
+Tag: devel::lang:c, devel::packaging, implemented-in::c, interface::commandline, role::program, scope::utility, special::auto-inst-parts, suite::gnu, works-with::text, works-with::unicode
+
+Package: libc6
+Status: install ok installed
+Priority: required
+Section: libs
+Installed-Size: 9340
+Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org>
+Architecture: i386
+Source: eglibc
+Version: 2.11.2-2
+Provides: glibc-2.11-1
+Depends: libc-bin (= 2.11.2-2), libgcc1
+Recommends: libc6-i686
+Suggests: glibc-doc, debconf | debconf-2.0, locales
+Conflicts: tzdata (<< 2007k-1), tzdata-etch
+Breaks: locales (<< 2.11), locales-all (<< 2.11), nscd (<< 2.11)
+Filename: pool/main/e/eglibc/libc6_2.11.2-2_i386.deb
+Size: 3877166
+MD5sum: 3d8fe972a359ad362ac1957c2687e5c2
+SHA1: cd901f3265254e40ad198b935877f546eeaa8403
+SHA256: e1bc3da1e11f9b742d05f927362e2079482db4186ff45af9f937d284e112e7e5
+Description-de: Die »Embedded GNU C Library«: Laufzeitbibliotheken
+Homepage: http://www.eglibc.org
+Tag: devel::lang:c, devel::library, implemented-in::c, protocol::ipv6, role::shared-lib, suite::gnu
+
+Package: mawk
+Status: install ok installed
+Priority: required
+Section: utils
+Installed-Size: 228
+Maintainer: Steve Langasek <vorlon@debian.org>
+Architecture: i386
+Version: 1.3.3-15
+Provides: awk
+Pre-Depends: libc6 (>= 2.1)
+Filename: pool/main/m/mawk/mawk_1.3.3-15_i386.deb
+Size: 81430
+MD5sum: e0f9e9903a862a52b5f107d560c4d8e0
+SHA1: cca3b3ea3a57b9c3c136fb538a4fb06a99d1a33e
+SHA256: 7449b10ffb6a8636a249ad6866188cad0040a6a446fb4a3a71d81fd136297ee6
+Description-de: Eine Muster- und Textverarbeitungssprache
+Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, use::filtering, use::scanning, works-with::text
+
+Package: gcc-4.5-base
+Status: install ok installed
+Priority: required
+Section: libs
+Installed-Size: 172
+Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org>
+Architecture: i386
+Source: gcc-4.5
+Version: 4.5.0-8
+Filename: pool/main/g/gcc-4.5/gcc-4.5-base_4.5.0-8_i386.deb
+Size: 117894
+MD5sum: f5850c42681fcfee3429a1b43da68433
+SHA1: 0548343feba69c4c01d5dbf147393d8dc27605ac
+SHA256: 04b60f5fe24b7397e3be233051615ff9addb66d4581578f67fde76f5d7f69f7a
+Description: The GNU Compiler Collection (base package)
+Homepage: http://gcc.gnu.org/
+
+Package: libgcc1
+Status: install ok installed
+Priority: required
+Section: libs
+Installed-Size: 148
+Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org>
+Architecture: i386
+Source: gcc-4.5 (4.5.0-8)
+Version: 1:4.5.0-8
+Depends: gcc-4.5-base (= 4.5.0-8), libc6 (>= 2.2.4)
+Filename: pool/main/g/gcc-4.5/libgcc1_4.5.0-8_i386.deb
+Size: 52190
+MD5sum: beda956a1dcdeffed11072c2d0f3eb83
+SHA1: 7117ec43eec7982a030fcc9a12d4772de3fcdba0
+SHA256: 1d10bd532adce8683b475fcc60c22300f717ef19bf84dc5bf43b07e504f85dcb
+Description: GCC support library
+Homepage: http://gcc.gnu.org/
+
diff --git a/test/integration/test-bug-590041-prefer-non-virtual-packages b/test/integration/test-bug-590041-prefer-non-virtual-packages
new file mode 100755
index 000000000..aa9e487e1
--- /dev/null
+++ b/test/integration/test-bug-590041-prefer-non-virtual-packages
@@ -0,0 +1,51 @@
+#!/bin/sh
+set -e
+
+. $(readlink -f $(dirname $0))/framework
+setupenvironment
+configarchitecture "i386" "armel"
+
+pkglibc6="Package: libc6
+Architecture: armel
+Version: 2.11.2-2~0.3
+Description: Embedded GNU C Library: Shared libraries
+Filename: pool/main/e/eglibc/libc6_2.11.2-2_armel.deb
+Installed-Size: 9740
+MD5sum: f5b878ce5fb8aa01a7927fa1460df537
+Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org>
+Priority: required
+SHA1: 0464d597dfbf949e8c17a42325b1f93fb4914afd
+SHA256: faca4a3d9ccff57568abf41f6cb81ddd835be7b5d8b0161e2d5f9a7f26aae3c0
+Section: libs
+Size: 4178958
+"
+
+pkglibdb1="Package: libdb1
+Architecture: i386
+Version: 2.1.3-13~0.3
+Replaces: libc6 (<< 2.2.5-13~0.3)
+Description: The Berkeley database routines [glibc 2.0/2.1 compatibility]
+Filename: pool/main/d/db1-compat/libdb1-compat_2.1.3-13_armel.deb
+Installed-Size: 136
+MD5sum: 4043f176ab2b40b0c01bc1211b8c103c
+Maintainer: Colin Watson <cjwatson@debian.org>
+Priority: extra
+SHA1: b9396fdd2e3e8d1d4ba9e74e7346075852d85666
+SHA256: f17decaa28d1db3eeb9eb17bebe50d437d293a509bcdd7cdfd3ebb56f5de3cea
+Section: oldlibs
+Size: 44168
+"
+
+cat <<-EOF >aptarchive/Packages
+$pkglibc6
+$pkglibdb1
+EOF
+
+setupflataptarchive
+
+testshowvirtual libc6:i386
+testequal "$pkglibc6" aptcache show libc6:armel
+testequal "$pkglibc6" aptcache show libc6
+testequal "$pkglibdb1" aptcache show libdb1:i386
+testnopackage libdb1:armel
+testequal "$pkglibdb1" aptcache show libdb1
diff --git a/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order
new file mode 100755
index 000000000..17ce50295
--- /dev/null
+++ b/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order
@@ -0,0 +1,98 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+setupflataptarchive
+
+pkgbasefile="Package: base-files
+Status: install ok installed
+Essential: yes
+Priority: required
+Section: admin
+Installed-Size: 472
+Maintainer: Santiago Vila <sanvila@debian.org>
+Architecture: i386
+Version: 5.8
+Replaces: base, dpkg (<= 1.15.0), miscutils
+Provides: base
+Filename: pool/main/b/base-files/base-files_5.8_i386.deb
+Size: 73986
+MD5sum: 8489687ce10e656babd467c9ee389349
+Description-de: Verschiedene Dateien für das Basis-System von Debian"
+
+predependsgawk() {
+# rm rootdir/var/cache/apt/*.bin
+ cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status
+ echo "$pkgbasefile
+Pre-Depends: $1
+" >> rootdir/var/lib/dpkg/status
+ testequal "Inst gawk (1:3.1.7.dfsg-5 localhost [i386])
+Conf gawk (1:3.1.7.dfsg-5 localhost [i386])
+Remv mawk [1.3.3-15]" aptget install gawk mawk- -sqq -o PreDepends=$(echo "$1" | sed 's/ //g')
+}
+
+predependsgawk "gawk | mawk"
+predependsgawk "mawk | gawk"
+
+predependsgawk "aawk | mawk | gawk"
+predependsgawk "aawk | gawk | mawk"
+
+predependsgawk "gawk | awk"
+predependsgawk "aawk | gawk | awk"
+
+predependsgawk "mawk | awk"
+
+predependsgawk "awk | gawk"
+predependsgawk "awk | gawk | aawk"
+
+predependsgawk "awk | mawk"
+
+predependsgawk "aawk | awk"
+predependsgawk "awk | aawk"
+
+predependsgawk "awk"
+
+predependsgawk2() {
+# rm rootdir/var/cache/apt/*.bin
+ cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status
+ echo "$pkgbasefile
+Pre-Depends: $1
+" >> rootdir/var/lib/dpkg/status
+ testequalor2 "Inst coolstuff (1-1 localhost [all])
+Conf coolstuff (1-1 localhost [all])
+Inst gawk2 (1:3.1.7.dfsg-5 localhost [i386])
+Conf gawk2 (1:3.1.7.dfsg-5 localhost [i386])
+Remv mawk [1.3.3-15]" "Inst coolstuff (1-1 localhost [all])
+Inst gawk2 (1:3.1.7.dfsg-5 localhost [i386])
+Conf coolstuff (1-1 localhost [all])
+Conf gawk2 (1:3.1.7.dfsg-5 localhost [i386])
+Remv mawk [1.3.3-15]" aptget install gawk2 mawk- -sqq -o PreDepends=$(echo "$1" | sed 's/ //g')
+}
+
+predependsgawk2 "gawk2 | mawk"
+predependsgawk2 "mawk | gawk2"
+
+predependsgawk2 "aawk | mawk | gawk2"
+predependsgawk2 "aawk | gawk2 | mawk"
+
+predependsgawk2 "gawk2 | awk"
+predependsgawk2 "aawk | gawk2 | awk"
+
+predependsgawk2 "mawk | awk"
+
+predependsgawk2 "awk | gawk2"
+predependsgawk2 "awk | gawk2 | aawk"
+
+predependsgawk2 "awk | mawk"
+
+predependsgawk2 "aawk | awk"
+predependsgawk2 "awk | aawk"
+
+predependsgawk2 "awk"
+
+
+# aptget install gawk2 mawk- -s #-o Debug::pkgOrderList=1 #-o Debug::pkgPackageManager=1
diff --git a/test/libapt/commandlineasstring_test.cc b/test/libapt/commandlineasstring_test.cc
new file mode 100644
index 000000000..a38957d7e
--- /dev/null
+++ b/test/libapt/commandlineasstring_test.cc
@@ -0,0 +1,39 @@
+#include <apt-pkg/cmndline.h>
+#include <apt-pkg/configuration.h>
+
+#include <string>
+
+#include "assert.h"
+
+class CLT: public CommandLine {
+
+ public:
+ std::string static AsString(const char * const * const argv,
+ unsigned int const argc) {
+ std::string const static conf = "Commandline::AsString";
+ _config->Clear(conf);
+ SaveInConfig(argc, argv);
+ return _config->Find(conf);
+ }
+};
+
+#define CMD(y,z) equals(CLT::AsString(argv, y), z);
+
+int main() {
+ {
+ const char* const argv[] = {"apt-get", "install", "-sf"};
+ CMD(3, "apt-get install -sf");
+ }
+ {
+ const char* const argv[] = {"apt-cache", "-s", "apt", "-so", "Debug::test=Test"};
+ CMD(5, "apt-cache -s apt -so Debug::test=Test");
+ }
+ {
+ const char* const argv[] = {"apt-cache", "-s", "apt", "-so", "Debug::test=Das ist ein Test"};
+ CMD(5, "apt-cache -s apt -so Debug::test=\"Das ist ein Test\"");
+ }
+ {
+ const char* const argv[] = {"apt-cache", "-s", "apt", "--hallo", "test=1.0"};
+ CMD(5, "apt-cache -s apt --hallo test=1.0");
+ }
+}
diff --git a/test/libapt/compareversion_test.cc b/test/libapt/compareversion_test.cc
new file mode 100644
index 000000000..b6213e84c
--- /dev/null
+++ b/test/libapt/compareversion_test.cc
@@ -0,0 +1,123 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+/* ######################################################################
+
+ Version Test - Simple program to run through a file and comare versions.
+
+ Each version is compared and the result is checked against an expected
+ result in the file. The format of the file is
+ a b Res
+ Where Res is -1, 1, 0. dpkg -D=1 --compare-versions a "<" b can be
+ used to determine what Res should be. # at the start of the line
+ is a comment and blank lines are skipped
+
+ The runner will also call dpkg --compare-versions to check if APT and
+ dpkg have (still) the same idea.
+
+ ##################################################################### */
+ /*}}}*/
+#include <apt-pkg/macros.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/version.h>
+#include <apt-pkg/debversion.h>
+#include <apt-pkg/fileutl.h>
+#include <iostream>
+#include <fstream>
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+using namespace std;
+
+bool callDPkg(const char *val, const char *ref, const char &op) {
+ pid_t Process = ExecFork();
+ if (Process == 0)
+ {
+ const char * args[6];
+ args[0] = "/usr/bin/dpkg";
+ args[1] = "--compare-versions";
+ args[2] = val;
+ args[3] = (op == 1) ? ">>" : ( (op == 0) ? "=" : "<<");
+ args[4] = ref;
+ args[5] = 0;
+ execv(args[0], (char**) args);
+ exit(1);
+ }
+ int Ret;
+ waitpid(Process, &Ret, 0);
+ return WIFEXITED(Ret) == true && WEXITSTATUS(Ret) == 0;
+}
+
+void assertVersion(int const &CurLine, string const &A, string const &B, int const &Expected) {
+ int Res = debVS.CmpVersion(A.c_str(), B.c_str());
+ bool const dpkg = callDPkg(A.c_str(),B.c_str(), Expected);
+ Res = (Res < 0) ? -1 : ( (Res > 0) ? 1 : Res);
+
+ if (Res != Expected)
+ _error->Error("Comparison failed on line %u. '%s' '%s' '%s' %i != %i",CurLine,A.c_str(),((Expected == 1) ? "<<" : ( (Expected == 0) ? "=" : ">>")) ,B.c_str(),Res,Expected);
+ if (dpkg == false)
+ _error->Error("DPkg differ with line: %u. '%s' '%s' '%s' == false",CurLine,A.c_str(),((Expected == 1) ? "<<" : ( (Expected == 0) ? "=" : ">>")),B.c_str());
+}
+
+bool RunTest(const char *File)
+{
+ ifstream F(File,ios::in);
+ if (!F != 0)
+ return false;
+
+ char Buffer[300];
+ int CurLine = 0;
+
+ while (1)
+ {
+ F.getline(Buffer,sizeof(Buffer));
+ CurLine++;
+ if (F.eof() != 0)
+ return true;
+ if (!F != 0)
+ return _error->Error("Line %u in %s is too long",CurLine,File);
+
+ // Comment
+ if (Buffer[0] == '#' || Buffer[0] == 0)
+ continue;
+
+ // First version
+ char *I;
+ char *Start = Buffer;
+ for (I = Buffer; *I != 0 && *I != ' '; I++);
+ string A(Start, I - Start);
+
+ if (*I == 0)
+ return _error->Error("Invalid line %u",CurLine);
+
+ // Second version
+ I++;
+ Start = I;
+ for (I = Start; *I != 0 && *I != ' '; I++);
+ string B(Start,I - Start);
+
+ if (*I == 0 || I[1] == 0)
+ return _error->Error("Invalid line %u",CurLine);
+
+ // Result
+ I++;
+ int const Expected = atoi(I);
+ assertVersion(CurLine, A, B, Expected);
+ // Check the reverse as well
+ assertVersion(CurLine, B, A, Expected*-1);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ if (argc <= 1)
+ RunTest("../versions.lst");
+ else
+ RunTest(argv[1]);
+
+ // Print any errors or warnings found
+ _error->DumpErrors();
+ return 0;
+}
diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc
new file mode 100644
index 000000000..1500caeed
--- /dev/null
+++ b/test/libapt/getarchitectures_test.cc
@@ -0,0 +1,61 @@
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/configuration.h>
+
+#include "assert.h"
+#include <string>
+#include <vector>
+
+#include <iostream>
+
+// simple helper to quickly output a vector of strings
+void dumpVector(std::vector<std::string> vec) {
+ for (std::vector<std::string>::const_iterator v = vec.begin();
+ v != vec.end(); v++)
+ std::cout << *v << std::endl;
+}
+
+int main(int argc,char *argv[])
+{
+ std::vector<std::string> vec;
+
+ _config->Set("APT::Architectures::1", "i386");
+ _config->Set("APT::Architectures::2", "amd64");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 2);
+ equals(vec[0], "i386");
+ equals(vec[1], "amd64");
+
+ _config->Set("APT::Architecture", "i386");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 2);
+ equals(vec[0], "i386");
+ equals(vec[1], "amd64");
+
+ _config->Set("APT::Architectures::2", "");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 1);
+ equals(vec[0], "i386");
+
+ _config->Set("APT::Architecture", "armel");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 2);
+ equals(vec[0], "i386");
+ equals(vec[1], "armel");
+
+ _config->Set("APT::Architectures::2", "amd64");
+ _config->Set("APT::Architectures::3", "i386");
+ _config->Set("APT::Architectures::4", "armel");
+ _config->Set("APT::Architectures::5", "i386");
+ _config->Set("APT::Architectures::6", "amd64");
+ _config->Set("APT::Architectures::7", "armel");
+ _config->Set("APT::Architectures::8", "armel");
+ _config->Set("APT::Architectures::9", "amd64");
+ _config->Set("APT::Architectures::10", "amd64");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 3);
+ equals(vec[0], "i386");
+ equals(vec[1], "amd64");
+ equals(vec[2], "armel");
+
+ return 0;
+}
diff --git a/test/libapt/globalerror_test.cc b/test/libapt/globalerror_test.cc
new file mode 100644
index 000000000..b2752255f
--- /dev/null
+++ b/test/libapt/globalerror_test.cc
@@ -0,0 +1,77 @@
+#include <apt-pkg/error.h>
+
+#include "assert.h"
+#include <string>
+
+int main(int argc,char *argv[])
+{
+ equals(_error->empty(), true);
+ equals(_error->PendingError(), false);
+ equals(_error->Notice("%s Notice", "A"), false);
+ equals(_error->empty(), true);
+ equals(_error->empty(GlobalError::DEBUG), false);
+ equals(_error->PendingError(), false);
+ equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false);
+ equals(_error->PendingError(), true);
+ std::string text;
+ equals(_error->PopMessage(text), false);
+ equals(_error->PendingError(), true);
+ equals(text, "A Notice");
+ equals(_error->PopMessage(text), true);
+ equals(text, "Something horrible happend 2 times");
+ equals(_error->empty(GlobalError::DEBUG), true);
+ equals(_error->PendingError(), false);
+ equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false);
+ equals(_error->PendingError(), true);
+ equals(_error->empty(GlobalError::FATAL), false);
+ _error->Discard();
+
+ equals(_error->empty(), true);
+ equals(_error->PendingError(), false);
+ equals(_error->Notice("%s Notice", "A"), false);
+ equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false);
+ equals(_error->PendingError(), true);
+ equals(_error->empty(GlobalError::NOTICE), false);
+ _error->PushToStack();
+ equals(_error->empty(GlobalError::NOTICE), true);
+ equals(_error->PendingError(), false);
+ equals(_error->Warning("%s Warning", "A"), false);
+ equals(_error->empty(GlobalError::ERROR), true);
+ equals(_error->PendingError(), false);
+ _error->RevertToStack();
+ equals(_error->empty(GlobalError::ERROR), false);
+ equals(_error->PendingError(), true);
+ equals(_error->PopMessage(text), false);
+ equals(_error->PendingError(), true);
+ equals(text, "A Notice");
+ equals(_error->PopMessage(text), true);
+ equals(text, "Something horrible happend 2 times");
+ equals(_error->PendingError(), false);
+ equals(_error->empty(), true);
+
+ equals(_error->Notice("%s Notice", "A"), false);
+ equals(_error->Error("%s horrible %s %d times", "Something", "happend", 2), false);
+ equals(_error->PendingError(), true);
+ equals(_error->empty(GlobalError::NOTICE), false);
+ _error->PushToStack();
+ equals(_error->empty(GlobalError::NOTICE), true);
+ equals(_error->PendingError(), false);
+ equals(_error->Warning("%s Warning", "A"), false);
+ equals(_error->empty(GlobalError::ERROR), true);
+ equals(_error->PendingError(), false);
+ _error->MergeWithStack();
+ equals(_error->empty(GlobalError::ERROR), false);
+ equals(_error->PendingError(), true);
+ equals(_error->PopMessage(text), false);
+ equals(_error->PendingError(), true);
+ equals(text, "A Notice");
+ equals(_error->PopMessage(text), true);
+ equals(text, "Something horrible happend 2 times");
+ equals(_error->PendingError(), false);
+ equals(_error->empty(), false);
+ equals(_error->PopMessage(text), false);
+ equals(text, "A Warning");
+ equals(_error->empty(), true);
+
+ return 0;
+}
diff --git a/test/libapt/makefile b/test/libapt/makefile
index 08f581e6d..50058262e 100644
--- a/test/libapt/makefile
+++ b/test/libapt/makefile
@@ -12,6 +12,11 @@ SLIBS = -lapt-pkg
SOURCE = getlanguages_test.cc
include $(PROGRAM_H)
+PROGRAM = getArchitectures${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = getarchitectures_test.cc
+include $(PROGRAM_H)
+
# Program for testing ParseDepends
PROGRAM = ParseDepends${BASENAME}
SLIBS = -lapt-pkg
@@ -23,3 +28,21 @@ PROGRAM = GetListOfFilesInDir${BASENAME}
SLIBS = -lapt-pkg
SOURCE = getlistoffilesindir_test.cc
include $(PROGRAM_H)
+
+# Program for testing CommandLine reconstruction
+PROGRAM = CommandlineAsString${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = commandlineasstring_test.cc
+include $(PROGRAM_H)
+
+# Program for testing debians version comparing
+PROGRAM = CompareVersion${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = compareversion_test.cc
+include $(PROGRAM_H)
+
+# test the GlobalError stack class
+PROGRAM = GlobalError${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = globalerror_test.cc
+include $(PROGRAM_H)
diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc
index b7befa561..7b496878d 100644
--- a/test/libapt/parsedepends_test.cc
+++ b/test/libapt/parsedepends_test.cc
@@ -21,6 +21,12 @@ int main(int argc,char *argv[]) {
"apt (>= 0.7.25), "
"not-for-me [ !dsk ], "
"only-for-me [ dsk ], "
+ "any-for-me [ any ], "
+ "not-for-darwin [ !darwin-any ], "
+ "cpu-for-me [ any-dsk ], "
+ "os-for-me [ linux-any ], "
+ "cpu-not-for-me [ any-amd64 ], "
+ "os-not-for-me [ kfreebsd-any ], "
"overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), "
;
@@ -100,6 +106,68 @@ test:
Start++;
}
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("any-for-me", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::NoOp, Op);
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("not-for-darwin", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::NoOp, Op);
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("cpu-for-me", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::NoOp, Op);
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("os-for-me", Package);
+ equals("", Version);
+ equals(Null | pkgCache::Dep::NoOp, Op);
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("", Package); // cpu-not-for-me
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseArchFlags == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
+ equals("", Package); // os-not-for-me
+ } else {
+ equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch);
if (StripMultiArch == true)
equals("overlord-dev", Package);
diff --git a/test/libapt/run-tests.sh b/test/libapt/run-tests
index f9df1af5f..0f55f7386 100755
--- a/test/libapt/run-tests.sh
+++ b/test/libapt/run-tests
@@ -1,10 +1,12 @@
#!/bin/sh
set -e
-echo "Compiling the tests ..."
-make
-echo "Running all testcases ..."
-LDPATH=$(pwd)/../../build/bin
+local DIR=$(readlink -f $(dirname $0))
+echo "Compiling the tests …"
+test -d "$DIR/../../build/obj/test/libapt/" || mkdir -p "$DIR/../../build/obj/test/libapt/"
+$(cd $DIR && make)
+echo "Running all testcases …"
+LDPATH="$DIR/../../build/bin"
EXT="_libapt_test"
for testapp in $(ls ${LDPATH}/*$EXT)
do
diff --git a/test/makefile b/test/makefile
index fb9123d0a..52adb96a2 100644
--- a/test/makefile
+++ b/test/makefile
@@ -25,13 +25,6 @@ SOURCE = scratch.cc
include $(PROGRAM_H)
# Version compare tester
-PROGRAM=versiontest
-SLIBS = -lapt-pkg
-LIB_MAKES = apt-pkg/makefile
-SOURCE = versiontest.cc
-include $(PROGRAM_H)
-
-# Version compare tester
PROGRAM=testextract
SLIBS = -lapt-pkg -lapt-inst
LIB_MAKES = apt-pkg/makefile apt-inst/makefile
@@ -75,7 +68,7 @@ SOURCE = test_udevcdrom.cc
include $(PROGRAM_H)
# Program for checking rpm versions
-PROGRAM=rpmver
-SLIBS = -lapt-pkg -lrpm
-SOURCE = rpmver.cc
-include $(PROGRAM_H)
+#PROGRAM=rpmver
+#SLIBS = -lapt-pkg -lrpm
+#SOURCE = rpmver.cc
+#include $(PROGRAM_H)
diff --git a/test/pre-upload-check.py b/test/pre-upload-check.py
index 268b3d672..f9da8f941 100755
--- a/test/pre-upload-check.py
+++ b/test/pre-upload-check.py
@@ -4,6 +4,8 @@ import sys
import os
import glob
import os.path
+import shutil
+import time
from subprocess import call, PIPE
import unittest
@@ -11,7 +13,102 @@ import unittest
stdout = os.open("/dev/null",0) #sys.stdout
stderr = os.open("/dev/null",0) # sys.stderr
-apt_args = [] # ["-o","Debug::pkgAcquire::Auth=true"]
+apt_args = []
+#apt_args = ["-o","Debug::pkgAcquire::Auth=true"]
+
+class testAptAuthenticationReliability(unittest.TestCase):
+ """
+ test if the spec https://wiki.ubuntu.com/AptAuthenticationReliability
+ is properly implemented
+ """
+ #apt = "../bin/apt-get"
+ apt = "apt-get"
+
+ def setUp(self):
+ if os.path.exists("/tmp/autFailure"):
+ os.unlink("/tmp/authFailure");
+ if os.path.exists("/tmp/autFailure2"):
+ os.unlink("/tmp/authFailure2");
+ def testRepositorySigFailure(self):
+ """
+ test if a repository that used to be authenticated and fails on
+ apt-get update refuses to update and uses the old state
+ """
+ # copy valid signatures into lists (those are ok, even
+ # if the name is "-broken-" ...
+ for f in glob.glob("./authReliability/lists/*"):
+ shutil.copy(f,"/var/lib/apt/lists")
+ # ensure we do *not* get a I-M-S hit
+ os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (0,0))
+ res = call([self.apt,
+ "update",
+ "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure",
+ "-o",'APT::Update::Auth-Failure::=touch /tmp/authFailure',
+ ] + apt_args,
+ stdout=stdout, stderr=stderr)
+ self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"),
+ "The gpg file disappeared, this should not happen")
+ self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"),
+ "The Packages file disappeared, this should not happen")
+ self.assert_(os.path.exists("/tmp/authFailure"),
+ "The APT::Update::Auth-Failure script did not run (1)")
+ # the same with i-m-s hit this time
+ for f in glob.glob("./authReliability/lists/*"):
+ shutil.copy(f,"/var/lib/apt/lists")
+ os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (time.time(),time.time()))
+ res = call([self.apt,
+ "update",
+ "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure",
+ "-o",'APT::Update::Auth-Failure::=touch /tmp/authFailure2',
+ ] + apt_args,
+ stdout=stdout, stderr=stderr)
+ self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"),
+ "The gpg file disappeared, this should not happen")
+ self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"),
+ "The Packages file disappeared, this should not happen")
+ self.assert_(os.path.exists("/tmp/authFailure2"),
+ "The APT::Update::Auth-Failure script did not run (2)")
+ def testRepositorySigGood(self):
+ """
+ test that a regular repository with good data stays good
+ """
+ res = call([self.apt,
+ "update",
+ "-o","Dir::Etc::sourcelist=./authReliability/sources.list.good"
+ ] + apt_args,
+ stdout=stdout, stderr=stderr)
+ self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg"),
+ "The gpg file disappeared after a regular download, this should not happen")
+ self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages"),
+ "The Packages file disappeared, this should not happen")
+ # test good is still good after non I-M-S hit and a previous files in lists/
+ for f in glob.glob("./authReliability/lists/*"):
+ shutil.copy(f,"/var/lib/apt/lists")
+ # ensure we do *not* get a I-M-S hit
+ os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (0,0))
+ res = call([self.apt,
+ "update",
+ "-o","Dir::Etc::sourcelist=./authReliability/sources.list.good"
+ ] + apt_args,
+ stdout=stdout, stderr=stderr)
+ self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg"),
+ "The gpg file disappeared after a I-M-S hit, this should not happen")
+ self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages"),
+ "The Packages file disappeared, this should not happen")
+ # test good is still good after I-M-S hit
+ for f in glob.glob("./authReliability/lists/*"):
+ shutil.copy(f,"/var/lib/apt/lists")
+ # ensure we do get a I-M-S hit
+ os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (time.time(),time.time()))
+ res = call([self.apt,
+ "update",
+ "-o","Dir::Etc::sourcelist=./authReliability/sources.list.good"
+ ] + apt_args,
+ stdout=stdout, stderr=stderr)
+ self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg"),
+ "The gpg file disappeared, this should not happen")
+ self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages"),
+ "The Packages file disappeared, this should not happen")
class testAuthentication(unittest.TestCase):
@@ -95,6 +192,20 @@ class testAuthentication(unittest.TestCase):
self.assert_(len(glob.glob("/var/lib/apt/lists/partial/*")) == 0,
"partial/ dir has leftover files: %s" % glob.glob("/var/lib/apt/lists/partial/*"))
+ def testValid(self):
+ for f in glob.glob("testsources.list/sources.list*validuntil*"):
+ self._cleanup()
+ (prefix, testtype, result) = f.split("-")
+ expected_res = self._expectedRes(result)
+ cmd = ["update"]
+ res = call([self.apt,"-o","Dir::Etc::sourcelist=./%s" % f]+cmd+apt_args,
+ stdout=stdout, stderr=stderr)
+ self.assert_(res == expected_res,
+ "test '%s' failed (got %s expected %s" % (f,res,expected_res))
+ if expected_res == 0:
+ self.assert_(len(glob.glob("/var/lib/apt/lists/partial/*")) == 0,
+ "partial/ dir has leftover files: %s" % glob.glob("/var/lib/apt/lists/partial/*"))
+
class testLocalRepositories(unittest.TestCase):
" test local repository regressions "
@@ -149,6 +260,7 @@ if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "-v":
stdout = sys.stdout
stderr = sys.stderr
+
+ # run only one for now
+ #unittest.main(defaultTest="testAptAuthenticationReliability")
unittest.main()
-
-
diff --git a/test/test-indexes.sh b/test/test-indexes.sh
new file mode 100755
index 000000000..dad3e1fb2
--- /dev/null
+++ b/test/test-indexes.sh
@@ -0,0 +1,226 @@
+#!/bin/sh -e
+
+# Test behaviour of index retrieval and usage, in particular with uncompressed
+# and gzip compressed indexes.
+# Author: Martin Pitt <martin.pitt@ubuntu.com>
+# (C) 2010 Canonical Ltd.
+
+BUILDDIR=$(readlink -f $(dirname $0)/../build)
+
+TEST_SOURCE="http://ftp.debian.org/debian unstable contrib"
+GPG_KEYSERVER=gpg-keyserver.de
+# should be a small package with dependencies satisfiable in TEST_SOURCE, i. e.
+# ideally no depends at all
+TEST_PKG="python-psyco-doc"
+
+export LD_LIBRARY_PATH=$BUILDDIR/bin
+
+OPTS="-qq -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true"
+DEBUG=""
+#DEBUG="-o Debug::pkgCacheGen=true"
+#DEBUG="-o Debug::pkgAcquire=true"
+APT_GET="$BUILDDIR/bin/apt-get $OPTS $DEBUG"
+APT_CACHE="$BUILDDIR/bin/apt-cache $OPTS $DEBUG"
+APT_FTPARCHIVE="$BUILDDIR/bin/apt-ftparchive"
+
+[ -x "$BUILDDIR/bin/apt-get" ] || {
+ echo "please build the tree first" >&2
+ exit 1
+}
+
+check_update() {
+ echo "--- apt-get update $@ (no trusted keys)"
+
+ rm -f etc/apt/trusted.gpg etc/apt/secring.gpg
+ touch etc/apt/trusted.gpg etc/apt/secring.gpg
+ find var/lib/apt/lists/ -type f | xargs -r rm
+
+ # first attempt should fail, no trusted GPG key
+ out=$($APT_GET "$@" update 2>&1)
+ echo "$out" | grep -q NO_PUBKEY
+ key=$(echo "$out" | sed -n '/NO_PUBKEY/ { s/^.*NO_PUBKEY \([[:alnum:]]\+\)$/\1/; p}')
+
+ # get keyring
+ gpg -q --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $key
+
+ # now it should work
+ echo "--- apt-get update $@ (with trusted keys)"
+ find var/lib/apt/lists/ -type f | xargs -r rm
+ $APT_GET "$@" update
+}
+
+# if $1 == "compressed", check that we have compressed indexes, otherwise
+# uncompressed ones
+check_indexes() {
+ echo "--- only ${1:-uncompressed} index files present"
+ local F
+ if [ "$1" = "compressed" ]; then
+ ! test -e var/lib/apt/lists/*_Packages || F=1
+ ! test -e var/lib/apt/lists/*_Sources || F=1
+ test -e var/lib/apt/lists/*_Packages.gz || F=1
+ test -e var/lib/apt/lists/*_Sources.gz || F=1
+ else
+ test -e var/lib/apt/lists/*_Packages || F=1
+ test -e var/lib/apt/lists/*_Sources || F=1
+ ! test -e var/lib/apt/lists/*_Packages.gz || F=1
+ ! test -e var/lib/apt/lists/*_Sources.gz || F=1
+ fi
+
+ if [ -n "$F" ]; then
+ ls -laR var/lib/apt/lists/
+ exit 1
+ fi
+}
+
+# test apt-cache commands
+check_cache() {
+ echo "--- apt-cache commands"
+
+ $APT_CACHE show $TEST_PKG | grep -q ^Version:
+ # again (with cache)
+ $APT_CACHE show $TEST_PKG | grep -q ^Version:
+ rm var/cache/apt/*.bin
+ $APT_CACHE policy $TEST_PKG | egrep -q '500 (http://|file:/)'
+ # again (with cache)
+ $APT_CACHE policy $TEST_PKG | egrep -q '500 (http://|file:/)'
+
+ TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print $2}'`
+ rm var/cache/apt/*.bin
+ $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
+ # again (with cache)
+ $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
+}
+
+# test apt-get install
+check_install() {
+ echo "--- apt-get install"
+
+ $APT_GET install -d $TEST_PKG
+ test -e var/cache/apt/archives/$TEST_PKG*.deb
+ $APT_GET clean
+ ! test -e var/cache/apt/archives/$TEST_PKG*.deb
+}
+
+# test apt-get source
+check_get_source() {
+ echo "--- apt-get source"
+ # quiesce: it'll complain about not being able to verify the signature
+ $APT_GET source $TEST_PKG >/dev/null 2>&1
+ test -f $TEST_SRC_*.dsc
+ test -d $TEST_SRC-*
+ rm -r $TEST_SRC*
+}
+
+############################################################################
+# main
+############################################################################
+
+echo "===== building sandbox ====="
+WORKDIR=$(mktemp -d)
+trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+cd $WORKDIR
+
+rm -fr etc var
+rm -f home
+ln -s /home home
+mkdir -p etc/apt/preferences.d etc/apt/trusted.gpg.d etc/apt/apt.conf.d var/cache/apt/archives/partial var/lib/apt/lists/partial var/lib/dpkg
+cp /etc/apt/trusted.gpg etc/apt
+touch var/lib/dpkg/status
+echo "deb $TEST_SOURCE" > etc/apt/sources.list
+echo "deb-src $TEST_SOURCE" >> etc/apt/sources.list
+
+# specifying -o RootDir at the command line does not work for
+# etc/apt/apt.conf.d/ since it is parsed after pkgInitConfig(); $APT_CONFIG is
+# checked first, so this works
+echo "RootDir \"$WORKDIR\";" > apt_config
+export APT_CONFIG=`pwd`/apt_config
+
+echo "===== uncompressed indexes ====="
+check_update
+check_indexes
+check_cache
+check_install
+check_get_source
+
+echo "--- apt-get update with preexisting indexes"
+$APT_GET update
+check_indexes
+check_cache
+
+echo "--- apt-get update with preexisting indexes and pdiff mode"
+$APT_GET -o Acquire::PDiffs=true update
+check_indexes
+check_cache
+
+echo "===== compressed indexes (CLI option) ====="
+check_update -o Acquire::GzipIndexes=true
+check_indexes compressed
+check_cache
+check_install
+check_get_source
+
+echo "--- apt-get update with preexisting indexes"
+$APT_GET -o Acquire::GzipIndexes=true update
+check_indexes compressed
+check_cache
+
+echo "--- apt-get update with preexisting indexes and pdiff mode"
+$APT_GET -o Acquire::GzipIndexes=true -o Acquire::PDiffs=true update
+check_indexes compressed
+check_cache
+
+echo "===== compressed indexes (apt.conf.d option) ====="
+cat <<EOF > etc/apt/apt.conf.d/02compress-indexes
+Acquire::GzipIndexes "true";
+Acquire::CompressionTypes::Order:: "gz";
+EOF
+
+check_update
+check_indexes compressed
+check_cache
+check_install
+check_get_source
+
+echo "--- apt-get update with preexisting indexes"
+$APT_GET update
+check_indexes compressed
+check_cache
+
+echo "--- apt-get update with preexisting indexes and pdiff mode"
+$APT_GET -o Acquire::PDiffs=true update
+check_indexes compressed
+check_cache
+
+rm etc/apt/apt.conf.d/02compress-indexes
+
+echo "==== apt-ftparchive ===="
+mkdir arch
+$APT_GET install -d $TEST_PKG
+cp var/cache/apt/archives/$TEST_PKG*.deb arch/
+cd arch
+$APT_GET source -d $TEST_PKG >/dev/null 2>&1
+$APT_FTPARCHIVE packages . | gzip -9 > Packages.gz
+$APT_FTPARCHIVE sources . | gzip -9 > Sources.gz
+cd ..
+
+echo "deb file://$WORKDIR/arch /
+deb-src file://$WORKDIR/arch /" > etc/apt/sources.list
+$APT_GET clean
+
+echo "==== uncompressed indexes from local file:// archive ===="
+echo "--- apt-get update"
+$APT_GET update
+check_indexes
+check_cache
+check_get_source
+
+echo "==== compressed indexes from local file:// archive ===="
+echo "--- apt-get update"
+$APT_GET -o Acquire::GzipIndexes=true update
+# EXFAIL: file:/ URIs currently decompress even with above option
+#check_indexes compressed
+check_indexes
+check_cache
+check_get_source
+
+echo "===== ALL TESTS PASSED ====="
diff --git a/test/testsources.list/sources.list.all-validuntil-broken b/test/testsources.list/sources.list.all-validuntil-broken
new file mode 100644
index 000000000..bab59bb81
--- /dev/null
+++ b/test/testsources.list/sources.list.all-validuntil-broken
@@ -0,0 +1 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/all-validuntil-broken/ /
diff --git a/test/versions.lst b/test/versions.lst
index efc19c4f0..517214151 100644
--- a/test/versions.lst
+++ b/test/versions.lst
@@ -10,10 +10,11 @@
1.3 1.2.2 1
# Important attributes
-- . -1
-p - -1
-a - -1
-z - -1
+# disabled as dpkg --compare-versions doesn't like them…
+#- . -1
+#p - -1
+#a - -1
+#z - -1
a . -1
z . -1
@@ -22,6 +23,10 @@ z . -1
1:1.25-4 1:1.25-8 -1
0:1.18.36 1.18.36 0
+# native version
+1.18.36 1.18.35 1
+0:1.18.36 1.18.35 1
+
# Funky, but allowed, characters in upstream version
9:1.18.36:5.4-20 10:0.5.1-22 -1
9:1.18.36:5.4-20 9:1.18.36:5.5-1 -1
@@ -49,3 +54,54 @@ III-alpha9.8 III-alpha9.8-1.5 -1
# #205960
3.0~rc1-1 3.0-1 -1
+
+# #573592 - debian policy 5.6.12
+1.0 1.0-0 0
+0.2 1.0-0 -1
+1.0 1.0-0+b1 -1
+1.0 1.0-0~ 1
+
+# if a version includes a dash
+# it should be the debrev dash - policy says so…
+0:0-0-0 0-0 1
+
+# do we like strange versions? Yes we like strange versions…
+0 0 0
+0 00 0
+
+# "steal" the testcases from cupt
+1.2.3 1.2.3 0 # identical
+4.4.3-2 4.4.3-2 0 # identical
+1:2ab:5 1:2ab:5 0 # this is correct...
+7:1-a:b-5 7:1-a:b-5 0 # and this
+57:1.2.3abYZ+~-4-5 57:1.2.3abYZ+~-4-5 0 # and those too
+1.2.3 0:1.2.3 0 # zero epoch
+1.2.3 1.2.3-0 0 # zero revision
+009 9 0 # zeroes...
+009ab5 9ab5 0 # there as well
+1.2.3 1.2.3-1 -1 # added non-zero revision
+1.2.3 1.2.4 -1 # just bigger
+1.2.4 1.2.3 1 # order doesn't matter
+1.2.24 1.2.3 1 # bigger, eh?
+0.10.0 0.8.7 1 # bigger, eh?
+3.2 2.3 1 # major number rocks
+1.3.2a 1.3.2 1 # letters rock
+0.5.0~git 0.5.0~git2 -1 # numbers rock
+2a 21 -1 # but not in all places
+1.3.2a 1.3.2b -1 # but there is another letter
+1:1.2.3 1.2.4 1 # epoch rocks
+1:1.2.3 1:1.2.4 -1 # bigger anyway
+1.2a+~bCd3 1.2a++ -1 # tilde doesn't rock
+1.2a+~bCd3 1.2a+~ 1 # but first is longer!
+5:2 304-2 1 # epoch rocks
+5:2 304:2 -1 # so big epoch?
+25:2 3:2 1 # 25 > 3, obviously
+1:2:123 1:12:3 -1 # 12 > 2
+1.2-5 1.2-3-5 -1 # 1.2 < 1.2-3
+5.10.0 5.005 1 # preceding zeroes don't matters
+3a9.8 3.10.2 -1 # letters are before all letter symbols
+3a9.8 3~10 1 # but after the tilde
+1.4+OOo3.0.0~ 1.4+OOo3.0.0-4 -1 # another tilde check
+2.4.7-1 2.4.7-z -1 # revision comparing
+1.002-1+b2 1.00 1 # whatever...
+2.2.4-47978_Debian_lenny 2.2.4-47978_Debian_lenny 0 # and underscore...
diff --git a/test/versiontest.cc b/test/versiontest.cc
deleted file mode 100644
index 4ede4b280..000000000
--- a/test/versiontest.cc
+++ /dev/null
@@ -1,233 +0,0 @@
-// -*- mode: cpp; mode: fold -*-
-// Description /*{{{*/
-// $Id: versiontest.cc,v 1.5 2003/08/18 15:55:19 mdz Exp $
-/* ######################################################################
-
- Version Test - Simple program to run through a file and comare versions.
-
- Each version is compared and the result is checked against an expected
- result in the file. The format of the file is
- a b Res
- Where Res is -1, 1, 0. dpkg -D=1 --compare-versions a "<" b can be
- used to determine what Res should be. # at the start of the line
- is a comment and blank lines are skipped
-
- ##################################################################### */
- /*}}}*/
-#include <apt-pkg/macros.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/debversion.h>
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-
- static int verrevcmp(const char *val, const char *ref)
-{
- int vc, rc;
- long vl, rl;
- const char *vp, *rp;
-
- if (!val)
- val = "";
- if (!ref)
- ref = "";
- for (;;)
- {
- vp = val;
- while (*vp && !isdigit(*vp))
- vp++;
- rp = ref;
- while (*rp && !isdigit(*rp))
- rp++;
- for (;;)
- {
- vc= val == vp ? 0 : *val++;
- rc= ref == rp ? 0 : *ref++;
- if (!rc && !vc)
- break;
- if (vc && !isalpha(vc))
- vc += 256; /* assumes ASCII character set */
- if (rc && !isalpha(rc))
- rc += 256;
- if (vc != rc)
- return vc - rc;
- }
- val = vp;
- ref = rp;
- vl = 0;
- if (isdigit(*vp))
- vl = strtol(val,(char**)&val,10);
- rl = 0;
- if (isdigit(*rp))
- rl = strtol(ref,(char**)&ref,10);
- if (vl != rl)
- return vl - rl;
- if (!*val && !*ref)
- return 0;
- if (!*val)
- return -1;
- if (!*ref)
- return +1;
- }
-}
-
-#if 0
-static int verrevcmp(const char *val, const char *ref)
-{
- int vc, rc;
- long vl, rl;
- const char *vp, *rp;
-
- if (!val) val= "";
- if (!ref) ref= "";
- for (;;)
- {
- vp= val; while (*vp && !isdigit(*vp) && *vp != '~') vp++;
- rp= ref; while (*rp && !isdigit(*rp) && *rp != '~') rp++;
- for (;;)
- {
- vc= val == vp ? 0 : *val++;
- rc= ref == rp ? 0 : *ref++;
- if (!rc && !vc) break;
- if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
- if (rc && !isalpha(rc)) rc += 256;
- if (vc != rc) return vc - rc;
- }
-
- val= vp;
- ref= rp;
- if (*vp == '~') val++;
- if (*rp == '~') ref++;
- vl=0; if (isdigit(*val)) vl= strtol(val,(char**)&val,10);
- rl=0; if (isdigit(*ref)) rl= strtol(ref,(char**)&ref,10);
- if (vl == 0 && rl == 0)
- {
- if (*vp == '~' && *rp != '~') return -1;
- if (*vp != '~' && *rp == '~') return +1;
- }
- if (*vp == '~')
- vl *= -1;
- if (*rp == '~')
- rl *= -1;
- if (vl != rl) return vl - rl;
- if (!*val && !*ref) return 0;
- if (!*val)
- {
- if (*ref == '~')
- return +1;
- else
- return -1;
- }
-
- if (!*ref)
- {
- if (*val == '~')
- return -1;
- else
- return +1;
- }
- }
-}
-#endif
-
-bool RunTest(const char *File)
-{
- ifstream F(File,ios::in);
- if (!F != 0)
- return false;
-
- char Buffer[300];
- int CurLine = 0;
-
- while (1)
- {
- F.getline(Buffer,sizeof(Buffer));
- CurLine++;
- if (F.eof() != 0)
- return true;
- if (!F != 0)
- return _error->Error("Line %u in %s is too long",CurLine,File);
-
- // Comment
- if (Buffer[0] == '#' || Buffer[0] == 0)
- continue;
-
- // First version
- char *I;
- char *Start = Buffer;
- for (I = Buffer; *I != 0 && *I != ' '; I++);
- string A(Start, I - Start);
-
- if (*I == 0)
- return _error->Error("Invalid line %u",CurLine);
-
- // Second version
- I++;
- Start = I;
- for (I = Start; *I != 0 && *I != ' '; I++);
- string B(Start,I - Start);
-
- if (*I == 0 || I[1] == 0)
- return _error->Error("Invalid line %u",CurLine);
-
- // Result
- I++;
- int Expected = atoi(I);
- int Res = debVS.CmpVersion(A.c_str(), B.c_str());
- int Res2 = verrevcmp(A.c_str(),B.c_str());
- cout << "'" << A << "' ? '" << B << "' = " << Res << " (= " << Expected << ") " << Res2 << endl;
-
- if (Res < 0)
- Res = -1;
- else if (Res > 0)
- Res = 1;
-
- if (Res != Expected)
- _error->Error("Comparison failed on line %u. '%s' ? '%s' %i != %i",CurLine,A.c_str(),B.c_str(),Res,Expected);
-
- // Check the reverse as well
- Expected = -1*Expected;
- Res = debVS.CmpVersion(B.c_str(), A.c_str());
- Res2 = verrevcmp(B.c_str(),A.c_str());
-
- cout << "'" << B << "' ? '" << A << "' = " << Res << " (= " << Expected << ") " << Res2 << endl;
-
- if (Res < 0)
- Res = -1;
- else if (Res > 0)
- Res = 1;
-
- if (Res != Expected)
- _error->Error("Comparison failed on line %u. '%s' ? '%s' %i != %i",CurLine,B.c_str(),A.c_str(),Res,Expected);
- }
-}
-
-int main(int argc, char *argv[])
-{
- if (argc <= 1)
- {
- cerr << "You must specify a test file" << endl;
- return 0;
- }
-
- RunTest(argv[1]);
-
- // Print any errors or warnings found
- if (_error->empty() == false)
- {
- string Err;
- while (_error->empty() == false)
- {
-
- bool Type = _error->PopMessage(Err);
- if (Type == true)
- cout << "E: " << Err << endl;
- else
- cout << "W: " << Err << endl;
- }
-
- return 0;
- }
-}