From 4a8c2852a887d2b1aaa43be3071ab586eb24b9e3 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Thu, 20 Sep 2012 23:09:29 +1000 Subject: pmtest: resolve path to scriptlet shell In order to support a variety of values for the --with-scriptlet-shell configure flag, pmtest has to be aware of what kind of path was passed, be it an absolute path or a fragment for a path lookup. For absolute paths, leave the path alone. For fragments, search the PATH environment var for the resolved path to the binary. In both cases, join the resultant path to the root directory defined for the test, not a pre-determined bin directory. Fixes FS#31552. With-contribution-by: Dave Reisner Signed-off-by: Allan McRae --- Makefile.am | 1 + test/pacman/pactest.py | 5 +++++ test/pacman/pmenv.py | 2 +- test/pacman/pmtest.py | 21 +++++++++++++++++++-- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index b05feb68..cd69b6e7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ check-local: test-pacman test-pacsort test-vercmp test-parseopts test-pacman: test/pacman src/pacman LC_ALL=C $(PYTHON) $(top_srcdir)/test/pacman/pactest.py --debug=1 \ --test $(top_srcdir)/test/pacman/tests/*.py \ + --scriptlet-shell $(SCRIPTLET_SHELL) \ -p $(top_builddir)/src/pacman/pacman test-pacsort: test/util src/util diff --git a/test/pacman/pactest.py b/test/pacman/pactest.py index 2fb64edc..42c6a825 100755 --- a/test/pacman/pactest.py +++ b/test/pacman/pactest.py @@ -3,6 +3,7 @@ # pactest : run automated testing on the pacman binary # # Copyright (c) 2006 by Aurelien Foret +# Copyright (c) 2006-2013 Pacman Development Team # # 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 @@ -81,6 +82,9 @@ def create_parser(): parser.add_option("--manual-confirm", action = "store_true", dest = "manualconfirm", default = False, help = "do not use --noconfirm for pacman calls") + parser.add_option("--scriptlet-shell", type = "string", + dest = "scriptletshell", default = "sh", + help = "specify shell used for install scriptlets") return parser @@ -99,6 +103,7 @@ if __name__ == "__main__": env.pacman["gdb"] = opts.gdb env.pacman["valgrind"] = opts.valgrind env.pacman["manual-confirm"] = opts.manualconfirm + env.pacman["scriptlet-shell"] = opts.scriptletshell if opts.testcases is None or len(opts.testcases) == 0: print "no tests defined, nothing to do" diff --git a/test/pacman/pmenv.py b/test/pacman/pmenv.py index 0e455cee..04948c12 100644 --- a/test/pacman/pmenv.py +++ b/test/pacman/pmenv.py @@ -66,7 +66,7 @@ class pmenv(object): print t.description print "----------"*8 - t.generate() + t.generate(self.pacman) t.run(self.pacman) diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py index 00a0b96e..5503559f 100644 --- a/test/pacman/pmtest.py +++ b/test/pacman/pmtest.py @@ -1,6 +1,7 @@ #! /usr/bin/python2 # # Copyright (c) 2006 by Aurelien Foret +# Copyright (c) 2006-2012 Pacman Development Team # # 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 @@ -102,7 +103,18 @@ class pmtest(object): else: raise IOError("file %s does not exist!" % self.name) - def generate(self): + def resolve_binary(self, binary): + if os.path.isabs(binary): + return binary + + for path in os.environ["PATH"].split(':'): + resolved = os.path.join(path, binary) + if os.path.exists(resolved): + return resolved + + return binary + + def generate(self, pacman): print "==> Generating test environment" # Cleanup leftover files from a previous test session @@ -120,13 +132,18 @@ class pmtest(object): etcdir = os.path.join(self.root, os.path.dirname(util.PACCONF)) bindir = os.path.join(self.root, "bin") sbindir = os.path.join(self.root, "sbin") - sys_dirs = [dbdir, cachedir, syncdir, tmpdir, logdir, etcdir, bindir, sbindir] + scriptlet_shell = self.resolve_binary(pacman["scriptlet-shell"]) + shelldir = os.path.join(self.root, os.path.dirname(scriptlet_shell)[1:]) + sys_dirs = [dbdir, cachedir, syncdir, tmpdir, logdir, etcdir, bindir, + sbindir, 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 scriptlet_shell != "/bin/sh": + shutil.copy("/bin/sh", os.path.join(self.root, scriptlet_shell[1:])) shutil.copy(os.path.join(util.SELFPATH, "ldconfig.stub"), os.path.join(sbindir, "ldconfig")) ld_so_conf = open(os.path.join(etcdir, "ld.so.conf"), "w") -- cgit v1.2.3-24-g4f1b