Zim Kalinowski 2 лет назад
Родитель
Сommit
a825dde9c0
26 измененных файлов с 159 добавлено и 216 удалено
  1. 0 4
      components/newlib/test/CMakeLists.txt
  2. 0 7
      components/newlib/test_apps/main/CMakeLists.txt
  3. 0 19
      components/newlib/test_apps/main/test_newlib_main.c
  4. 0 0
      components/newlib/test_apps/newlib/CMakeLists.txt
  5. 0 0
      components/newlib/test_apps/newlib/README.md
  6. 13 0
      components/newlib/test_apps/newlib/main/CMakeLists.txt
  7. 47 0
      components/newlib/test_apps/newlib/main/test_app_main.c
  8. 2 2
      components/newlib/test_apps/newlib/main/test_atomic.c
  9. 2 18
      components/newlib/test_apps/newlib/main/test_file.c
  10. 1 1
      components/newlib/test_apps/newlib/main/test_locks.c
  11. 5 28
      components/newlib/test_apps/newlib/main/test_misc.c
  12. 1 1
      components/newlib/test_apps/newlib/main/test_newlib.c
  13. 3 2
      components/newlib/test_apps/newlib/main/test_setjmp.c
  14. 1 1
      components/newlib/test_apps/newlib/main/test_shared_stack_printf.c
  15. 10 115
      components/newlib/test_apps/newlib/main/test_stdatomic.c
  16. 12 2
      components/newlib/test_apps/newlib/main/test_time.c
  17. 22 0
      components/newlib/test_apps/newlib/pytest_newlib.py
  18. 0 0
      components/newlib/test_apps/newlib/sdkconfig.ci.default
  19. 12 0
      components/newlib/test_apps/newlib/sdkconfig.ci.psram_esp32
  20. 4 0
      components/newlib/test_apps/newlib/sdkconfig.ci.release_esp32
  21. 10 0
      components/newlib/test_apps/newlib/sdkconfig.ci.release_esp32c2
  22. 4 0
      components/newlib/test_apps/newlib/sdkconfig.ci.single_core_esp32
  23. 4 0
      components/newlib/test_apps/newlib/sdkconfig.ci.single_core_esp32s2
  24. 6 0
      components/newlib/test_apps/newlib/sdkconfig.defaults
  25. 0 11
      components/newlib/test_apps/pytest_newlib.py
  26. 0 5
      components/newlib/test_apps/sdkconfig.defaults

+ 0 - 4
components/newlib/test/CMakeLists.txt

@@ -1,4 +0,0 @@
-idf_component_register(SRC_DIRS "."
-                    PRIV_INCLUDE_DIRS "."
-                    PRIV_REQUIRES cmock test_utils driver esp_timer spi_flash)
-target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")

+ 0 - 7
components/newlib/test_apps/main/CMakeLists.txt

@@ -1,7 +0,0 @@
-idf_component_register(SRCS
-                        "test_newlib_main.c"
-                        "test_stdatomic.c"
-                        "test_misc.c"
-                        "test_file.c"
-                       REQUIRES pthread test_utils
-                       PRIV_REQUIRES unity vfs)

+ 0 - 19
components/newlib/test_apps/main/test_newlib_main.c

@@ -1,19 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
- *
- * SPDX-License-Identifier: Unlicense OR CC0-1.0
- */
-#include "unity.h"
-#include "unity_fixture.h"
-
-static void run_all_tests(void)
-{
-    RUN_TEST_GROUP(stdatomic);
-    RUN_TEST_GROUP(misc);
-    RUN_TEST_GROUP(file);
-}
-
-void app_main(void)
-{
-    UNITY_MAIN_FUNC(run_all_tests);
-}

+ 0 - 0
components/newlib/test_apps/CMakeLists.txt → components/newlib/test_apps/newlib/CMakeLists.txt


+ 0 - 0
components/newlib/test_apps/README.md → components/newlib/test_apps/newlib/README.md


