test.sh 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/usr/bin/env bash
  2. memory_test () {
  3. pushd $IDF_PATH/examples/get-started/hello_world \
  4. && echo -e "\n***\nBuilding project for $1..." &>> $IDF_PATH/tools/test_idf_size/output \
  5. && idf.py set-target $1 \
  6. && idf.py build \
  7. && echo -e "\n***\nRunning mem_test.py for $1..." &>> $IDF_PATH/tools/test_idf_size/output \
  8. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json build/hello-world.map > size_output.json \
  9. && python $IDF_PATH/components/esptool_py/esptool/esptool.py --chip $1 image_info build/hello-world.bin > esptool_output \
  10. && python -m coverage run -a $IDF_PATH/tools/test_idf_size/mem_test.py size_output.json esptool_output &>> $IDF_PATH/tools/test_idf_size/output \
  11. && popd
  12. }
  13. { python -m coverage debug sys \
  14. && python -m coverage erase &> output \
  15. && memory_test esp32 \
  16. && memory_test esp32s2 \
  17. && echo -e "\n***\nRunning idf_size.py..." &>> output \
  18. && coverage run -a $IDF_PATH/tools/idf_size.py app.map &>> output \
  19. && echo -e "\n***\nRunning idf_size.py on bootloader..." &>> output \
  20. && coverage run -a $IDF_PATH/tools/idf_size.py bootloader.map &>> output \
  21. && echo -e "\n***\nRunning idf_size.py --archives..." &>> output \
  22. && coverage run -a $IDF_PATH/tools/idf_size.py --archives app.map &>> output \
  23. && echo -e "\n***\nRunning idf_size.py --files..." &>> output \
  24. && coverage run -a $IDF_PATH/tools/idf_size.py --files app.map &>> output \
  25. && echo -e "\n***\nRunning idf_size.py --archive_details..." &>> output \
  26. && coverage run -a $IDF_PATH/tools/idf_size.py --archive_details libdriver.a app.map &>> output \
  27. && echo -e "\n***\nRunning idf_size.py diff with bootloader..." &>> output \
  28. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --diff bootloader.map &>> output \
  29. && echo -e "\n***\nRunning idf_size.py diff with itself..." &>> output \
  30. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --diff app.map &>> output \
  31. && echo -e "\n***\nRunning idf_size.py diff with another app..." &>> output \
  32. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --diff app2.map &>> output \
  33. && echo -e "\n***\nRunning idf_size.py diff with app in reverse order..." &>> output \
  34. && coverage run -a $IDF_PATH/tools/idf_size.py app2.map --diff app.map &>> output \
  35. && echo -e "\n***\nRunning idf_size.py diff --archives with bootloader..." &>> output \
  36. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --archives --diff bootloader.map &>> output \
  37. && echo -e "\n***\nRunning idf_size.py diff --archives with itself..." &>> output \
  38. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --archives --diff app.map &>> output \
  39. && echo -e "\n***\nRunning idf_size.py diff --archives with another app..." &>> output \
  40. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --archives --diff app2.map &>> output \
  41. && echo -e "\n***\nRunning idf_size.py diff --archives with app in reverse order..." &>> output \
  42. && coverage run -a $IDF_PATH/tools/idf_size.py app2.map --archives --diff app.map &>> output \
  43. && echo -e "\n***\nRunning idf_size.py diff --files with bootloader..." &>> output \
  44. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --files --diff bootloader.map &>> output \
  45. && echo -e "\n***\nRunning idf_size.py diff --files with itself..." &>> output \
  46. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --files --diff app.map &>> output \
  47. && echo -e "\n***\nRunning idf_size.py diff --files with another app..." &>> output \
  48. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --files --diff app2.map &>> output \
  49. && echo -e "\n***\nRunning idf_size.py diff --files with app in reverse order..." &>> output \
  50. && coverage run -a $IDF_PATH/tools/idf_size.py app2.map --files --diff app.map &>> output \
  51. && echo -e "\n***\nRunning idf_size.py diff --archive_details with bootloader..." &>> output \
  52. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --archive_details libdriver.a --diff bootloader.map &>> output \
  53. && echo -e "\n***\nRunning idf_size.py diff --archive_details with bootloader..." &>> output \
  54. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --archive_details libc.a --diff bootloader.map &>> output \
  55. && echo -e "\n***\nRunning idf_size.py diff --archive_details with itself..." &>> output \
  56. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --archive_details libdriver.a --diff app.map &>> output \
  57. && echo -e "\n***\nRunning idf_size.py diff --archive_details with another app..." &>> output \
  58. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --archive_details libdriver.a --diff app2.map &>> output \
  59. && echo -e "\n***\nRunning idf_size.py diff --archive_details with app in reverse order..." &>> output \
  60. && coverage run -a $IDF_PATH/tools/idf_size.py app2.map --archive_details libdriver.a --diff app.map &>> output \
  61. && echo -e "\n***\nRunning idf_size.py diff --archive_details with another app..." &>> output \
  62. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --archive_details libfreertos.a --diff app2.map &>> output \
  63. && echo -e "\n***\nRunning idf_size.py for esp32s2..." &>> output \
  64. && coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 app_esp32s2.map &>> output \
  65. && echo -e "\n***\nRunning idf_size.py for esp32s2 (target autodetected)..." &>> output \
  66. && coverage run -a $IDF_PATH/tools/idf_size.py app_esp32s2.map &>> output \
  67. && echo -e "\n***\nRunning idf_size.py on bootloader for esp32s2..." &>> output \
  68. && coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 bootloader_esp32s2.map &>> output \
  69. && echo -e "\n***\nRunning idf_size.py on bootloader for esp32s2 (target autodetected)..." &>> output \
  70. && coverage run -a $IDF_PATH/tools/idf_size.py bootloader_esp32s2.map &>> output \
  71. && echo -e "\n***\nRunning idf_size.py --archives for esp32s2..." &>> output \
  72. && coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 --archives app_esp32s2.map &>> output \
  73. && echo -e "\n***\nRunning idf_size.py --files for esp32s2..." &>> output \
  74. && coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 --files app_esp32s2.map &>> output \
  75. && echo -e "\n***\nRunning idf_size.py --archive_details for esp32s2..." &>> output \
  76. && coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 --archive_details libdriver.a app_esp32s2.map &>> output \
  77. && echo -e "\n***\nRunning idf_size.py diff with another app (different target)..." &>> output \
  78. && coverage run -a $IDF_PATH/tools/idf_size.py app.map --diff app_esp32s2.map &>> output \
  79. && echo -e "\n***\nProducing JSON output..." &>> output \
  80. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json app.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  81. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json --archives app.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  82. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json --files app.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  83. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json --archive_details libdriver.a app.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  84. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json app.map --diff app2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  85. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json --archives app.map --diff app2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  86. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json --files app.map --diff app2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  87. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json --archive_details libdriver.a app.map --diff app2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  88. && echo -e "\n***\nProducing JSON output for esp32s2..." &>> output \
  89. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json app_esp32s2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  90. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json --archives app_esp32s2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  91. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json --files app_esp32s2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  92. && python -m coverage run -a $IDF_PATH/tools/idf_size.py --json --archive_details libdriver.a app_esp32s2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
  93. && echo -e "\n***\nProducing JSON file output..." &>> output \
  94. && coverage run -a $IDF_PATH/tools/idf_size.py --json --output-file output.json app.map &>> output \
  95. && echo -e "\n***\nProducing text file output..." &>> output \
  96. && coverage run -a $IDF_PATH/tools/idf_size.py -o output.txt app.map &>> output \
  97. && echo -e "\n***\nRunning idf_size_tests.py..." &>> output \
  98. && coverage run -a $IDF_PATH/tools/test_idf_size/test_idf_size.py &>> output \
  99. && echo -e "\n\nComparing expected output..." \
  100. && diff -Z output expected_output \
  101. && echo -e "\n\nComparing expected json output..." \
  102. && diff -Z output.json expected_output.json \
  103. && echo -e "\n\nComparing expected text output..." \
  104. && diff -Z output.txt expected_output.txt \
  105. && coverage report \
  106. ; } || { echo 'The test for idf_size has failed. Please examine the artifacts.' ; exit 1; }
  107. # Note: "diff -Z is used because some versions of Python print trailing whitespace for JSON pretty-printing, and some don't