testing: prepare running in incomplete chroots

In the future, nightly testing will use chroots which copy their root
filesystem and all additional files, instead of bind mounting them as it is
done now. The advantage of that setup is that the test runs become independent
from each other and thus can be parallelized. The downside is that paths to
files created inside the chroot has to be accessed via a different path from
the outside.

runtests.py will be invoked with those outside paths and needs to translate
them to the shorter paths used inside the chroot when invoking commands that
run inside it. This affects the current directory and any paths in the
argument list.
This commit is contained in:
Patrick Ohly 2013-12-09 08:41:06 -08:00
parent 30575344cf
commit e1fb7eb282
2 changed files with 24 additions and 10 deletions

View File

@ -116,15 +116,15 @@ def step1(resultdir, result, indents, dir, resulturi, shellprefix, srcdir):
s = fout.read()
result.write(indent+s)
result.write(indent+'''</osinfo>\n''')
if 'schroot' in shellprefix:
result.write(indent+'''<chrootinfo>\n''')
fout,fin=popen2.popen2(shellprefix.replace('schroot', 'schroot -i'))
s = ""
for line in fout:
if line.startswith(" Name ") or line.startswith(" Description "):
s = s + line
result.write(indent+s)
result.write(indent+'''</chrootinfo>\n''')
# if 'schroot' in shellprefix:
# result.write(indent+'''<chrootinfo>\n''')
# fout,fin=popen2.popen2(shellprefix.replace('schroot', 'schroot -i').replace(' -r ', ' ').replace(' --run ', ' ')
# s = ""
# for line in fout:
# if line.startswith(" Name ") or line.startswith(" Description "):
# s = s + line
# result.write(indent+s)
# result.write(indent+'''</chrootinfo>\n''')
result.write(indent+'''<libraryinfo>\n''')
libs = ['libsoup-2.4', 'evolution-data-server-1.2', 'glib-2.0','dbus-glib-1']
s=''

View File

@ -260,7 +260,18 @@ class Context:
cmdstr = " ".join(map(lambda x: (' ' in x or '(' in x or '\\' in x or x == '') and ("'" in x and '"%s"' or "'%s'") % x or x, cmd))
if dumpCommands:
cmdstr = "set -x; " + cmdstr
print "*** ( cd %s; export %s; %s )" % (os.getcwd(),
cwd = os.getcwd()
# Most commands involving schroot need to run with paths as seen inside the chroot.
# Detect that in a hackish way by checking for "schroot" and then adapting
# paths with search/replace. Exception is resultchecker.py, which runs outside
# the chroot, but gets passed "schroot" as parameter.
if 'schroot ' in cmdstr and options.schrootdir and not 'resultchecker.py' in cmdstr:
if cwd.startswith(options.schrootdir):
relcwd = cwd[len(options.schrootdir):]
cmdstr = cmdstr.replace('schroot ', 'schroot -d %s ' % relcwd)
cmdstr = cmdstr.replace(options.schrootdir + '/', '/')
print "*** ( cd %s; export %s; %s )" % (cwd,
" ".join(map(lambda x: "'%s=%s'" % (x, os.getenv(x, "")), [ "LD_LIBRARY_PATH", "PATH" ])),
cmdstr)
sys.stdout.flush()
@ -761,6 +772,9 @@ parser.add_option("", "--resulturi",
parser.add_option("", "--shell",
type="string", dest="shell", default="",
help="a prefix which is put in front of a command to execute it (can be used for e.g. run_garnome)")
parser.add_option("", "--schrootdir",
type="string", dest="schrootdir", default="",
help="the path to the root of the chroot when using schroot in --shell; --resultdir already includes the path")
parser.add_option("", "--test-prefix",
type="string", dest="testprefix", default="",
help="a prefix which is put in front of client-test (e.g. valgrind)")