فهرست منبع

CI: Fix the test "smallest partition is nearly full"

This test will not fail anymore if the binary size is bigger than 170K.
Omar Chebib 3 سال پیش
والد
کامیت
4e7ba0f8bd
1فایلهای تغییر یافته به همراه16 افزوده شده و 2 حذف شده
  1. 16 2
      tools/ci/test_build_system_cmake.sh

+ 16 - 2
tools/ci/test_build_system_cmake.sh

@@ -38,6 +38,14 @@ export PATH="$IDF_PATH/tools:$PATH"  # for idf.py
 # Some tests assume that ccache is not enabled
 unset IDF_CCACHE_ENABLE
 
+function get_file_size() {
+  if [[ $OSTYPE == 'darwin'* ]]; then
+    BINSIZE=$(stat -f "%z" ${1})
+  else
+    BINSIZE=$(stat -c "%s" ${1})
+  fi
+}
+
 function run_tests()
 {
     FAILURES=
@@ -816,14 +824,20 @@ endmenu\n" >> ${IDF_PATH}/Kconfig
 
     print_status "Warning is given if smallest partition is nearly full"
     clean_build_dir
+    # Build a first time to get the binary size and to check that no warning is issued.
+    ( idf.py build 2>&1 | grep "partition is nearly full" ) && failure "Warning for nearly full smallest partition was given when the condition is not fulfilled"
+    # Get the size of the binary, in KB. Add 1 to the total.
+    # The goal is to create an app partition which is slightly bigger than the binary itself
+    get_file_size "build/app-template.bin"
+    # Put the returned size ($BINSIZE) in a new variable, convert it to KB and add 1
+    let size=${BINSIZE}/1024+1
     cp ${IDF_PATH}/components/partition_table/partitions_singleapp.csv partitions.csv
-    ${SED} -i "s/factory,  app,  factory, ,        1M/factory,  app,  factory, ,        170K/" partitions.csv
+    ${SED} -i "s/factory,  app,  factory, ,        1M/factory,  app,  factory, ,        ${size}K/" partitions.csv
     echo "CONFIG_PARTITION_TABLE_CUSTOM=y" > sdkconfig
     # don't use FreeRTOS SMP build for this test - follow up ticket: IDF-5386
     echo "CONFIG_FREERTOS_SMP=n" >> sdkconfig
     ( idf.py build 2>&1 | grep "partition is nearly full" ) || failure "No warning for nearly full smallest partition was given when the condition is fulfilled"
     rm -f partitions.csv sdkconfig
-    ( idf.py build 2>&1 | grep "partition is nearly full" ) && failure "Warning for nearly full smallest partition was given when the condition is not fulfilled"
 
     print_status "Flash size is correctly set in the bootloader image header"
     # Build with the default 2MB setting