Add preupload hooks to run tests
BUG=chromium:1051691
TEST=run preupload hooks
Change-Id: I16bd7cde86729116597d077956b31f772ba95a6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/infra/tnull/+/2309092
Tested-by: Jacob Kopczynski <jkop@chromium.org>
Auto-Submit: Jacob Kopczynski <jkop@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
Commit-Queue: Prathmesh Prabhu <pprabhu@chromium.org>
diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg
new file mode 100644
index 0000000..dfcb228
--- /dev/null
+++ b/PRESUBMIT.cfg
@@ -0,0 +1,5 @@
+# Per-project `repo upload` hook settings.
+# # https://chromium.googlesource.com/chromiumos/repohooks/
+
+[Hook Scripts]
+pre-upload_unittest = cros_sdk --working-dir . ./preupload.sh
diff --git a/preupload.sh b/preupload.sh
new file mode 100755
index 0000000..14395cf
--- /dev/null
+++ b/preupload.sh
@@ -0,0 +1,12 @@
+#!/bin/bash -e
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This script can only be run in the cros_sdk chroot
+
+ROOT=$(readlink -f ~/trunk/infra/tnull)
+. $ROOT/fast_build.sh
+. $ROOT/run_tests.sh
+echo "Not all these tests are expected to pass without an RTS."
+echo "Therefore examine the output to be sure it looks sane."
diff --git a/run_tests.sh b/run_tests.sh
index 5b0fafd..81f7c5d 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -10,6 +10,8 @@
if $?
then
echo "pass"
+ exit 0
else
echo "fail"
+ exit 1
fi