summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2017-08-29 08:44:13 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-08-29 22:08:20 -0700
commit2777b7771e788a7c2205c907710b703c48efedc5 (patch)
tree4ca5c44a99d4c0e6d0bdb2413a55d159e5b14c9e
parentc1e5671e561c82c9532cb29b17fc7cf4061ab20a (diff)
downloadchrome-ec-2777b7771e788a7c2205c907710b703c48efedc5.tar.gz
presubmit_check: Check unittests results on extra/stack_analyzer
BRANCH=none BUG=none TEST=util/presubmit_check.sh Change-Id: I6078377603719de1d633660c69ad3a40b29ffadf Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/640191 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Che-yu Wu <cheyuw@google.com>
-rwxr-xr-xextra/stack_analyzer/run_tests.sh9
-rwxr-xr-xutil/presubmit_check.sh39
2 files changed, 34 insertions, 14 deletions
diff --git a/extra/stack_analyzer/run_tests.sh b/extra/stack_analyzer/run_tests.sh
new file mode 100755
index 0000000000..0e307d8d4a
--- /dev/null
+++ b/extra/stack_analyzer/run_tests.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+#
+# Copyright 2017 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.
+
+# Discover all the unit tests in extra/stack_analyzer directory and run them.
+python2 -m unittest discover -b -s extra/stack_analyzer -p *_unittest.py \
+ && touch extra/stack_analyzer/.tests-passed
diff --git a/util/presubmit_check.sh b/util/presubmit_check.sh
index b4024dbfd8..b11c8dec47 100755
--- a/util/presubmit_check.sh
+++ b/util/presubmit_check.sh
@@ -9,10 +9,14 @@ if [[ ! -e .tests-passed ]]; then
exit 1
fi
+# Directories that need to be tested by separate unit tests.
+unittest_dirs="util/ec3po/ extra/stack_analyzer/"
+
changed=$(find ${PRESUBMIT_FILES} -newer .tests-passed)
-ec3po_files=$(echo "${PRESUBMIT_FILES}" | grep util/ec3po/)
-# Filter out ec3po files from changed files. They're handled separately.
-changed=$(echo "${changed}" | grep -v util/ec3po/)
+# Filter out unittest_dirs files from changed files. They're handled separately.
+for dir in $unittest_dirs; do
+ changed=$(echo "${changed}" | grep -v "${dir}")
+done
# Filter out flash_ec since it's not part of any unit tests.
changed=$(echo "${changed}" | grep -v util/flash_ec)
# Filter out this file itself.
@@ -24,15 +28,22 @@ if [[ -n "${changed}" ]]; then
exit 1
fi
-if [[ ! -e util/ec3po/.tests-passed ]] && [[ -n "${ec3po_files}" ]]; then
- echo 'Unit tests have not passed. Please run "util/ec3po/run_tests.sh".'
- exit 1
-fi
+for dir in $unittest_dirs; do
+ dir_files=$(echo "${PRESUBMIT_FILES}" | grep "${dir}")
+ if [[ -z "${dir_files}" ]]; then
+ continue
+ fi
-changed_ec3po_files=$(find ${ec3po_files} -newer util/ec3po/.tests-passed)
-if [[ -n "${changed_ec3po_files}" ]] && [[ -n "${ec3po_files}" ]]; then
- echo "Files have changed since last time EC-3PO unit tests passed:"
- echo "${changed_ec3po_files}" | sed -e 's/^/ /'
- echo 'Please run "util/ec3po/run_tests.sh".'
- exit 1
-fi
+ if [[ ! -e "${dir}/.tests-passed" ]]; then
+ echo "Unit tests have not passed. Please run \"${dir}run_tests.sh\"."
+ exit 1
+ fi
+
+ changed_files=$(find ${dir_files} -newer "${dir}/.tests-passed")
+ if [[ -n "${changed_files}" ]] && [[ -n "${dir_files}" ]]; then
+ echo "Files have changed since last time unit tests passed:"
+ echo "${changed_files}" | sed -e 's/^/ /'
+ echo "Please run \"${dir}run_tests.sh\"."
+ exit 1
+ fi
+done