aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2019-11-08 11:14:52 +0100
committerVratko Polak <vrpolak@cisco.com>2019-11-08 13:48:08 +0100
commitb0d6fc976be09da5d5c0d57b58a87d8b0b286ca4 (patch)
treeef893e8b4f4b827b364cfbbf5ccc2321e150cba1
parente426a0bdf65badd2ffc6b0defdb01094bfb33578 (diff)
Prevent many TC triggered by bad tag expressions
Typical example: Use multiple perftest lines in a comment. Atypical example: Use perftest as an expression (without any ANDs). Fix: Die if "perftest" is found in the tag expression (before prefixing). Change-Id: I0230541b30557ce7a4e9d57c8303cd432f86747d Signed-off-by: Vratko Polak <vrpolak@cisco.com>
-rw-r--r--resources/libraries/bash/function/common.sh10
1 files changed, 8 insertions, 2 deletions
diff --git a/resources/libraries/bash/function/common.sh b/resources/libraries/bash/function/common.sh
index c1593b2466..93adda7e0c 100644
--- a/resources/libraries/bash/function/common.sh
+++ b/resources/libraries/bash/function/common.sh
@@ -515,8 +515,8 @@ function get_test_tag_string () {
*"device"*)
# On parsing error, ${trigger} stays empty.
trigger="$(echo "${GERRIT_EVENT_COMMENT_TEXT}" \
- | grep -oE '(devicetest$|devicetest[[:space:]].+$)')" \
- || true
+ | grep -oE '(devicetest$|devicetest[[:space:]].+$)' \
+ || true)"
# Set test tags as string.
TEST_TAG_STRING="${trigger#$"devicetest"}"
;;
@@ -876,6 +876,12 @@ function select_tags () {
if [[ "${tag}" == "!"* ]]; then
# Exclude tags are not prefixed.
TAGS+=("${tag}")
+ elif [[ "${tag}" == " "* || "${tag}" == *"perftest"* ]]; then
+ # Badly formed tag expressions can trigger way too much tests.
+ set -x
+ warn "The following tag expression hints at bad trigger: ${tag}"
+ warn "Possible cause: Multiple triggers in a single comment."
+ die "Aborting to avoid triggering too many tests."
elif [[ "${tag}" != "" && "${tag}" != "#"* ]]; then
# Empty and comment lines are skipped.
# Other lines are normal tags, they are to be prefixed.