From 624a87870164ab48bda485204d6fd49c86a0c354 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 22 Jun 2011 15:45:09 -0500 Subject: pactest: generate sync DB's in memory Sync database are no longer exploded on the filesystem. Rework the logic used to generate our test databases so we can create them completely in memory without having to write the individual files to disk at all. The local database is unaffected. Note that several shortcomings in libalpm parsing were discovered by this change, which have since been temporarily patched around in this test suite: * archive_fgets() did not properly handle a file that ended in a non-newline, and would silently drop the data in this line. * sync database with only the file entries and not the directories would fail to parse properly, and even cause segfaults in some cases. Signed-off-by: Dan McGee --- test/pacman/pmtest.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'test/pacman/pmtest.py') diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py index 105a841c..3f78ff92 100644 --- a/test/pacman/pmtest.py +++ b/test/pacman/pmtest.py @@ -55,7 +55,7 @@ def findpkg(self, name, version, allow_local=False): either sync databases or the local package collection. The local database is allowed to match if allow_local is True.""" for db in self.db.itervalues(): - if db.treename == "local" and not allow_local: + if db.is_local and not allow_local: continue pkg = db.getpkg(name) if pkg and pkg.version == version: @@ -110,7 +110,7 @@ def generate(self): # Create directory structure vprint(" Creating directory structure:") - dbdir = os.path.join(self.root, util.PM_DBPATH) + dbdir = os.path.join(self.root, util.PM_SYNCDBPATH) cachedir = os.path.join(self.root, util.PM_CACHEDIR) syncdir = os.path.join(self.root, util.SYNCREPO) tmpdir = os.path.join(self.root, util.TMPDIR) @@ -146,25 +146,11 @@ def generate(self): pkg.md5sum = util.getmd5sum(pkg.path) pkg.csize = os.stat(pkg.path)[stat.ST_SIZE] - # Populating databases - vprint(" Populating databases") - for key, value in self.db.iteritems(): - for pkg in value.pkgs: - vprint("\t%s/%s" % (key, pkg.fullname())) - if key == "local": - pkg.installdate = time.ctime() - value.db_write(pkg) - # Creating sync database archives - vprint(" Creating sync database archives") + vprint(" Creating databases") for key, value in self.db.iteritems(): - if key == "local": - continue vprint("\t" + value.treename) - value.gensync() - serverpath = os.path.join(syncdir, value.treename) - util.mkdir(serverpath) - shutil.copy(value.dbfile, serverpath) + value.generate() # Filesystem vprint(" Populating file system") -- cgit v1.2.3-54-g00ecf