]> granicus.if.org Git - esp-idf/commitdiff
unit tests: Use a unit test app partition table, configure spi_flash to use data...
authorAngus Gratton <angus@espressif.com>
Tue, 21 Feb 2017 02:40:42 +0000 (13:40 +1100)
committerAngus Gratton <angus@espressif.com>
Tue, 21 Feb 2017 23:26:04 +0000 (10:26 +1100)
components/spi_flash/test/test_flash_encryption.c
components/spi_flash/test/test_mmap.c
components/spi_flash/test/test_read_write.c
components/spi_flash/test/test_spi_flash.c
tools/unit-test-app/components/unity/include/test_utils.h [moved from components/spi_flash/test/test_config.h with 63% similarity]
tools/unit-test-app/components/unity/test_utils.c [new file with mode: 0644]
tools/unit-test-app/partition_table_unit_test_app.csv [new file with mode: 0644]
tools/unit-test-app/sdkconfig

index b8d8018ae47d180d5c4170b6d88afe4a9b487193..16579930c6059ada526864a7b411eb703191b2c6 100644 (file)
@@ -4,23 +4,35 @@
 #include <freertos/semphr.h>
 
 #include <unity.h>
+#include <test_utils.h>
 #include <esp_spi_flash.h>
 #include <esp_attr.h>
 #include <esp_flash_encrypt.h>
 
-#include "test_config.h"
-
 static void test_encrypted_write(size_t offset, const uint8_t *data, size_t length);
 static void verify_erased_flash(size_t offset, size_t length);
 
+static size_t start;
+
+static void setup_tests()
+{
+    if (start == 0) {
+        const esp_partition_t *part = get_test_data_partition();
+        start = part->address;
+        printf("Test data partition @ 0x%x\n", start);
+    }
+}
+
 TEST_CASE("test 16 byte encrypted writes", "[spi_flash]")
 {
+    setup_tests();
+
     if (!esp_flash_encryption_enabled()) {
         TEST_IGNORE_MESSAGE("flash encryption disabled, skipping spi_flash_write_encrypted() tests");
     }
 
     TEST_ASSERT_EQUAL_HEX(ESP_OK,
-                      spi_flash_erase_sector(TEST_REGION_START / SPI_FLASH_SEC_SIZE));
+                      spi_flash_erase_sector(start / SPI_FLASH_SEC_SIZE));
 
     uint8_t fortyeight_bytes[0x30]; // 0, 1, 2, 3, 4... 47
     for(int i = 0; i < sizeof(fortyeight_bytes); i++) {
@@ -29,38 +41,38 @@ TEST_CASE("test 16 byte encrypted writes", "[spi_flash]")
 
     /* Verify unaligned start or length fails */
     TEST_ASSERT_EQUAL_HEX(ESP_ERR_INVALID_ARG,
-                      spi_flash_write_encrypted(TEST_REGION_START+1, fortyeight_bytes, 32));
+                      spi_flash_write_encrypted(start+1, fortyeight_bytes, 32));
 
     TEST_ASSERT_EQUAL_HEX(ESP_ERR_INVALID_SIZE,
-                      spi_flash_write_encrypted(TEST_REGION_START, fortyeight_bytes, 15));
+                      spi_flash_write_encrypted(start, fortyeight_bytes, 15));
 
     /* ensure nothing happened to the flash yet */
-    verify_erased_flash(TEST_REGION_START, 0x20);
+    verify_erased_flash(start, 0x20);
 
     /* Write 32 byte block, this is the "normal" encrypted write */
-    test_encrypted_write(TEST_REGION_START, fortyeight_bytes, 0x20);
-    verify_erased_flash(TEST_REGION_START + 0x20, 0x20);
+    test_encrypted_write(start, fortyeight_bytes, 0x20);
+    verify_erased_flash(start + 0x20, 0x20);
 
     /* Slip in an unaligned spi_flash_read_encrypted() test */
     uint8_t buf[0x10];