+ 13 - 0
components/newlib/test_apps/newlib/main/CMakeLists.txt

@@ -0,0 +1,13 @@
+idf_component_register(SRCS
+                       "test_app_main.c"
+                       "test_atomic.c"
+                       "test_file.c"
+                       "test_locks.c"
+                       "test_misc.c"
+                       "test_newlib.c"
+                       "test_setjmp.c"
+                       "test_shared_stack_printf.c"
+                       "test_stdatomic.c"
+                       "test_time.c"
+                       PRIV_REQUIRES unity vfs cmock driver esp_timer spi_flash test_utils pthread esp_psram
+                       WHOLE_ARCHIVE)

+ 47 - 0
components/newlib/test_apps/newlib/main/test_app_main.c

@@ -0,0 +1,47 @@
+/*
+ * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: CC0-1.0
+ */
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "unity.h"
+#include "unity_test_runner.h"
+#include "esp_heap_caps.h"
+#include "test_utils.h"
+
+#define TEST_MEMORY_LEAK_THRESHOLD (-350)
+
+static size_t before_free_8bit;
+static size_t before_free_32bit;
+
+static void check_leak(size_t before_free, size_t after_free, const char *type)
+{
+    ssize_t delta = after_free - before_free;
+    printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
+    TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak");
+}
+
+void setUp(void)
+{
+    before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
+    before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
+}
+
+void tearDown(void)
+{
+    // Add a short delay of 10ms to allow the idle task to free an remaining memory
+    vTaskDelay(pdMS_TO_TICKS(10));
+    size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
+    size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
+    check_leak(before_free_8bit, after_free_8bit, "8BIT");
+    check_leak(before_free_32bit, after_free_32bit, "32BIT");
+}
+
+void app_main(void)
+{
+    // Raise priority to main task as some tests depend on the test task being at priority UNITY_FREERTOS_PRIORITY
+    vTaskPrioritySet(NULL, UNITY_FREERTOS_PRIORITY);
+    unity_run_menu();
+}

+ 2 - 2
components/newlib/test/test_atomic.c → components/newlib/test_apps/newlib/main/test_atomic.c

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Unlicense OR CC0-1.0
  */
@@ -56,7 +56,7 @@ static void test_flow(const char* name, test_f func)
         sorted_array_insert(t_flight_sorted, &t_flight_num, t_op);
     }
     for (int i = 0; i < TEST_TIMES; i++) {
-        ESP_LOGI(TAG, "%s: %d ops", name, t_flight_sorted[i]-s_t_ref);
+        ESP_LOGI(TAG, "%s: %" PRIu32 " ops", name, t_flight_sorted[i]-s_t_ref);
     }
 }
 

+ 2 - 18
components/newlib/test_apps/main/test_file.c → components/newlib/test_apps/newlib/main/test_file.c

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Unlicense OR CC0-1.0
  */
@@ -10,17 +10,6 @@
 #include <errno.h>
 #include "esp_vfs.h"
 #include "unity.h"
-#include "unity_fixture.h"
-
-TEST_GROUP(file);
-
-TEST_SETUP(file)
-{
-}
-
-TEST_TEAR_DOWN(file)
-{
-}
 
 /* This test checks that st_blksize value set in struct stat correctly affects the
  * FILE structure:
@@ -53,7 +42,7 @@ static ssize_t blksize_test_write(void* ctx, int fd, const void * data, size_t s
     return size;
 }
 
-TEST(file, blksize)
+TEST_CASE("file - blksize", "[newlib_file]")
 {
     FILE* f;
     blksize_test_ctx_t ctx = {};
@@ -87,8 +76,3 @@ TEST(file, blksize)
 
     TEST_ESP_OK(esp_vfs_unregister("/test"));
 }
-
-TEST_GROUP_RUNNER(file)
-{
-    RUN_TEST_CASE(file, blksize)
-}

+ 1 - 1
components/newlib/test/test_locks.c → components/newlib/test_apps/newlib/main/test_locks.c

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Unlicense OR CC0-1.0
  */

