compileAllExamples.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/bin/bash
  2. #
  3. # testing script: compileAllExamples
  4. #
  5. # This script will compile all the local examples, optionally installing wolfSSL in the ESP-IDF components directory.
  6. #
  7. # Example usage:
  8. # cd wolfssl && docker run --rm -v $PWD:/project -w /project espressif/idf:latest IDE/Espressif/ESP-IDF/compileAllExamples.sh
  9. #
  10. # Parameter option to also run the ./setup.sh to install the wolfSSL component in ESP-IDF and test for multiple installs:
  11. #
  12. # --run-setup
  13. #
  14. # Note that once installed, the wolfSSL component will need to be manually removed to successfully run this script.
  15. #
  16. if [[ "$IDF_PATH" == "" ]]; then
  17. echo "Error: $IDF_PATH not found; run Espressif export.sh"
  18. exit 1
  19. fi
  20. SCRIPT_DIR=$(builtin cd ${BASH_SOURCE%/*}; pwd)
  21. RUN_SETUP=$1
  22. THIS_ERR=0
  23. echo "Found IDF_PATH = $IDF_PATH"
  24. # Regular tests of wolfSSL in local component directories of each project:
  25. #
  26. # Note these tests should FAIL if wolfSSL is already installed in ESP-IDF
  27. #
  28. for file in "benchmark" "client" "server" "test"; do
  29. pushd ${SCRIPT_DIR}/examples/wolfssl_${file}/ && idf.py fullclean build;
  30. THIS_ERR=$?
  31. popd
  32. if [ $THIS_ERR -ne 0 ]; then
  33. echo "Failed in ${file}"
  34. exit 1
  35. fi
  36. done
  37. # Check for option to also install wolfSSL.
  38. #
  39. # When doing so, we'll run a check that multiple installs should cause build failure.
  40. if [[ "$RUN_SETUP" == "--run-setup" ]]; then
  41. echo "Running wolfSSL setup.sh"
  42. # install wolfSSL into EDP-IDF shared components directory.
  43. ./setup.sh --verbose
  44. THIS_ERR=$?
  45. if [ $? -ne 0 ]; then
  46. echo "Failed running setup.sh"
  47. exit 1
  48. fi
  49. # Check ESP-IDF install:
  50. #
  51. # The wolfssl_test_idf should NOT have a local components/wolfssl when testing!
  52. # This test is to confirm the ESP-IDF component build properly after setup.
  53. #
  54. echo ""
  55. echo "Testing a build of wolfSSL in ESP-IDF components directory"
  56. echo ""
  57. for file in "test_idf"; do
  58. if [ -e "../../../include/user_settings.h" ]; then
  59. mv "../../../include/user_settings.h" "../../../include/user_settings.h.${file}.bak"
  60. fi
  61. pushd ${SCRIPT_DIR}/examples/wolfssl_${file}/ && idf.py fullclean build;
  62. THIS_ERR=$?
  63. popd
  64. if [ $? -ne 0 ]; then
  65. echo "Failed in ${file}"
  66. exit 1
  67. fi
  68. done
  69. # Check multiple installs: the wolfSSL component in ESP-IDF and local directory:
  70. #
  71. # The wolfssl_test project already has a local wolfSSL component directory.
  72. #
  73. # Once wolfssl has been installed to ESP-IDF components, the local
  74. # component build SHOULD fail:
  75. echo ""
  76. echo "Testing a build of wolfSSL in both local and ESP-IDF components directory"
  77. echo ""
  78. for file in "test"; do
  79. pushd ${SCRIPT_DIR}/examples/wolfssl_${file}/ && idf.py fullclean build;
  80. THIS_ERR=$?
  81. popd
  82. if [ $THIS_ERR -ne 0 ]; then
  83. echo ""
  84. echo "Success: Confirmed build fails when wolfSSL found in ESP-IDF and local project."
  85. echo ""
  86. else
  87. echo "Error: build should have failed when wolfSSL found in ESP-IDF and local project."
  88. exit 1
  89. fi
  90. done
  91. else
  92. echo "Skipping ESP-IDF install tests. For these tests, use parameter: --run-setup"
  93. fi
  94. # Show a reminder that wolfSSL was installed as a shared component.
  95. if [[ "$RUN_SETUP" == "--run-setup" ]]; then
  96. echo ""
  97. echo "wolfSSL was installed as an ESP-IDF component. This will be in conflict with any project that has a local component."
  98. echo ""
  99. echo "Delete the installed component before re-running this test."
  100. echo ""
  101. fi
  102. # Done
  103. echo "Completed compileAllExamples in $SCRIPT_DIR"