-    spi_flash_read_encrypted(TEST_REGION_START+0x10, buf, 0x10);
+    spi_flash_read_encrypted(start+0x10, buf, 0x10);
     TEST_ASSERT_EQUAL_HEX8_ARRAY(fortyeight_bytes+0x10, buf, 16);
 
     /* Write 16 bytes unaligned */
-    test_encrypted_write(TEST_REGION_START + 0x30, fortyeight_bytes, 0x10);
+    test_encrypted_write(start + 0x30, fortyeight_bytes, 0x10);
     /* the 16 byte regions before and after the 16 bytes we just wrote should still be 0xFF */
-    verify_erased_flash(TEST_REGION_START + 0x20, 0x10);
-    verify_erased_flash(TEST_REGION_START + 0x40, 0x10);
+    verify_erased_flash(start + 0x20, 0x10);
+    verify_erased_flash(start + 0x40, 0x10);
 
     /* Write 48 bytes starting at a 32-byte aligned offset */
-    test_encrypted_write(TEST_REGION_START + 0x40, fortyeight_bytes, 0x30);
+    test_encrypted_write(start + 0x40, fortyeight_bytes, 0x30);
     /* 16 bytes after this write should still be 0xFF -unencrypted- */
-    verify_erased_flash(TEST_REGION_START + 0x70, 0x10);
+    verify_erased_flash(start + 0x70, 0x10);
 
     /* Write 48 bytes starting at a 16-byte aligned offset */
-    test_encrypted_write(TEST_REGION_START + 0x90, fortyeight_bytes, 0x30);
+    test_encrypted_write(start + 0x90, fortyeight_bytes, 0x30);
     /* 16 bytes after this write should still be 0xFF -unencrypted- */
-    verify_erased_flash(TEST_REGION_START + 0x120, 0x10);
+    verify_erased_flash(start + 0x120, 0x10);
 }
 
 static void test_encrypted_write(size_t offset, const uint8_t *data, size_t length)
index facc1ffded3c9076df6f939c8094f4b2b6a208fd..a2ef0fd56f8e1dba3c56798578aa38cd98d2e97b 100644 (file)
 #include <esp_partition.h>
 #include <esp_flash_encrypt.h>
 
-#include "test_config.h"
+#include "test_utils.h"
 
 static uint32_t buffer[1024];
 
