check-warnings.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # Colors
  3. RED='\033[0;31m'
  4. GREEN='\033[0;32m'
  5. BOLD='\e[1m'
  6. NC='\033[0;0m' # No color, unmodified characters
  7. allowed=(18236 276020 15064 169177 171167 15705 15714 13024 21074 10036 12240 35016 332043)
  8. IFS='
  9. '
  10. function check_problems() {
  11. for x in ${@}; do
  12. code=`echo $x | cut -d "(" -f2 | cut -d ")" -f1`
  13. if [[ "${allowed[@]}" =~ "$code" ]]; then
  14. line="${GREEN}[ALLOWED]${NC} ${x}";
  15. #echo -e ${line:0:`tput cols`};
  16. echo -e ${line};
  17. else
  18. line="${RED}[NOT ALLOWED]${NC} ${x}";
  19. echo -e ${line};
  20. fi
  21. done
  22. }
  23. warning_count=`grep -c -e '^Warning (' $1`;
  24. inferred_latche_count=`grep -c -e '^Info (10041)' $1`;
  25. crit_warning_count=`grep -c -e '^Critical Warning (' $1`;
  26. error_count=`grep -c -e '^Error (' $1`;
  27. # Check for warnings
  28. if ((${warning_count} > 0)); then
  29. echo -e "${BOLD}-------- Found ${warning_count} Warnings${NC}";
  30. warnings=`grep -e '^Warning (' $1`;
  31. check_problems ${warnings};
  32. fi
  33. # Check for inferred latches
  34. if ((${inferred_latche_count} > 0)); then
  35. echo -e "${BOLD}-------- Found ${inferred_latche_count} Inferred Latches${NC}";
  36. inferred_latches=`grep -e '^Info (10041)' $1`;
  37. check_problems ${inferred_latches};
  38. fi
  39. # Check for critical warnings
  40. if ((${crit_warning_count} > 0)); then
  41. echo -e "${BOLD}-------- Found ${crit_warning_count} Critical Warnings${NC}";
  42. crit_warnings=`grep -e '^Critical Warning (' $1`;
  43. check_problems ${crit_warnings};
  44. fi
  45. # Check for errors
  46. if ((${error_count} > 0)); then
  47. echo -e "${BOLD}-------- Found ${error_count} Errors${NC}";
  48. errors=`grep -e '^Error (' $1`;
  49. check_problems ${errors};
  50. fi
  51. summary="${BOLD}-------- ${error_count} Errors, ${crit_warning_count} Critical Warnings, ${inferred_latche_count} Inferred Latches, ${warning_count} Warnings${NC}";
  52. echo -e ${summary}