tests_defaultcfg.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. echo -e ""
  3. echo -e "0.1 - Full comparison Output"
  4. echo -e "=================================================================="
  5. echo -e "Description:"
  6. echo -e "test checks that vars present in ALL _default.cfg files are correct."
  7. echo -e ""
  8. find "lgsm/config-default/config-lgsm/" ! -name '*template.cfg' -name "*.cfg" -type f -print0 |
  9. while IFS= read -r -d $'\0' line; do
  10. grep = ${line} | cut -f1 -d"=" > defaultcfgtemp.txt
  11. diffoutput=$(diff tests/tests_defaultcfg/defaultcfg_0.txt defaultcfgtemp.txt)
  12. if [ "${diffoutput}" ]; then
  13. echo "File with errors:"
  14. echo "${line}"
  15. echo -e "================================="
  16. echo "${diffoutput}"
  17. echo ""
  18. fi
  19. rm defaultcfgtemp.txt
  20. done
  21. echo -e ""
  22. echo -e "1.0 - Master Comparison"
  23. echo -e "=================================================================="
  24. echo -e "Description:"
  25. echo -e "test checks that vars present in ALL _default.cfg files are correct."
  26. echo -e ""
  27. find lgsm/config-default/config-lgsm/ ! -name '*template.cfg' -name "*.cfg" -type f -print0 |
  28. while IFS= read -r -d $'\0' line; do
  29. grep "=" "${line}" | cut -f1 -d"=" > defaultcfgtemp.txt
  30. diffoutput=$(diff tests/tests_defaultcfg/defaultcfg_0.txt defaultcfgtemp.txt | grep '^<')
  31. if [ "${diffoutput}" ]; then
  32. echo "File with errors:"
  33. echo "${line}"
  34. echo -e "================================="
  35. echo "${diffoutput}"
  36. echo ""
  37. fi
  38. rm defaultcfgtemp.txt
  39. done
  40. echo -e ""
  41. echo -e "2.0 - Check Comment"
  42. echo -e "=================================================================="
  43. echo -e "Description:"
  44. echo -e "test checks that comments in ALL _default.cfg files are correct."
  45. echo -e ""
  46. find lgsm/config-default/config-lgsm/ ! -name '*template.cfg' -name "*.cfg" -type f -print0 |
  47. while IFS= read -r -d $'\0' line; do
  48. grep "#" "${line}" > defaultcfgtemp.txt
  49. diffoutput=$(diff tests/tests_defaultcfg/defaultcfg_1.txt defaultcfgtemp.txt | grep '^<')
  50. if [ "${diffoutput}" ]; then
  51. echo "File with errors:"
  52. echo "${line}"
  53. echo -e "================================="
  54. echo "${diffoutput}"
  55. echo ""
  56. fi
  57. rm defaultcfgtemp.txt
  58. done