-/* read-only region used for mmap tests */
-static const uint32_t start = 0x100000;
-static const uint32_t end = 0x200000;
+/* read-only region used for mmap tests, intialised in setup_mmap_tests() */
+static uint32_t start;
+static uint32_t end;
 
 static spi_flash_mmap_handle_t handle1, handle2, handle3;
 
 static void setup_mmap_tests()
 {
+    if (start == 0) {
+        const esp_partition_t *part = get_test_data_partition();
+        start = part->address;
+        end = part->address + part->size;
+        printf("Test data partition @ 0x%x - 0x%x\n", start, end);
+    }
+    TEST_ASSERT(end > start);
+    TEST_ASSERT(end - start >= 512*1024);
+
     /* clean up any mmap handles left over from failed tests */
     if (handle1) {
         spi_flash_munmap(handle1);
@@ -41,7 +50,7 @@ static void setup_mmap_tests()
     srand(0);
     for (int block = start / 0x10000; block < end / 0x10000; ++block) {
         for (int sector = 0; sector < 16; ++sector) {
-            uint32_t abs_sector = (block) * 16 + sector;
+            uint32_t abs_sector = (block * 16) + sector;
             uint32_t sector_offs = abs_sector * SPI_FLASH_SEC_SIZE;
             bool sector_needs_write = false;
 
@@ -50,7 +59,7 @@ static void setup_mmap_tests()
             for (uint32_t word = 0; word < 1024; ++word) {
                 uint32_t val = rand();
                 if (block == start / 0x10000 && sector == 0 && word == 0) {
-                    printf("setup_mmap_tests(): first prepped word: %08x\n", val);
+                    printf("setup_mmap_tests(): first prepped word: 0x%08x (flash holds 0x%08x)\n", val, buffer[word]);
                 }
                 if (buffer[word] != val) {
                     buffer[word] = val;
@@ -67,7 +76,7 @@ static void setup_mmap_tests()
     }
 }
 
-TEST_CASE("Can mmap into data address space", "[mmap]")
+TEST_CASE("Can mmap into data address space", "[spi_flash]")
 {
     setup_mmap_tests();
 
@@ -81,9 +90,11 @@ TEST_CASE("Can mmap into data address space", "[mmap]")
     srand(0);
     const uint32_t *data = (const uint32_t *) ptr1;
     for (int block = 0; block < (end - start) / 0x10000; ++block) {
+        printf("block %d\n", block);
         for (int sector = 0; sector < 16; ++sector) {
+            printf("sector %d\n", sector);
             for (uint32_t word = 0; word < 1024; ++word) {
-                TEST_ASSERT_EQUAL_UINT32(rand(), data[(block * 16 + sector) * 1024 + word]);
+                TEST_ASSERT_EQUAL_HEX32(rand(), data[(block * 16 + sector) * 1024 + word]);
             }
         }
     }
@@ -137,10 +148,10 @@ TEST_CASE("flash_mmap invalidates just-written data", "[spi_flash]")
         TEST_IGNORE_MESSAGE("flash encryption enabled, spi_flash_write_encrypted() test won't pass as-is");
     }
 
-    ESP_ERROR_CHECK( spi_flash_erase_sector(TEST_REGION_START / SPI_FLASH_SEC_SIZE) );
+    ESP_ERROR_CHECK( spi_flash_erase_sector(start / SPI_FLASH_SEC_SIZE) );
 
     /* map erased test region to ptr1 */
-    ESP_ERROR_CHECK( spi_flash_mmap(TEST_REGION_START, test_size, SPI_FLASH_MMAP_DATA, &ptr1, &handle1) );
+    ESP_ERROR_CHECK( spi_flash_mmap(start, test_size, SPI_FLASH_MMAP_DATA, &ptr1, &handle1) );
     printf("mmap_res ptr1: handle=%d ptr=%p\n", handle1, ptr1);
 
     /* verify it's all 0xFF */
@@ -155,14 +166,14 @@ TEST_CASE("flash_mmap invalidates just-written data", "[spi_flash]")
     /* write flash region to 0xEE */
     uint8_t buf[test_size];
     memset(buf, 0xEE, test_size);
-    ESP_ERROR_CHECK( spi_flash_write(TEST_REGION_START, buf, test_size) );
+    ESP_ERROR_CHECK( spi_flash_write(start, buf, test_size) );
 
     /* re-map the test region at ptr1.
 
        this is a fresh mmap call so should trigger a cache flush,
        ensuring we see the updated flash.
     */
-    ESP_ERROR_CHECK( spi_flash_mmap(TEST_REGION_START, test_size, SPI_FLASH_MMAP_DATA, &ptr1, &handle1) );
+    ESP_ERROR_CHECK( spi_flash_mmap(start, test_size, SPI_FLASH_MMAP_DATA, &ptr1, &handle1) );
     printf("mmap_res ptr1 #2: handle=%d ptr=%p\n", handle1, ptr1);
 
     /* assert that ptr1 now maps to the new values on flash,
@@ -176,7 +187,9 @@ TEST_CASE("flash_mmap invalidates just-written data", "[spi_flash]")
 
 TEST_CASE("phys2cache/cache2phys basic checks", "[spi_flash]")
 {
-    uint8_t buf_a[32], buf_b[32];
+    uint8_t buf[64];
+
+    static const uint8_t constant_data[] = { 1, 2, 3, 7, 11, 16, 3, 88 };
 
     /* esp_partition_find is in IROM */
     uint32_t phys = spi_flash_cache2phys(esp_partition_find);
@@ -184,27 +197,25 @@ TEST_CASE("phys2cache/cache2phys basic checks", "[spi_flash]")
     TEST_ASSERT_EQUAL_PTR(esp_partition_find, spi_flash_phys2cache(phys, SPI_FLASH_MMAP_INST));
     TEST_ASSERT_EQUAL_PTR(NULL, spi_flash_phys2cache(phys, SPI_FLASH_MMAP_DATA));
 
-    /* Read the flash @ 'phys' and compare it to the data we get via cache */
-    memcpy(buf_a, esp_partition_find, sizeof(buf_a));
-    spi_flash_read(phys, buf_b, sizeof(buf_b));
-    TEST_ASSERT_EQUAL_HEX8_ARRAY(buf_a, buf_b, sizeof(buf_b));
+    /* Read the flash @ 'phys' and compare it to the data we get via regular cache access */
+    spi_flash_read(phys, buf, sizeof(buf));
+    TEST_ASSERT_EQUAL_HEX32_ARRAY((void *)esp_partition_find, buf, sizeof(buf)/sizeof(uint32_t));
 
     /* spi_flash_mmap is in IRAM */
     printf("%p\n", spi_flash_mmap);
     TEST_ASSERT_EQUAL_HEX32(SPI_FLASH_CACHE2PHYS_FAIL,
                             spi_flash_cache2phys(spi_flash_mmap));
 
-    /* 'start' should be in DROM */
-    phys = spi_flash_cache2phys(&start);
+    /* 'constant_data' should be in DROM */
+    phys = spi_flash_cache2phys(&constant_data);
     TEST_ASSERT_NOT_EQUAL(SPI_FLASH_CACHE2PHYS_FAIL, phys);
-    TEST_ASSERT_EQUAL_PTR(&start,
+    TEST_ASSERT_EQUAL_PTR(&constant_data,
                           spi_flash_phys2cache(phys, SPI_FLASH_MMAP_DATA));
     TEST_ASSERT_EQUAL_PTR(NULL, spi_flash_phys2cache(phys, SPI_FLASH_MMAP_INST));
 
-    /* Read the flash @ 'phys' and compare it to the data we get via cache */
-    memcpy(buf_a, &start, sizeof(start));
-    spi_flash_read(phys, buf_b, sizeof(start));
-    TEST_ASSERT_EQUAL_HEX8_ARRAY(buf_a, buf_b, sizeof(start));
+    /* Read the flash @ 'phys' and compare it to the data we get via normal cache access */
+    spi_flash_read(phys, buf, sizeof(constant_data));
+    TEST_ASSERT_EQUAL_HEX8_ARRAY(constant_data, buf, sizeof(constant_data));
 }
 
 TEST_CASE("mmap consistent with phys2cache/cache2phys", "[spi_flash]")
@@ -216,15 +227,15 @@ TEST_CASE("mmap consistent with phys2cache/cache2phys", "[spi_flash]")
 
     TEST_ASSERT_EQUAL_HEX(SPI_FLASH_CACHE2PHYS_FAIL, spi_flash_cache2phys(ptr));
 
-    ESP_ERROR_CHECK( spi_flash_mmap(TEST_REGION_START, test_size, SPI_FLASH_MMAP_DATA, &ptr, &handle1) );
+    ESP_ERROR_CHECK( spi_flash_mmap(start, test_size, SPI_FLASH_MMAP_DATA, &ptr, &handle1) );
     TEST_ASSERT_NOT_NULL(ptr);
     TEST_ASSERT_NOT_EQUAL(0, handle1);
 
-    TEST_ASSERT_EQUAL_HEX(TEST_REGION_START, spi_flash_cache2phys(ptr));
-    TEST_ASSERT_EQUAL_HEX(TEST_REGION_START + 1024, spi_flash_cache2phys((void *)((intptr_t)ptr + 1024)));
-    TEST_ASSERT_EQUAL_HEX(TEST_REGION_START + 3000, spi_flash_cache2phys((void *)((intptr_t)ptr + 3000)));
+    TEST_ASSERT_EQUAL_HEX(start, spi_flash_cache2phys(ptr));
+    TEST_ASSERT_EQUAL_HEX(start + 1024, spi_flash_cache2phys((void *)((intptr_t)ptr + 1024)));
+    TEST_ASSERT_EQUAL_HEX(start + 3000, spi_flash_cache2phys((void *)((intptr_t)ptr + 3000)));
     /* this pointer lands in a different MMU table entry */
-    TEST_ASSERT_EQUAL_HEX(TEST_REGION_START + test_size - 4, spi_flash_cache2phys((void *)((intptr_t)ptr + test_size - 4)));
+    TEST_ASSERT_EQUAL_HEX(start + test_size - 4, spi_flash_cache2phys((void *)((intptr_t)ptr + test_size - 4)));
 
     spi_flash_munmap(handle1);
     handle1 = 0;
index 37edbbb944cba0158c14f2481c817ca39d03f80a..aca4850325d46bed6148502966e991bc2c2a05f1 100644 (file)
 #include <sys/param.h>
 
 #include <unity.h>
+#include <test_utils.h>
 #include <esp_spi_flash.h>
 #include <rom/spi_flash.h>
 #include "../cache_utils.h"
 #include "soc/timer_group_struct.h"
 #include "soc/timer_group_reg.h"
 
-#include "test_config.h"
-
 /* Base offset in flash for tests. */
-#define FLASH_BASE TEST_REGION_START
+static size_t start;
+
+static void setup_tests()
+{
+    if (start == 0) {
+        const esp_partition_t *part = get_test_data_partition();
+        start = part->address;
+        printf("Test data partition @ 0x%x\n", start);
+    }
+}
 
 #ifndef CONFIG_SPI_FLASH_MINIMAL_TEST
 #define CONFIG_SPI_FLASH_MINIMAL_TEST 1
@@ -66,21 +74,22 @@ static void IRAM_ATTR test_read(int src_off, int dst_off, int len)
     fprintf(stderr, "src=%d dst=%d len=%d\n", src_off, dst_off, len);
     memset(src_buf, 0xAA, sizeof(src_buf));
     fill(((char *) src_buf) + src_off, src_off, len);
-    ESP_ERROR_CHECK(spi_flash_erase_sector((FLASH_BASE + src_off) / SPI_FLASH_SEC_SIZE));
+    ESP_ERROR_CHECK(spi_flash_erase_sector((start + src_off) / SPI_FLASH_SEC_SIZE));
     spi_flash_disable_interrupts_caches_and_other_cpu();
-    SpiFlashOpResult rc = SPIWrite(FLASH_BASE, src_buf, sizeof(src_buf));
+    SpiFlashOpResult rc = SPIWrite(start, src_buf, sizeof(src_buf));
     spi_flash_enable_interrupts_caches_and_other_cpu();
     TEST_ASSERT_EQUAL_INT(rc, SPI_FLASH_RESULT_OK);
     memset(dst_buf, 0x55, sizeof(dst_buf));
     memset(dst_gold, 0x55, sizeof(dst_gold));
     fill(dst_gold + dst_off, src_off, len);
 
-    ESP_ERROR_CHECK(spi_flash_read(FLASH_BASE + src_off, dst_buf + dst_off, len));
+    ESP_ERROR_CHECK(spi_flash_read(start + src_off, dst_buf + dst_off, len));
     TEST_ASSERT_EQUAL_INT(cmp_or_dump(dst_buf, dst_gold, sizeof(dst_buf)), 0);
 }
 
 TEST_CASE("Test spi_flash_read", "[spi_flash_read]")
 {
+    setup_tests();
 #if CONFIG_SPI_FLASH_MINIMAL_TEST
     test_read(0, 0, 0);
     test_read(0, 0, 4);
@@ -137,7 +146,7 @@ static void IRAM_ATTR test_write(int dst_off, int src_off, int len)
     memset(src_buf, 0x55, sizeof(src_buf));
     fill(src_buf + src_off, src_off, len);
     // Fills with 0xff
-    ESP_ERROR_CHECK(spi_flash_erase_sector((FLASH_BASE + dst_off) / SPI_FLASH_SEC_SIZE));
+    ESP_ERROR_CHECK(spi_flash_erase_sector((start + dst_off) / SPI_FLASH_SEC_SIZE));
     memset(dst_gold, 0xff, sizeof(dst_gold));
     if (len > 0) {
         int pad_left_off = (dst_off & ~3U);
@@ -148,9 +157,9 @@ static void IRAM_ATTR test_write(int dst_off, int src_off, int len)
         }
         fill(dst_gold + dst_off, src_off, len);
     }
-    ESP_ERROR_CHECK(spi_flash_write(FLASH_BASE + dst_off, src_buf + src_off, len));
+    ESP_ERROR_CHECK(spi_flash_write(start + dst_off, src_buf + src_off, len));
     spi_flash_disable_interrupts_caches_and_other_cpu();
-    SpiFlashOpResult rc = SPIRead(FLASH_BASE, dst_buf, sizeof(dst_buf));
+    SpiFlashOpResult rc = SPIRead(start, dst_buf, sizeof(dst_buf));
     spi_flash_enable_interrupts_caches_and_other_cpu();
     TEST_ASSERT_EQUAL_INT(rc, SPI_FLASH_RESULT_OK);
     TEST_ASSERT_EQUAL_INT(cmp_or_dump(dst_buf, dst_gold, sizeof(dst_buf)), 0);
@@ -158,6 +167,7 @@ static void IRAM_ATTR test_write(int dst_off, int src_off, int len)
 
 TEST_CASE("Test spi_flash_write", "[spi_flash_write]")
 {
+    setup_tests();
 #if CONFIG_SPI_FLASH_MINIMAL_TEST
     test_write(0, 0, 0);
     test_write(0, 0, 4);
@@ -202,8 +212,8 @@ TEST_CASE("Test spi_flash_write", "[spi_flash_write]")
      * NB: At the moment these only support aligned addresses, because memcpy
      * is not aware of the 32-but load requirements for these regions.
      */
-    ESP_ERROR_CHECK(spi_flash_write(FLASH_BASE, (char *) 0x40000000, 16));
-    ESP_ERROR_CHECK(spi_flash_write(FLASH_BASE, (char *) 0x40070000, 16));
-    ESP_ERROR_CHECK(spi_flash_write(FLASH_BASE, (char *) 0x40078000, 16));
-    ESP_ERROR_CHECK(spi_flash_write(FLASH_BASE, (char *) 0x40080000, 16));
+    ESP_ERROR_CHECK(spi_flash_write(start, (char *) 0x40000000, 16));
+    ESP_ERROR_CHECK(spi_flash_write(start, (char *) 0x40070000, 16));
+    ESP_ERROR_CHECK(spi_flash_write(start, (char *) 0x40078000, 16));
+    ESP_ERROR_CHECK(spi_flash_write(start, (char *) 0x40080000, 16));
 }
index 90d0cc1fdcb35a2ecbb10be47fde3175bb905aa7..008286a4898f60b468117bb0cd7b65ad02e83221 100644 (file)
@@ -7,8 +7,6 @@
 #include <esp_spi_flash.h>
 #include <esp_attr.h>
 
-#include "test_config.h"
-
 struct flash_test_ctx {
     uint32_t offset;
     bool fail;
similarity index 63%
rename from components/spi_flash/test/test_config.h
rename to tools/unit-test-app/components/unity/include/test_utils.h
index 45e73661bb543f8b1c0da88f48b2c5836b42fdcb..2fad41a10a710447af09a2d6a5b7743976c9226c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
-
-// Common header for SPI flash test data
 #pragma once
 
-/* Define a region of flash we can mess up for testing...
+// Utilities for esp-idf unit tests
+
+#include <esp_partition.h>
+
+/* Return the 'flash_test' custom data partition (type 0x55)
+   defined in the custom partition table.
+*/
+const esp_partition_t *get_test_data_partition();
 
-   This is pretty ugly, better to do something with a partition but
-   this is OK for now.
- */
-#define TEST_REGION_START 0x180000
-#define TEST_REGION_END   0x1E0000
diff --git a/tools/unit-test-app/components/unity/test_utils.c b/tools/unit-test-app/components/unity/test_utils.c
new file mode 100644 (file)
index 0000000..416853a
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "unity.h"
+#include "test_utils.h"
+
+const esp_partition_t *get_test_data_partition()
+{
+    /* This user type/subtype (0x55) is set in
+       partition_table_unit_test_app.csv */
+    const esp_partition_t *result = esp_partition_find_first(0x55, 0x55, NULL);
+    TEST_ASSERT_NOT_NULL(result); /* means partition table set wrong */
+    return result;
+}
diff --git a/tools/unit-test-app/partition_table_unit_test_app.csv b/tools/unit-test-app/partition_table_unit_test_app.csv
new file mode 100644 (file)
index 0000000..b6e57b4
--- /dev/null
@@ -0,0 +1,12 @@
+# Special partition table for unit test app
+#
+# Name,     Type, SubType, Offset,   Size, Flags
+# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
+nvs,        data, nvs,     0x9000,  0x4000
+otadata,    data, ota,     0xd000,  0x2000
+phy_init,   data, phy,     0xf000,  0x1000
+factory,    0,    0,       0x10000, 1M
+ota_0,      0,    ota_0,   ,        1M
+ota_1,      0,    ota_1,   ,        1M
+# flash_test partition used for SPI flash tests
+flash_test, 0x55, 0x55,  ,        512K
index 14b31e0d18102eafd4d4062ceabb459d5a2e48d1..2945dbaf6109c1720ee0e78ad281cd876e1593ef 100644 (file)
@@ -21,12 +21,10 @@ CONFIG_LOG_BOOTLOADER_LEVEL_WARN=y
 CONFIG_LOG_BOOTLOADER_LEVEL=2
 
 #
-# Secure boot configuration
+# Security features
 #
-CONFIG_SECURE_BOOTLOADER_DISABLED=y
-# CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH is not set
-# CONFIG_SECURE_BOOTLOADER_REFLASHABLE is not set
-# CONFIG_SECURE_BOOTLOADER_ENABLED is not set
+# CONFIG_SECURE_BOOT_ENABLED is not set
+# CONFIG_FLASH_ENCRYPTION_ENABLED is not set
 
 #
 # Serial flasher config
@@ -56,39 +54,58 @@ CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
 # CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set
 # CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set
 CONFIG_ESPTOOLPY_FLASHSIZE="2MB"
+CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
+CONFIG_ESPTOOLPY_BEFORE_RESET=y
+# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set
+# CONFIG_ESPTOOLPY_BEFORE_ESP32R0 is not set
+CONFIG_ESPTOOLPY_BEFORE="default_reset"
+CONFIG_ESPTOOLPY_AFTER_RESET=y
+# CONFIG_ESPTOOLPY_AFTER_NORESET is not set
+CONFIG_ESPTOOLPY_AFTER="hard_reset"
+# CONFIG_MONITOR_BAUD_9600B is not set
+# CONFIG_MONITOR_BAUD_57600B is not set
+CONFIG_MONITOR_BAUD_115200B=y
+# CONFIG_MONITOR_BAUD_230400B is not set
+# CONFIG_MONITOR_BAUD_921600B is not set
+# CONFIG_MONITOR_BAUD_2MB is not set
+# CONFIG_MONITOR_BAUD_OTHER is not set
+CONFIG_MONITOR_BAUD_OTHER_VAL=115200
+CONFIG_MONITOR_BAUD=115200
 
 #
 # Partition Table
 #
-CONFIG_PARTITION_TABLE_SINGLE_APP=y
+# CONFIG_PARTITION_TABLE_SINGLE_APP is not set
 # CONFIG_PARTITION_TABLE_TWO_OTA is not set
-# CONFIG_PARTITION_TABLE_CUSTOM is not set
-CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
+CONFIG_PARTITION_TABLE_CUSTOM=y
+CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partition_table_unit_test_app.csv"
 CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET=0x10000
-CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv"
+CONFIG_PARTITION_TABLE_FILENAME="partition_table_unit_test_app.csv"
 CONFIG_APP_OFFSET=0x10000
-CONFIG_PHY_DATA_OFFSET=0xf000
+CONFIG_PHY_DATA_OFFSET=
 CONFIG_OPTIMIZATION_LEVEL_DEBUG=y
 # CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set
 
 #
 # Component config
 #
-CONFIG_BTC_TASK_STACK_SIZE=2048
+# CONFIG_BT_ENABLED is not set
 CONFIG_BT_RESERVE_DRAM=0
 
 #
-# ESP32-specific config
+# ESP32-specific
 #
 # CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set
 # CONFIG_ESP32_DEFAULT_CPU_FREQ_160 is not set
 CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
 CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240
-# CONFIG_ESP32_ENABLE_STACK_WIFI is not set
-# CONFIG_ESP32_ENABLE_STACK_BT is not set
 CONFIG_MEMMAP_SMP=y
 # CONFIG_MEMMAP_TRACEMEM is not set
 CONFIG_TRACEMEM_RESERVE_DRAM=0x0
+# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set
+# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set
+CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y
+# CONFIG_ESP32_ENABLE_COREDUMP is not set
 CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32
 CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2048
 CONFIG_MAIN_TASK_STACK_SIZE=4096
@@ -115,8 +132,17 @@ CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y
 # CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set
 # CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set
 CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y
+CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=0
+CONFIG_WIFI_ENABLED=y
+CONFIG_ESP32_WIFI_RX_BUFFER_NUM=10
+CONFIG_PHY_ENABLED=y
+
+#
+# PHY
+#
 CONFIG_ESP32_PHY_AUTO_INIT=y
 # CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set
+CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20
 CONFIG_ESP32_PHY_MAX_TX_POWER=20
 # CONFIG_ETHERNET is not set
 
@@ -126,7 +152,6 @@ CONFIG_ESP32_PHY_MAX_TX_POWER=20
 # CONFIG_FREERTOS_UNICORE is not set
 CONFIG_FREERTOS_CORETIMER_0=y
 # CONFIG_FREERTOS_CORETIMER_1 is not set
-# CONFIG_FREERTOS_CORETIMER_2 is not set
 CONFIG_FREERTOS_HZ=1000
 CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y
 # CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set
@@ -161,7 +186,13 @@ CONFIG_LOG_COLORS=y
 CONFIG_LWIP_MAX_SOCKETS=4
 CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX=0
 # CONFIG_LWIP_SO_REUSE is not set
+# CONFIG_LWIP_SO_RCVBUF is not set
 CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1
+# CONFIG_LWIP_IP_FRAG is not set
+# CONFIG_LWIP_IP_REASSEMBLY is not set
+CONFIG_TCP_MAXRTX=12
+CONFIG_TCP_SYNMAXRTX=6
+# CONFIG_LWIP_DHCP_DOES_ARP_CHECK is not set
 
 #
 # mbedTLS
@@ -175,6 +206,13 @@ CONFIG_MBEDTLS_HARDWARE_SHA=y
 CONFIG_MBEDTLS_HAVE_TIME=y
 # CONFIG_MBEDTLS_HAVE_TIME_DATE is not set
 
+#
+# OpenSSL
+#
+# CONFIG_OPENSSL_DEBUG is not set
+CONFIG_OPENSSL_ASSERT_DO_NOTHING=y
+# CONFIG_OPENSSL_ASSERT_EXIT is not set
+
 #
 # SPI Flash driver
 #