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