-#! /usr/bin/python
+#! /usr/bin/python2
#
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-#
+# Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
self.rules = []
self.files = []
self.expectfailure = False
-
+
if os.path.isfile(self.name):
# all tests expect this to be available
from pmpkg import pmpkg
else:
raise IOError("file %s does not exist!" % self.name)
- def generate(self):
+ def generate(self, pacman):
print "==> Generating test environment"
# Cleanup leftover files from a previous test session
logdir = os.path.join(self.root, os.path.dirname(util.LOGFILE))
etcdir = os.path.join(self.root, os.path.dirname(util.PACCONF))
bindir = os.path.join(self.root, "bin")
- sys_dirs = [dbdir, cachedir, syncdir, tmpdir, logdir, etcdir, bindir]
+ ldconfig = os.path.basename(pacman["ldconfig"])
+ ldconfigdir = os.path.join(self.root, os.path.dirname(pacman["ldconfig"][1:]))
+ shell = pacman["scriptlet-shell"][1:]
+ shelldir = os.path.join(self.root, os.path.dirname(shell))
+ sys_dirs = [dbdir, cachedir, syncdir, tmpdir, logdir, etcdir, bindir,
+ ldconfigdir, shelldir]
for sys_dir in sys_dirs:
if not os.path.isdir(sys_dir):
vprint("\t%s" % sys_dir[len(self.root)+1:])
os.makedirs(sys_dir, 0755)
# Only the dynamically linked binary is needed for fakechroot
shutil.copy("/bin/sh", bindir)
+ if shell != "bin/sh":
+ shutil.copy("/bin/sh", os.path.join(self.root, shell))
+ shutil.copy(os.path.join(util.SELFPATH, "ldconfig.stub"),
+ os.path.join(ldconfigdir, ldconfig))
+ ld_so_conf = open(os.path.join(etcdir, "ld.so.conf"), "w")
+ ld_so_conf.close()
# Configuration file
vprint(" Creating configuration file")
vprint(" Creating package archives")
for pkg in self.localpkgs:
vprint("\t%s" % os.path.join(util.TMPDIR, pkg.filename()))
+ pkg.finalize()
pkg.makepkg(tmpdir)
for key, value in self.db.iteritems():
+ for pkg in value.pkgs:
+ pkg.finalize()
if key == "local" and not self.createlocalpkgs:
continue
for pkg in value.pkgs:
# Filesystem
vprint(" Populating file system")
- for pkg in self.db["local"].pkgs:
- vprint("\tinstalling %s" % pkg.fullname())
- pkg.install_package(self.root)
for f in self.filesystem:
vprint("\t%s" % f)
util.mkfile(self.root, f, f)
path = os.path.join(self.root, f)
if os.path.isfile(path):
os.utime(path, (355, 355))
+ for pkg in self.db["local"].pkgs:
+ vprint("\tinstalling %s" % pkg.fullname())
+ pkg.install_package(self.root)
# Done.
vprint(" Taking a snapshot of the file system")
cmd.append("fakeroot")
fakechroot = util.which("fakechroot")
- if fakechroot:
+ if not fakechroot:
+ print "WARNING: fakechroot not found!"
+ else:
cmd.append("fakechroot")
if pacman["gdb"]:
cmd.extend(["libtool", "execute", "gdb", "--args"])
if pacman["valgrind"]:
+ suppfile = os.path.join(os.path.dirname(__file__),
+ '..', '..', 'valgrind.supp')
cmd.extend(["libtool", "execute", "valgrind", "-q",
"--tool=memcheck", "--leak-check=full",
- "--show-reachable=yes", "--suppressions=%s/valgrind.supp" % os.getcwd()])
+ "--show-reachable=yes",
+ "--suppressions=%s" % suppfile])
cmd.extend([pacman["bin"],
"--config", os.path.join(self.root, util.PACCONF),
"--root", self.root,
# archives are made available more easily.
time_start = time.time()
self.retcode = subprocess.call(cmd, stdout=output, stderr=output,
- cwd=os.path.join(self.root, util.TMPDIR))
+ cwd=os.path.join(self.root, util.TMPDIR), env={'LC_ALL': 'C'})
time_end = time.time()
vprint("\ttime elapsed: %.2fs" % (time_end - time_start))
if success == 1:
msg = " OK "
self.result["success"] += 1
- elif success == 0:
+ else:
msg = "FAIL"
self.result["fail"] += 1
- else:
- msg = "SKIP"
print "\t[%s] %s" % (msg, i)
# vim: set ts=4 sw=4 et: