aboutsummaryrefslogtreecommitdiff
path: root/pgo_tools
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2019-05-31 15:46:46 -0700
committerGeorge Burgess <gbiv@chromium.org>2019-06-05 18:37:00 +0000
commit1bba5a6f270a05f95f87b326eb39035edb6c53f3 (patch)
tree21b49b0032e87f7c9741136ef66ea2e05cd177df /pgo_tools
parent0635efd6b8fd9b15e9e5a32c778919cd304f922c (diff)
downloadtoolchain-utils-1bba5a6f270a05f95f87b326eb39035edb6c53f3.tar.gz
pgo_tools: make the uploader check new uploads
As noted by zhizhou in I26d17b6b698f14d40e7e11c55ef894afd91552f5, this script previously didn't verify that the thing we intended to upload was actually uploaded. This CL fixes that. BUG=None TEST=Temporary profile was uploaded successfully; tried to clobber it, but the script failed loudly (as it should). Change-Id: Id791cb7ecd07140eb4dfc803c9267f3824983ae3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1638843 Tested-by: George Burgess <gbiv@chromium.org> Reviewed-by: Zhizhou Yang <zhizhouy@google.com>
Diffstat (limited to 'pgo_tools')
-rwxr-xr-xpgo_tools/merge_profdata_and_upload.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/pgo_tools/merge_profdata_and_upload.py b/pgo_tools/merge_profdata_and_upload.py
index 78546ff8..5348d61a 100755
--- a/pgo_tools/merge_profdata_and_upload.py
+++ b/pgo_tools/merge_profdata_and_upload.py
@@ -93,14 +93,33 @@ def _tar_and_upload_profdata(profdata, name_suffix):
subprocess.check_call(
['tar', '--sparse', '-I', 'xz', '-cf', tarball, profdata])
+ upload_location = '%schromeos-localmirror/distfiles/%s' % (_GS_PREFIX,
+ tarball)
+
# TODO: it's better to create a subdir: distfiles/llvm_pgo_profile, but
# now llvm could only recognize distfiles.
upload_cmd = [
- 'gsutil', '-m', 'cp', '-n', '-a', 'public-read', tarball,
- '%schromeos-localmirror/distfiles/%s' % (_GS_PREFIX, tarball)
+ 'gsutil',
+ '-m',
+ 'cp',
+ '-n',
+ '-a',
+ 'public-read',
+ tarball,
+ upload_location,
]
print('Uploading tarball to gs.\nCMD: %s\n' % upload_cmd)
- subprocess.check_call(upload_cmd)
+
+ # gsutil prints all status to stderr, oddly enough.
+ gs_output = subprocess.check_output(upload_cmd, stderr=subprocess.STDOUT)
+ print(gs_output)
+
+ # gsutil exits successfully even if it uploaded nothing. It prints a summary
+ # of what all it did, though. Successful uploads are just a progress bar,
+ # unsuccessful ones note that items were skipped.
+ if 'Skipping existing item' in gs_output:
+ raise ValueError('Profile upload failed: would overwrite an existing '
+ 'profile at %s' % upload_location)
def main():