+ 5 - 28
components/newlib/test_apps/main/test_misc.c → components/newlib/test_apps/newlib/main/test_misc.c

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
@@ -13,27 +13,11 @@
 #include <sys/param.h>
 #include <stdlib.h>
 #include "unity.h"
-#include "unity_fixture.h"
 
-// unity_fixture_malloc_overrides.h defines 'free' as 'unity_free',
-// which can only handle pointers allocated with 'unity_malloc'.
-// This test allocates memory via 'posix_memalign' so calling 'free'
-// for these pointers causes the heap guards check to fail.
-#undef free
 
-TEST_GROUP(misc);
-
-TEST_SETUP(misc)
-{
-}
-
-TEST_TEAR_DOWN(misc)
-{
-}
-
-TEST(misc, posix_memalign)
+TEST_CASE("misc - posix_memalign", "[newlib_misc]")
 {
-    void* outptr;
+    void* outptr = NULL;
     int ret;
 
     ret = posix_memalign(&outptr, 4, 0);
@@ -59,12 +43,12 @@ TEST(misc, posix_memalign)
     free(outptr);
 }
 
-TEST(misc, sysconf)
+TEST_CASE("misc - sysconf", "[newlib_misc]")
 {
     TEST_ASSERT_NOT_EQUAL(-1, sysconf(_SC_NPROCESSORS_ONLN));
 }
 
-TEST(misc, realpath)
+TEST_CASE("misc - realpath", "[newlib_misc]")
 {
     char out[PATH_MAX];
 
@@ -86,10 +70,3 @@ TEST(misc, realpath)
     TEST_ASSERT_EQUAL_STRING("/abc/def", out_new);
     free(out_new);
 }
-
-TEST_GROUP_RUNNER(misc)
-{
-    RUN_TEST_CASE(misc, posix_memalign)
-    RUN_TEST_CASE(misc, sysconf)
-    RUN_TEST_CASE(misc, realpath)
-}

+ 1 - 1
components/newlib/test/test_newlib.c → components/newlib/test_apps/newlib/main/test_newlib.c

@@ -62,7 +62,7 @@ TEST_CASE("test sscanf function", "[newlib]")
     TEST_ASSERT_EQUAL(42, fourty_two);
     TEST_ASSERT_EQUAL(2147483647, int_max);
     TEST_ASSERT_EQUAL_UINT32(2147483648UL, int_max_plus_one);
-    TEST_ASSERT_EQUAL(0x40010000, iram_ptr);
+    TEST_ASSERT_EQUAL(0x40010000, (UNITY_UINT32)iram_ptr);
     TEST_ASSERT_EQUAL(0x40020000, irom_ptr);
     TEST_ASSERT_EQUAL('Q', department);
     TEST_ASSERT_TRUE(1.0f / inv_fine_structure_constant > 136 && 1.0f / inv_fine_structure_constant < 138);

+ 3 - 2
components/newlib/test/test_setjmp.c → components/newlib/test_apps/newlib/main/test_setjmp.c

@@ -1,10 +1,11 @@
 /*
- * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Unlicense OR CC0-1.0
  */
 #include <setjmp.h>
 #include <stdio.h>
+#include <inttypes.h>
 #include "unity.h"
 #include "esp_system.h"
 
