mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-08 12:28:00 -05:00
pactest: treat symlinks with more respect
Don't call os.stat() when we should be using os.lstat(); this allows us to actually test dead symlinks that don't have a corresponding file. Add a new LINK_EXIST rule that complements FILE_EXIST for a similar purpose. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
ac6f6b317a
commit
3000b6b473
@ -102,7 +102,7 @@ class pmpkg(object):
|
|||||||
# Generate package file system
|
# Generate package file system
|
||||||
for f in self.files:
|
for f in self.files:
|
||||||
util.mkfile(f, f)
|
util.mkfile(f, f)
|
||||||
self.size += os.stat(util.getfilename(f))[stat.ST_SIZE]
|
self.size += os.lstat(util.getfilename(f))[stat.ST_SIZE]
|
||||||
|
|
||||||
# .PKGINFO
|
# .PKGINFO
|
||||||
data = ["pkgname = %s" % self.name]
|
data = ["pkgname = %s" % self.name]
|
||||||
|
@ -146,6 +146,14 @@ class pmrule(object):
|
|||||||
else:
|
else:
|
||||||
print "FILE rule '%s' not found" % case
|
print "FILE rule '%s' not found" % case
|
||||||
success = -1
|
success = -1
|
||||||
|
elif kind == "LINK":
|
||||||
|
filename = os.path.join(test.root, key)
|
||||||
|
if case == "EXIST":
|
||||||
|
if not os.path.islink(filename):
|
||||||
|
success = 0
|
||||||
|
else:
|
||||||
|
print "LINK rule '%s' not found" % case
|
||||||
|
success = -1
|
||||||
elif kind == "CACHE":
|
elif kind == "CACHE":
|
||||||
cachedir = os.path.join(test.root, util.PM_CACHEDIR)
|
cachedir = os.path.join(test.root, util.PM_CACHEDIR)
|
||||||
if case == "EXISTS":
|
if case == "EXISTS":
|
||||||
|
@ -149,7 +149,6 @@ def getmd5sum(filename):
|
|||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
print "file %s does not exist!" % filename
|
|
||||||
return ""
|
return ""
|
||||||
fd = open(filename, "rb")
|
fd = open(filename, "rb")
|
||||||
checksum = hashlib.md5()
|
checksum = hashlib.md5()
|
||||||
@ -177,9 +176,8 @@ def getmtime(filename):
|
|||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
print "path %s does not exist!" % filename
|
return None, None, None
|
||||||
return 0, 0, 0
|
st = os.lstat(filename)
|
||||||
st = os.stat(filename)
|
|
||||||
return st[stat.ST_ATIME], st[stat.ST_MTIME], st[stat.ST_CTIME]
|
return st[stat.ST_ATIME], st[stat.ST_MTIME], st[stat.ST_CTIME]
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user