perfetto: add script to quickly add traces to test data

This CL vastly lowers the barrier of entry for writing regression tests on
new traces. By automating the mind-numbing process of downloading,
unzipping, copying, zipping, uploading, setting ACLs and deleting temp
files, it allows us to focus on writing the tests rathert than adding
traces.

Change-Id: I234b4f5e05134955c23fe1061c31f13ab75734f4
diff --git a/tools/add_test_trace.sh b/tools/add_test_trace.sh
new file mode 100755
index 0000000..ef9c2d5
--- /dev/null
+++ b/tools/add_test_trace.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+set -e
+
+echo ""
+echo "Downloading latest copy of test data"
+echo ""
+LATEST_ZIP="$(gsutil ls gs://perfetto | sort | grep test-data | tail -n 1)"
+gsutil cp $LATEST_ZIP /tmp/latest-test-data.zip
+
+echo ""
+echo "Extracting test data to temp folder"
+echo ""
+unzip /tmp/latest-test-data.zip -d /tmp/latest-test-data
+
+echo ""
+echo "Copying trace to temp folder"
+echo ""
+cp $1 /tmp/latest-test-data
+
+echo ""
+echo "Zipping file back up"
+echo ""
+NEW_TEST_DATA="test-data-$(date +%Y%m%d).zip"
+zip -r /tmp/$NEW_TEST_DATA /tmp/latest-test-data
+
+echo ""
+echo "Uploading file to Google Cloud"
+echo ""
+gsutil cp /tmp/$NEW_TEST_DATA gs://perfetto/$NEW_TEST_DATA
+
+echo ""
+echo "Setting file to world readable"
+echo ""
+gsutil acl ch -u AllUsers:R gs://perfetto/$NEW_TEST_DATA
+
+echo ""
+echo "sha1sum of file $NEW_TEST_DATA is"
+echo $(sha1sum /tmp/$NEW_TEST_DATA)
+
+echo ""
+echo "Cleaning up leftover files"
+echo ""
+rm -r /tmp/latest-test-data
+rm /tmp/latest-test-data.zip
+rm /tmp/$NEW_TEST_DATA
+
+echo ""
+echo "All done! Please update tools/install-build-deps"
+echo "with the new file name and sha1sum"
+echo ""