chiark / gitweb /
bugfixes; new execute syntax
authorIan Jackson <ian@davenant.relativity.greenend.org.uk>
Thu, 2 Feb 2006 19:40:19 +0000 (19:40 +0000)
committerIan Jackson <ian@davenant.relativity.greenend.org.uk>
Thu, 2 Feb 2006 19:40:19 +0000 (19:40 +0000)
runner/adt-run
virt-chroot/adt-virt-chroot

index e663a2a76a8e0070ed1ff3f9db5e266f946dc855..88e2315a33986b24f7745d7898f0870c559ae5ac 100755 (executable)
@@ -349,12 +349,12 @@ class Test:
        so = stdouterr('stdout')
        se = stdouterr('stderr')
        rc = testbed.commandr1('execute',(t.p.ontb(),
-               '/dev/null', so.ontb(), se.ontb()))
+               '/dev/null', so.ontb(), se.ontb(), opts.build_tree.ontb()))
        soh = stdouterrh(so, 'stdout')
-       soe = stdouterrh(se, 'stderr')
+       seh = stdouterrh(se, 'stderr')
        testbed.close()
        rc = int(rc)
-       stab = os.stat(soh)
+       stab = os.stat(seh)
        if stab.st_size != 0:
                l = file(seh).readline()
                l = l.rstrip('\n \t\r')
index c231a1e62b2b3a3356fed7fd8eeed47fb93a8006..9fdf4f147d8d9cb67360a3b72fc393df76b5d8c7 100755 (executable)
@@ -106,7 +106,6 @@ def execute(cmd_string, cmd_list=[], downp=False, outp=False):
        else: stdout = None
 
        cmd = perhaps_down + cmdl + cmd_list
-
        (status, out) = execute_raw(cmdl[0], None, cmd, stdout=stdout)
 
        if status: bomb("%s%s failed (exit status %d)" %
@@ -153,8 +152,9 @@ def down_python_script(gobody, functions=''):
                        "       os.dup2(nfd,fd)\n"
                        + functions +
                        "def go():\n" )
-       script += (     "       os.chdir(urllib.unquote('%s'))\n" %
+       script += (     "       os.environ['TMPDIR']= urllib.unquote('%s')\n" %
                                urllib.quote(downtmp)   )
+       script += (     "       os.chdir(os.environ['TMPDIR'])\n" )
        script += (     gobody +
                        "go()\n" )
 
@@ -167,18 +167,25 @@ def down_python_script(gobody, functions=''):
        return cmdl
 
 def cmd_execute(c, ce):
-       cmdnumargs(c, ce, 4)
+       cmdnumargs(c, ce, 5)
        gobody = "      import sys\n"
        for ioe in range(3):
                gobody += "     setfd(%d,'%s',%d)\n" % (
                        ioe, ce[ioe+2], ioe>0 )
+       gobody += "     os.chdir(urllib.unquote('" + ce[5] +"'))\n"
        gobody += "     cmd = '%s'\n" % ce[1]
        gobody += ("    cmd = cmd.split(',')\n"
                "       cmd = map(urllib.unquote, cmd)\n"
-               "       try: os.execvp(cmd[0], cmd)\n"
+               "       c0 = cmd[0]\n"
+               "       if '/' in c0:\n"
+               "               if not os.access(c0, os.X_OK):\n"
+               "                       status = os.stat(c0)\n"
+               "                       mode = status.st_mode | 0111\n"
+               "                       os.chmod(c0, mode)\n"
+               "       try: os.execvp(c0, cmd)\n"
                "       except OSError, e:\n"
                "               print >>sys.stderr, \"%s: %s\" % (\n"
-               "                       (cmd[0], os.strerror(e.errno)))\n"
+               "                       (c0, os.strerror(e.errno)))\n"
                "               os._exit(127)\n")
        cmdl = down_python_script(gobody)