@@ -17,7 +18,7 @@ typedef struct {
 
 static __attribute__((noreturn)) void inner(setjmp_test_ctx_t *ctx)
 {
-    printf("inner, retval=0x%x\n", ctx->retval);
+    printf("inner, retval=0x%" PRIx32 "\n", ctx->retval);
     ctx->inner_called = true;
     longjmp(ctx->jmp_env, ctx->retval);
     TEST_FAIL_MESSAGE("Should not reach here");

+ 1 - 1
components/newlib/test/test_shared_stack_printf.c → components/newlib/test_apps/newlib/main/test_shared_stack_printf.c

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Unlicense OR CC0-1.0
  */

+ 10 - 115
components/newlib/test_apps/main/test_stdatomic.c → components/newlib/test_apps/newlib/main/test_stdatomic.c

@@ -13,7 +13,6 @@
 #include "esp_pthread.h"
 #include "freertos/portmacro.h"
 #include "unity.h"
-#include "unity_fixture.h"
 
 /* non-static to prevent optimization */
 atomic_ullong g_atomic64;
@@ -22,17 +21,7 @@ atomic_ushort g_atomic16;
 atomic_uchar  g_atomic8;
 
 
-TEST_GROUP(stdatomic);
-
-TEST_SETUP(stdatomic)
-{
-}
-
-TEST_TEAR_DOWN(stdatomic)
-{
-}
-
-TEST(stdatomic, test_64bit_atomics_fetch_op)
+TEST_CASE("stdatomic - test_64bit_atomics", "[newlib_stdatomic]")
 {
     unsigned long long x64 = 0;
     g_atomic64 = 0;  // calls atomic_store
@@ -53,7 +42,7 @@ TEST(stdatomic, test_64bit_atomics_fetch_op)
 #endif
 }
 
-TEST(stdatomic, test_32bit_atomics_fetch_op)
+TEST_CASE("stdatomic - test_32bit_atomics", "[newlib_stdatomic]")
 {
     unsigned int x32 = 0;
     g_atomic32 = 0;
@@ -74,7 +63,7 @@ TEST(stdatomic, test_32bit_atomics_fetch_op)
 #endif
 }
 
-TEST(stdatomic, test_16bit_atomics_fetch_op)
+TEST_CASE("stdatomic - test_16bit_atomics", "[newlib_stdatomic]")
 {
     unsigned int x16 = 0;
     g_atomic16 = 0;
@@ -95,7 +84,7 @@ TEST(stdatomic, test_16bit_atomics_fetch_op)
 #endif
 }
 
-TEST(stdatomic, test_8bit_atomics_fetch_op)
+TEST_CASE("stdatomic - test_8bit_atomics", "[newlib_stdatomic]")
 {
     unsigned int x8 = 0;
     g_atomic8 = 0;
@@ -117,7 +106,7 @@ TEST(stdatomic, test_8bit_atomics_fetch_op)
 }
 
 #ifndef __clang__
-TEST(stdatomic, test_64bit_atomics_op_fetch)
+TEST_CASE("stdatomic - test_64bit_atomics", "[newlib_stdatomic]")
 {
     unsigned long long x64 = 0;
     g_atomic64 = 0;  // calls atomic_store
@@ -133,7 +122,7 @@ TEST(stdatomic, test_64bit_atomics_op_fetch)
     TEST_ASSERT_EQUAL_HEX64(0xDDDDDDDDDDDDDDDDULL, g_atomic64);  // calls atomic_load
 }
 
-TEST(stdatomic, test_32bit_atomics_op_fetch)
+TEST_CASE("stdatomic - test_32bit_atomics", "[newlib_stdatomic]")
 {
     unsigned int x32 = 0;
     g_atomic32 = 0;
@@ -149,7 +138,7 @@ TEST(stdatomic, test_32bit_atomics_op_fetch)
     TEST_ASSERT_EQUAL_HEX32(0xDDDDDDDDU, g_atomic32);
 }
 
-TEST(stdatomic, test_16bit_atomics_op_fetch)
+TEST_CASE("stdatomic - test_16bit_atomics", "[newlib_stdatomic]")
 {
     unsigned int x16 = 0;
     g_atomic16 = 0;
@@ -165,7 +154,7 @@ TEST(stdatomic, test_16bit_atomics_op_fetch)
     TEST_ASSERT_EQUAL_HEX16(0xDDDD, g_atomic16);
 }
 
-TEST(stdatomic, test_8bit_atomics_op_fetch)
+TEST_CASE("stdatomic - test_8bit_atomics", "[newlib_stdatomic]")
 {
     unsigned int x8 = 0;
     g_atomic8 = 0;
@@ -184,7 +173,7 @@ TEST(stdatomic, test_8bit_atomics_op_fetch)
 #endif // #ifndef __clang__
 
 
-#define TEST_EXCLUSION(n) TEST(stdatomic, test_ ## n ## bit_exclusion)       \
+#define TEST_EXCLUSION(n) TEST_CASE("stdatomic - test_" #n "bit_exclusion", "[newlib_stdatomic]") \
 {                                                                            \
     g_atomic ## n = 0;                                                       \
     pthread_t thread1;                                                       \
@@ -242,7 +231,7 @@ static void *test_thread_##NAME (void *arg)                                  \
   return NULL;                                                               \
 }                                                                            \
                                                                              \
-TEST(stdatomic, test_ ##NAME)                                                \
+TEST_CASE("stdatomic - test_" #NAME, "[newlib_stdatomic]")                  \
 {                                                                            \
   pthread_t thread_id1;                                                      \
   pthread_t thread_id2;                                                      \
@@ -330,97 +319,3 @@ TEST_RACE_OPERATION (long_double_preinc, long double, ++, , 0, (2*ITER_COUNT))
 TEST_RACE_OPERATION (complex_long_double_sub, _Complex long double, , -= 1, 0, -(2*ITER_COUNT))
 TEST_RACE_OPERATION (long_double_postdec, long double, , --, 0, -(2*ITER_COUNT))
 TEST_RACE_OPERATION (long_double_predec, long double, --, , 0, -(2*ITER_COUNT))
-
-
-TEST_GROUP_RUNNER(stdatomic)
-{
-    RUN_TEST_CASE(stdatomic, test_64bit_atomics_fetch_op)
-    RUN_TEST_CASE(stdatomic, test_32bit_atomics_fetch_op)
-    RUN_TEST_CASE(stdatomic, test_16bit_atomics_fetch_op)
-    RUN_TEST_CASE(stdatomic, test_8bit_atomics_fetch_op)
-
-#ifndef __clang__
-    RUN_TEST_CASE(stdatomic, test_64bit_atomics_op_fetch)
-    RUN_TEST_CASE(stdatomic, test_32bit_atomics_op_fetch)
-    RUN_TEST_CASE(stdatomic, test_16bit_atomics_op_fetch)
-    RUN_TEST_CASE(stdatomic, test_8bit_atomics_op_fetch)
-#endif
-
-    RUN_TEST_CASE(stdatomic, test_64bit_exclusion)
-    RUN_TEST_CASE(stdatomic, test_32bit_exclusion)
-    RUN_TEST_CASE(stdatomic, test_16bit_exclusion)
-    RUN_TEST_CASE(stdatomic, test_8bit_exclusion)
-
-    RUN_TEST_CASE(stdatomic, test_uint8_add)
-    RUN_TEST_CASE(stdatomic, test_uint8_add_3);
-    RUN_TEST_CASE(stdatomic, test_uint8_postinc);
-    RUN_TEST_CASE(stdatomic, test_uint8_preinc);
-    RUN_TEST_CASE(stdatomic, test_uint8_sub);
-    RUN_TEST_CASE(stdatomic, test_uint8_sub_3);
-    RUN_TEST_CASE(stdatomic, test_uint8_postdec);
-    RUN_TEST_CASE(stdatomic, test_uint8_predec);
-    RUN_TEST_CASE(stdatomic, test_uint8_mul);
-
-    RUN_TEST_CASE(stdatomic, test_uint16_add);
-    RUN_TEST_CASE(stdatomic, test_uint16_add_3);
-    RUN_TEST_CASE(stdatomic, test_uint16_postinc);
-    RUN_TEST_CASE(stdatomic, test_uint16_preinc);
-    RUN_TEST_CASE(stdatomic, test_uint16_sub);
-    RUN_TEST_CASE(stdatomic, test_uint16_sub_3);
-    RUN_TEST_CASE(stdatomic, test_uint16_postdec);
-    RUN_TEST_CASE(stdatomic, test_uint16_predec);
-    RUN_TEST_CASE(stdatomic, test_uint16_mul);
-
-    RUN_TEST_CASE(stdatomic, test_uint32_add);
-    RUN_TEST_CASE(stdatomic, test_uint32_add_3);
-    RUN_TEST_CASE(stdatomic, test_uint32_postinc);
-    RUN_TEST_CASE(stdatomic, test_uint32_preinc);
-    RUN_TEST_CASE(stdatomic, test_uint32_sub);
-    RUN_TEST_CASE(stdatomic, test_uint32_sub_3);
-    RUN_TEST_CASE(stdatomic, test_uint32_postdec);
-    RUN_TEST_CASE(stdatomic, test_uint32_predec);
-    RUN_TEST_CASE(stdatomic, test_uint32_mul);
-
-    RUN_TEST_CASE(stdatomic, test_uint64_add);
-    RUN_TEST_CASE(stdatomic, test_uint64_add_3);
-    RUN_TEST_CASE(stdatomic, test_uint64_add_neg);
-    RUN_TEST_CASE(stdatomic, test_uint64_sub);
-    RUN_TEST_CASE(stdatomic, test_uint64_sub_3);
-    RUN_TEST_CASE(stdatomic, test_uint64_sub_neg);
-    RUN_TEST_CASE(stdatomic, test_uint64_postinc);
-    RUN_TEST_CASE(stdatomic, test_uint64_postinc_neg);
-    RUN_TEST_CASE(stdatomic, test_uint64_preinc);
-    RUN_TEST_CASE(stdatomic, test_uint64_preinc_neg);
-    RUN_TEST_CASE(stdatomic, test_uint64_postdec);
-    RUN_TEST_CASE(stdatomic, test_uint64_postdec_neg);
-    RUN_TEST_CASE(stdatomic, test_uint64_predec);
-    RUN_TEST_CASE(stdatomic, test_uint64_predec_neg);
-    RUN_TEST_CASE(stdatomic, test_uint64_mul);
-
-    RUN_TEST_CASE(stdatomic, test_float_add);
-    RUN_TEST_CASE(stdatomic, test_complex_float_add);
-    RUN_TEST_CASE(stdatomic, test_float_postinc);
-    RUN_TEST_CASE(stdatomic, test_float_preinc);
-    RUN_TEST_CASE(stdatomic, test_float_sub);
-    RUN_TEST_CASE(stdatomic, test_complex_float_sub);
-    RUN_TEST_CASE(stdatomic, test_float_postdec);
-    RUN_TEST_CASE(stdatomic, test_float_predec);
-
-    RUN_TEST_CASE(stdatomic, test_double_add);
-    RUN_TEST_CASE(stdatomic, test_complex_double_add);
-    RUN_TEST_CASE(stdatomic, test_double_postinc);
-    RUN_TEST_CASE(stdatomic, test_double_preinc);
-    RUN_TEST_CASE(stdatomic, test_double_sub);
-    RUN_TEST_CASE(stdatomic, test_complex_double_sub);
-    RUN_TEST_CASE(stdatomic, test_double_postdec);
-    RUN_TEST_CASE(stdatomic, test_double_predec);
-
-    RUN_TEST_CASE(stdatomic, test_long_double_add);
-    RUN_TEST_CASE(stdatomic, test_complex_long_double_add);
-    RUN_TEST_CASE(stdatomic, test_long_double_postinc);
-    RUN_TEST_CASE(stdatomic, test_long_double_preinc);
-    RUN_TEST_CASE(stdatomic, test_long_double_sub);
-    RUN_TEST_CASE(stdatomic, test_complex_long_double_sub);
-    RUN_TEST_CASE(stdatomic, test_long_double_postdec);
-    RUN_TEST_CASE(stdatomic, test_long_double_predec);
-}

+ 12 - 2
components/newlib/test/test_time.c → components/newlib/test_apps/newlib/main/test_time.c

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
@@ -164,6 +164,7 @@ TEST_CASE("test adjtime function", "[newlib]")
     TEST_ASSERT_EQUAL(adjtime(NULL, &tv_outdelta), 0);
     TEST_ASSERT_EQUAL(tv_outdelta.tv_sec, 0);
     // the correction will be equal to (1_000_000us >> 6) = 15_625 us.
+
     TEST_ASSERT_TRUE(1000000L - tv_outdelta.tv_usec >= 15600);
     TEST_ASSERT_TRUE(1000000L - tv_outdelta.tv_usec <= 15650);
 }
@@ -367,7 +368,7 @@ void test_posix_timers_clock (void)
 #ifdef CONFIG_RTC_CLK_SRC_EXT_CRYS
     printf("External (crystal) Frequency = %d Hz\n", rtc_clk_slow_freq_get_hz());
 #else
-    printf("Internal Frequency = %d Hz\n", rtc_clk_slow_freq_get_hz());
+    printf("Internal Frequency = %" PRIu32 " Hz\n", rtc_clk_slow_freq_get_hz());
 #endif
 
     TEST_ASSERT(clock_settime(CLOCK_REALTIME, NULL) == -1);
@@ -468,6 +469,9 @@ TEST_CASE("test time_t wide 64 bits", "[newlib]")
     ESP_LOGI("TAG", "sizeof(time_t): %d (%d-bit)", sizeof(time_t), sizeof(time_t)*8);
     TEST_ASSERT_EQUAL(8, sizeof(time_t));
 
+    // mktime takes current timezone into account, this test assumes it's UTC+0
+    setenv("TZ", "UTC+0", 1);
+    tzset();
     struct tm tm = {4, 14, 3, 19, 0, 138, 0, 0, 0};
     struct timeval timestamp = { mktime(&tm), 0 };
 #if !CONFIG_NEWLIB_NANO_FORMAT
@@ -488,6 +492,9 @@ TEST_CASE("test time functions wide 64 bits", "[newlib]")
     static char origin_buffer[32];
     char strftime_buf[64];
 
+    // mktime takes current timezone into account, this test assumes it's UTC+0
+    setenv("TZ", "UTC+0", 1);
+    tzset();
     int year = 2018;
     struct tm tm = {0, 14, 3, 19, 0, year - 1900, 0, 0, 0};
     time_t t = mktime(&tm);
@@ -542,6 +549,8 @@ TEST_CASE("test time functions wide 64 bits", "[newlib]")
 
 #endif // !_USE_LONG_TIME_T
 
+// IDF-6962 following test cases don't pass on C2
+#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2)
 #if defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) && defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
 
 extern int64_t s_microseconds_offset;
@@ -642,3 +651,4 @@ TEST_CASE_MULTIPLE_STAGES("Timestamp after abort is correct in case RTC & High-r
 TEST_CASE_MULTIPLE_STAGES("Timestamp after restart is correct in case RTC & High-res timer have + big error", "[newlib][reset=SW_CPU_RESET]", set_timestamp2, check_time);
 TEST_CASE_MULTIPLE_STAGES("Timestamp after restart is correct in case RTC & High-res timer have - big error", "[newlib][reset=SW_CPU_RESET]", set_timestamp3, check_time);
 #endif // CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER && CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
+#endif // !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2)

+ 22 - 0
components/newlib/test_apps/newlib/pytest_newlib.py

@@ -0,0 +1,22 @@
+# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
+# SPDX-License-Identifier: CC0-1.0
+
+import pytest
+from pytest_embedded import Dut
+
+
+@pytest.mark.generic
+@pytest.mark.parametrize(
+    'config',
+    [
+        pytest.param('default', marks=[pytest.mark.supported_targets]),
+        pytest.param('single_core_esp32', marks=[pytest.mark.esp32]),
+        pytest.param('single_core_esp32s2', marks=[pytest.mark.esp32s2]),
+        pytest.param('psram_esp32', marks=[pytest.mark.esp32]),
+        pytest.param('release_esp32', marks=[pytest.mark.esp32]),
+        pytest.param('release_esp32c2', marks=[pytest.mark.esp32c2]),
+    ],
+    indirect=True
+)
+def test_newlib(dut: Dut) -> None:
+    dut.run_all_single_board_cases()

+ 0 - 0
components/newlib/test_apps/newlib/sdkconfig.ci.default


+ 12 - 0
components/newlib/test_apps/newlib/sdkconfig.ci.psram_esp32

@@ -0,0 +1,12 @@
+CONFIG_IDF_TARGET="esp32"
+CONFIG_SPIRAM=y
+
+# moved from old psram config
+CONFIG_ESP_INT_WDT_TIMEOUT_MS=800
+CONFIG_SPIRAM_OCCUPY_NO_HOST=y
+CONFIG_ESP_WIFI_RX_IRAM_OPT=n
+CONFIG_ESP_WIFI_IRAM_OPT=n
+# Disable encrypted flash reads/writes to save IRAM in this build configuration
+CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=n
+CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y
+CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y

+ 4 - 0
components/newlib/test_apps/newlib/sdkconfig.ci.release_esp32

@@ -0,0 +1,4 @@
+CONFIG_IDF_TARGET="esp32"
+CONFIG_COMPILER_OPTIMIZATION_SIZE=y
+CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
+CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y

+ 10 - 0
components/newlib/test_apps/newlib/sdkconfig.ci.release_esp32c2

@@ -0,0 +1,10 @@
+CONFIG_IDF_TARGET="esp32c2"
+CONFIG_COMPILER_OPTIMIZATION_SIZE=y
+CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
+CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
+
+# C2 specific moved from old C2 default config
+CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE=n
+CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT=y
+CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC=n
+CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=n

+ 4 - 0
components/newlib/test_apps/newlib/sdkconfig.ci.single_core_esp32

@@ -0,0 +1,4 @@
+CONFIG_IDF_TARGET="esp32"
+CONFIG_FREERTOS_UNICORE=y
+# IDF-6964 test nano format in this configuration (current tests are not passing, so keep disabled for now)
+CONFIG_NEWLIB_NANO_FORMAT=n

+ 4 - 0
components/newlib/test_apps/newlib/sdkconfig.ci.single_core_esp32s2

@@ -0,0 +1,4 @@
+CONFIG_IDF_TARGET="esp32s2"
+CONFIG_FREERTOS_UNICORE=y
+# IDF-6964 test nano format in this configuration (current tests are not passing, so keep disabled for now)
+CONFIG_NEWLIB_NANO_FORMAT=n

+ 6 - 0
components/newlib/test_apps/newlib/sdkconfig.defaults

@@ -0,0 +1,6 @@
+# certain 64-bit related asserts need this option to be enabled in unity in order to work correctly
+CONFIG_UNITY_ENABLE_64BIT=y
+CONFIG_FREERTOS_HZ=1000
+CONFIG_ESP_TASK_WDT_INIT=n
+CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y
+CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y

+ 0 - 11
components/newlib/test_apps/pytest_newlib.py

@@ -1,11 +0,0 @@
-# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
-# SPDX-License-Identifier: CC0-1.0
-
-import pytest
-from pytest_embedded import Dut
-
-
-@pytest.mark.supported_targets
-@pytest.mark.generic
-def test_newlib(dut: Dut) -> None:
-    dut.expect_unity_test_output()

+ 0 - 5
components/newlib/test_apps/sdkconfig.defaults

@@ -1,5 +0,0 @@
-CONFIG_UNITY_ENABLE_FIXTURE=y
-CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n
-CONFIG_UNITY_ENABLE_64BIT=y
-CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n
-CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n