Yet another fix in low-level scripts involving command_executer changes.
Fixed run_tests.py.
Also added options in the nightly client for debugging it. It can use a local p4 checkout instead of creating a new client for faster iteration.
PRESUBMIT=passed
R=raymes,bjanakiraman
DELTA=46 (22 added, 14 deleted, 10 changed)
OCL=45701-p2
RCL=45709-p2
RDATE=2010/12/08 17:00:37
P4 change: 42606965
diff --git a/v14/automation/clients/test_client.py b/v14/automation/clients/test_client.py
index 0a8bf4a..884a0bc 100755
--- a/v14/automation/clients/test_client.py
+++ b/v14/automation/clients/test_client.py
@@ -31,17 +31,23 @@
default="trunk",
help="Toolchain to use {trunk|branch|custom}"
)
+ parser.add_option("-p",
+ "--p4-snapshot",
+ default="",
+ help="An existing perforce checkout for debugging."
+ )
options = parser.parse_args(argv)[0]
server = xmlrpclib.Server("http://localhost:8000")
all_jobs = []
- tc_job = jobs_helper.CreateBuildTCJob()
+ tc_job = jobs_helper.CreateBuildTCJob(p4_snapshot=options.p4_snapshot)
all_jobs.append(tc_job)
build_chromeos_job = (
jobs_helper.CreateBuildAndTestChromeOSJob(
- tc_job))
+ tc_job,
+ p4_snapshot=options.p4_snapshot))
all_jobs.append(build_chromeos_job)
group = job_group.JobGroup(os.uname()[1], "/tmp/", all_jobs, False, False)
diff --git a/v14/automation/common/jobs_helper.py b/v14/automation/common/jobs_helper.py
index d058352..e45bd27 100755
--- a/v14/automation/common/jobs_helper.py
+++ b/v14/automation/common/jobs_helper.py
@@ -1,5 +1,7 @@
import job
from automation.common import machine_description
+import os
+import sys
p4_checkout_dir = "perforce2"
version_dir = "/gcctools/chromeos/v14/"
@@ -21,9 +23,22 @@
return p4_string
-def GetP4Command(p4_port, p4_paths, revision, checkoutdir):
- client_name = "p4-automation-$JOB_ID"
+def GetP4Command(p4_port, p4_paths, revision, checkoutdir, p4_snapshot=""):
command = ""
+
+ if p4_snapshot:
+ command += "mkdir -p " + checkoutdir
+ for p4_path in p4_paths:
+ real_path = p4_path[1]
+ if real_path.endswith("..."):
+ real_path = real_path.replace("/...", "")
+ command += ("&& mkdir -p " + checkoutdir + "/" +
+ os.path.dirname(real_path))
+ command += ("&& ln -s " + p4_snapshot + "/" + real_path +
+ " " + checkoutdir + "/" + real_path)
+ return command
+
+ client_name = "p4-automation-$JOB_ID"
command += " export P4CONFIG=.p4config"
command += " && mkdir -p " + checkoutdir
command += " && cd " + checkoutdir
@@ -63,12 +78,12 @@
command += "&& cp -pr " + source + "/* " + dest
return command
-def GetP4VersionDirCommand():
+def GetP4VersionDirCommand(p4_snapshot=""):
p4_port = "perforce2:2666"
p4_paths = []
p4_paths.append(("//depot2/gcctools/chromeos/v14/...", "gcctools/chromeos/v14/..."))
p4_revision = 1
- command = GetP4Command(p4_port, p4_paths, p4_revision, p4_checkout_dir)
+ command = GetP4Command(p4_port, p4_paths, p4_revision, p4_checkout_dir, p4_snapshot)
return command
@@ -81,11 +96,8 @@
p4_revision = 1
command = GetInitialCommand()
- if p4_snapshot:
- command += "; cp -rp " + p4_snapshot + " " + p4_checkout_dir
- else:
- command += "; " + GetP4Command(p4_port, p4_paths,
- p4_revision, p4_checkout_dir)
+ command += "; " + GetP4Command(p4_port, p4_paths,
+ p4_revision, p4_checkout_dir, p4_snapshot)
if chromeos_snapshot == "weekly":
command += "; sudo cp -rp " + GetWeeklyChromeOSLocation() + " chromeos"
@@ -103,11 +115,7 @@
command = GetInitialCommand()
# TODO(asharif): Get rid of this hack at some point.
command += "&& mkdir -p perforce2/gcctools/google_vendor_src_branch/gcc"
- if p4_snapshot:
- command += "&& " + GetCopyTreeCommand(p4_snapshot + version_dir,
- p4_version_dir)
- else:
- command += "; " + GetP4VersionDirCommand()
+ command += "; " + GetP4VersionDirCommand(p4_snapshot)
if chromeos_snapshot == "weekly":
command += "; sudo cp -rp " + GetWeeklyChromeOSLocation() + " chromeos"
diff --git a/v14/build_chromeos.py b/v14/build_chromeos.py
index f4b12f0..3968a91 100755
--- a/v14/build_chromeos.py
+++ b/v14/build_chromeos.py
@@ -18,8 +18,6 @@
from utils import logger
from utils import utils
-cmd_executer = None
-
def Usage(parser, message):
print "ERROR: " + message
@@ -51,7 +49,7 @@
if clobber_chroot:
clobber_chroot = "--replace"
commands.append("./make_chroot --fast " + clobber_chroot)
- ret = cmd_executer.RunCommands(commands)
+ ret = command_executer.GetCommandExecuter().RunCommands(commands)
utils.AssertTrue(ret == 0, "make_chroot failed")
else:
logger.GetLogger().LogOutput("Did not make_chroot because it already exists")
@@ -60,7 +58,6 @@
def Main(argv):
"""Build ChromeOS."""
# Common initializations
- global cmd_executer
cmd_executer = command_executer.GetCommandExecuter()
parser = optparse.OptionParser()
diff --git a/v14/run_tests.py b/v14/run_tests.py
index 08d3a48..54a144f 100755
--- a/v14/run_tests.py
+++ b/v14/run_tests.py
@@ -14,9 +14,6 @@
import sys
from utils import command_executer
-# Common initializations
-cmd_executer = command_executer.GetCommandExecuter()
-
def Main():
"""The main function."""
@@ -51,7 +48,7 @@
" --board=" + board +
" " + tests)
- retval = cmd_executer.RunCommand(command)
+ retval = command_executer.GetCommandExecuter().RunCommand(command)
return retval
if __name__ == "__main__":