summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-10-26 22:55:31 -0500
committerDan McGee <dan@archlinux.org>2011-01-22 11:19:21 -0600
commit32727efc38bf5376a402c4c4149cc4148ba2068b (patch)
treeebbe400b78b4431ca197ee9c49541178ac4dc066 /test
parent5699f2c94c39afec19810fc450b78dced86e7c5d (diff)
downloadpacman-32727efc38bf5376a402c4c4149cc4148ba2068b.tar.xz
pactest: revamp modified logic
Remove all logic dealing with PKG_MODIFIED as this rule no longer exists. This removes a bunch of unnecessary stat and checksum logic that most of the time we were never even using. Also update the file modified checks to mark every file created using mkfile() with an older time so any modified checks will just work without hacks. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'test')
-rwxr-xr-xtest/pacman/pmdb.py40
-rwxr-xr-xtest/pacman/pmenv.py7
-rwxr-xr-xtest/pacman/pmfile.py27
-rwxr-xr-xtest/pacman/pmpkg.py17
-rwxr-xr-xtest/pacman/pmrule.py6
-rwxr-xr-xtest/pacman/pmtest.py12
6 files changed, 18 insertions, 91 deletions
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py
index 22af989d..bb5aab92 100755
--- a/test/pacman/pmdb.py
+++ b/test/pacman/pmdb.py
@@ -161,8 +161,6 @@ class pmdb:
elif line == "%PROVIDES%":
pkg.provides = _getsection(fd)
fd.close()
- pkg.checksum["desc"] = util.getmd5sum(filename)
- pkg.mtime["desc"] = util.getmtime(filename)
# files
filename = os.path.join(path, "files")
@@ -183,14 +181,9 @@ class pmdb:
if line == "%BACKUP%":
pkg.backup = _getsection(fd)
fd.close()
- pkg.checksum["files"] = util.getmd5sum(filename)
- pkg.mtime["files"] = util.getmtime(filename)
# install
filename = os.path.join(path, "install")
- if os.path.isfile(filename):
- pkg.checksum["install"] = util.getmd5sum(filename)
- pkg.mtime["install"] = util.getmtime(filename)
return pkg
@@ -252,8 +245,6 @@ class pmdb:
data.append("")
filename = os.path.join(path, "desc")
util.mkfile(filename, "\n".join(data))
- pkg.checksum["desc"] = util.getmd5sum(filename)
- pkg.mtime["desc"] = util.getmtime(filename)
# files
# for local entries, fields are: files, backup
@@ -268,8 +259,6 @@ class pmdb:
data.append("")
filename = os.path.join(path, "files")
util.mkfile(filename, "\n".join(data))
- pkg.checksum["files"] = util.getmd5sum(filename)
- pkg.mtime["files"] = util.getmtime(filename)
# install
if self.treename == "local":
@@ -280,8 +269,6 @@ class pmdb:
if not empty:
filename = os.path.join(path, "install")
util.mkinstallfile(filename, pkg.install)
- pkg.checksum["install"] = util.getmd5sum(filename)
- pkg.mtime["install"] = util.getmtime(filename)
def gensync(self):
"""
@@ -300,31 +287,4 @@ class pmdb:
os.chdir(curdir)
- def ispkgmodified(self, pkg):
- """
- """
-
- modified = 0
-
- oldpkg = self.getpkg(pkg.name)
- if not oldpkg:
- return 0
-
- util.vprint("\toldpkg.checksum : %s" % oldpkg.checksum)
- util.vprint("\toldpkg.mtime : %s" % oldpkg.mtime)
-
- for key in pkg.mtime.keys():
- if key == "install" \
- and oldpkg.mtime[key] == (0, 0, 0) \
- and pkg.mtime[key] == (0, 0, 0):
- continue
- if oldpkg.mtime[key][1:3] != pkg.mtime[key][1:3]:
- modified += 1
-
- return modified
-
-
-if __name__ == "__main__":
- db = pmdb("local")
- print db
# vim: set ts=4 sw=4 et:
diff --git a/test/pacman/pmenv.py b/test/pacman/pmenv.py
index d1ea8328..5b61de2c 100755
--- a/test/pacman/pmenv.py
+++ b/test/pacman/pmenv.py
@@ -68,13 +68,6 @@ class pmenv:
print "----------"*8
t.generate()
- # Hack for mtimes consistency
- for i in t.rules:
- if i.rule.find("FILE_MODIFIED") != -1:
- [test, arg] = i.rule.split("=")
- for f in t.files:
- if f.name == arg:
- f.resettimes()
t.run(self.pacman)
diff --git a/test/pacman/pmfile.py b/test/pacman/pmfile.py
index ffa4aa7e..6770bca8 100755
--- a/test/pacman/pmfile.py
+++ b/test/pacman/pmfile.py
@@ -27,10 +27,10 @@ class pmfile:
def __init__(self, root, name):
self.name = name
self.root = root
+ self.filename = os.path.join(self.root, self.name)
- filename = os.path.join(self.root, self.name)
- self.checksum = util.getmd5sum(filename)
- self.mtime = util.getmtime(filename)
+ self.checksum = util.getmd5sum(self.filename)
+ self.mtime = util.getmtime(self.filename)
def __str__(self):
return "%s (%s / %lu)" % (self.name, self.checksum, self.mtime)
@@ -38,12 +38,8 @@ class pmfile:
def ismodified(self):
"""
"""
-
- retval = 0
-
- filename = os.path.join(self.root, self.name)
- checksum = util.getmd5sum(filename)
- mtime = util.getmtime(filename)
+ checksum = util.getmd5sum(self.filename)
+ mtime = util.getmtime(self.filename)
util.vprint("\tismodified(%s)" % self.name)
util.vprint("\t\told: %s / %s" % (self.checksum, self.mtime))
@@ -51,17 +47,8 @@ class pmfile:
if self.checksum != checksum \
or (self.mtime[1], self.mtime[2]) != (mtime[1], mtime[2]):
- retval = 1
-
- return retval
-
- def resettimes(self):
- """
- """
+ return 1
- filename = os.path.join(self.root, self.name)
- os.utime(filename, (355, 355))
- self.mtime = util.getmtime(filename)
- util.vprint("\tmtime reset (%s)" % self.name)
+ return 0
# vim: set ts=4 sw=4 et:
diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py
index 2b4a4a72..336f2974 100755
--- a/test/pacman/pmpkg.py
+++ b/test/pacman/pmpkg.py
@@ -64,16 +64,6 @@ class pmpkg:
"pre_upgrade": "",
"post_upgrade": ""
}
- self.checksum = {
- "desc": "",
- "files": "",
- "install": ""
- }
- self.mtime = {
- "desc": (0, 0, 0),
- "files": (0, 0, 0),
- "install": (0, 0, 0)
- }
def __str__(self):
s = ["%s" % self.fullname()]
@@ -97,13 +87,6 @@ class pmpkg:
"""
return "%s%s" % (self.fullname(), util.PM_EXT_PKG)
- def install_files(self, root):
- """Install files in the filesystem located under "root".
-
- Files are created with content generated automatically.
- """
- [util.mkfile(os.path.join(root, f), f) for f in self.files]
-
def makepkg(self, path):
"""Creates an ArchLinux package archive.
diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py
index c69e3cd3..3ba72fe7 100755
--- a/test/pacman/pmrule.py
+++ b/test/pacman/pmrule.py
@@ -69,13 +69,8 @@ class pmrule:
if not newpkg:
success = 0
else:
- util.vprint("\tnewpkg.checksum : %s" % newpkg.checksum)
- util.vprint("\tnewpkg.mtime : %s" % newpkg.mtime)
if case == "EXIST":
success = 1
- elif case == "MODIFIED":
- if not localdb.ispkgmodified(newpkg):
- success = 0
elif case == "VERSION":
if value != newpkg.version:
success = 0
@@ -121,6 +116,7 @@ class pmrule:
if f.name == key:
if not f.ismodified():
success = 0
+ break
elif case == "MODE":
if not os.path.isfile(filename):
success = 0
diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
index 716b920a..31517a9a 100755
--- a/test/pacman/pmtest.py
+++ b/test/pacman/pmtest.py
@@ -166,10 +166,18 @@ class pmtest:
vprint(" Populating file system")
for pkg in self.db["local"].pkgs:
vprint("\tinstalling %s" % pkg.fullname())
- pkg.install_files(self.root)
+ for f in pkg.files:
+ vprint("\t%s" % f)
+ path = os.path.join(self.root, f)
+ util.mkfile(path, f)
+ if os.path.isfile(path):
+ os.utime(path, (355, 355))
for f in self.filesystem:
vprint("\t%s" % f)
- util.mkfile(os.path.join(self.root, f), f)
+ path = os.path.join(self.root, f)
+ util.mkfile(path, f)
+ if os.path.isfile(path):
+ os.utime(path, (355, 355))
# Done.
vprint(" Taking a snapshot of the file system")