Fix UBSan errors counter in the 'report' command script 81/158381/5
authorDmitriy Nikiforov <d.nikiforov@samsung.com>
Tue, 31 Oct 2017 11:23:15 +0000 (14:23 +0300)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Tue, 7 Nov 2017 12:33:57 +0000 (12:33 +0000)
Count number of matches instead of words in every matched line.

Also, changed [CRASH] label to less confusing [FAILED].

Change-Id: I7bfdbcfc1de5deafba543824563905c36f91866b

infra/commands/report.sh

index 928ec3a..d9897fd 100755 (executable)
@@ -112,11 +112,12 @@ for i in "${!logs[@]}"; do
     done
 
     # get UBSan errors
-    ubsan_errors=($(grep "runtime error" "${run_dir}/${symbolized}" || :))
+    # ignore error codes from grep - it returns non-zero code if it does not find any matches
+    ubsan_errors=$(grep -c "runtime error" "${run_dir}/${symbolized}" || true)
 
-    if (( ${#crash_inputs[@]} + ${#ubsan_errors[@]} > 0 )); then
-        (( errors_num += ${#crash_inputs[@]} + ${#ubsan_errors[@]} ))
-        printf_err " [CRASH]"
+    if (( ${#crash_inputs[@]} + ubsan_errors > 0 )); then
+        (( errors_num += ${#crash_inputs[@]} + ubsan_errors ))
+        printf_err " [FAILED]"
     fi
 
     printf_err "\n"