Merge branch 'ci/newlib_pytest_v5.1' into 'release/v5.1'

ci: move newlib tests to pytest (v5.1)

See merge request espressif/esp-idf!23685
This commit is contained in:
Marius Vikhammer 2023-05-11 11:49:48 +08:00
commit 5d6b59109b
26 changed files with 174 additions and 233 deletions

View File

@ -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")

View File

@ -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)

View File

@ -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);
}

View File

@ -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)

View File

@ -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();
}

View File

@ -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 * 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); sorted_array_insert(t_flight_sorted, &t_flight_num, t_op);
} }
for (int i = 0; i < TEST_TIMES; i++) { 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);
} }
} }

View File

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

View File

@ -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 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */

View File

@ -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 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -13,27 +13,11 @@
#include <sys/param.h> #include <sys/param.h>
#include <stdlib.h> #include <stdlib.h>
#include "unity.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_CASE("misc - posix_memalign", "[newlib_misc]")
TEST_SETUP(misc)
{ {
} void* outptr = NULL;
TEST_TEAR_DOWN(misc)
{
}
TEST(misc, posix_memalign)
{
void* outptr;
int ret; int ret;
ret = posix_memalign(&outptr, 4, 0); ret = posix_memalign(&outptr, 4, 0);
@ -59,12 +43,12 @@ TEST(misc, posix_memalign)
free(outptr); free(outptr);
} }
TEST(misc, sysconf) TEST_CASE("misc - sysconf", "[newlib_misc]")
{ {
TEST_ASSERT_NOT_EQUAL(-1, sysconf(_SC_NPROCESSORS_ONLN)); TEST_ASSERT_NOT_EQUAL(-1, sysconf(_SC_NPROCESSORS_ONLN));
} }
TEST(misc, realpath) TEST_CASE("misc - realpath", "[newlib_misc]")
{ {
char out[PATH_MAX]; char out[PATH_MAX];
@ -86,10 +70,3 @@ TEST(misc, realpath)
TEST_ASSERT_EQUAL_STRING("/abc/def", out_new); TEST_ASSERT_EQUAL_STRING("/abc/def", out_new);
free(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)
}

View File

@ -62,7 +62,7 @@ TEST_CASE("test sscanf function", "[newlib]")
TEST_ASSERT_EQUAL(42, fourty_two); TEST_ASSERT_EQUAL(42, fourty_two);
TEST_ASSERT_EQUAL(2147483647, int_max); TEST_ASSERT_EQUAL(2147483647, int_max);
TEST_ASSERT_EQUAL_UINT32(2147483648UL, int_max_plus_one); 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(0x40020000, irom_ptr);
TEST_ASSERT_EQUAL('Q', department); TEST_ASSERT_EQUAL('Q', department);
TEST_ASSERT_TRUE(1.0f / inv_fine_structure_constant > 136 && 1.0f / inv_fine_structure_constant < 138); TEST_ASSERT_TRUE(1.0f / inv_fine_structure_constant > 136 && 1.0f / inv_fine_structure_constant < 138);
@ -123,43 +123,51 @@ TEST_CASE("test asctime", "[newlib]")
TEST_ASSERT_EQUAL_STRING(buf, time_str); TEST_ASSERT_EQUAL_STRING(buf, time_str);
} }
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32H2)
static bool fn_in_rom(void *fn) static bool fn_in_rom(void *fn)
{ {
const int fnaddr = (int)fn; const int fnaddr = (int)fn;
return (fnaddr >= SOC_IROM_MASK_LOW && fnaddr < SOC_IROM_MASK_HIGH); return (fnaddr >= SOC_IROM_MASK_LOW && fnaddr < SOC_IROM_MASK_HIGH);
} }
/* Older chips have newlib nano in rom as well, but this is not linked in due to us now using 64 bit time_t
and the ROM code was compiled for 32 bit.
*/
#define PRINTF_NANO_IN_ROM (CONFIG_NEWLIB_NANO_FORMAT && (CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32H2))
#define SSCANF_NANO_IN_ROM (CONFIG_NEWLIB_NANO_FORMAT && CONFIG_IDF_TARGET_ESP32C2)
TEST_CASE("check if ROM or Flash is used for functions", "[newlib]") TEST_CASE("check if ROM or Flash is used for functions", "[newlib]")
{ {
#if CONFIG_NEWLIB_NANO_FORMAT || ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT #if PRINTF_NANO_IN_ROM || (ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT && !CONFIG_NEWLIB_NANO_FORMAT)
TEST_ASSERT(fn_in_rom(vfprintf)); TEST_ASSERT(fn_in_rom(vfprintf));
#else #else
TEST_ASSERT_FALSE(fn_in_rom(vfprintf)); TEST_ASSERT_FALSE(fn_in_rom(vfprintf));
#endif // CONFIG_NEWLIB_NANO_FORMAT || ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT #endif // PRINTF_NANO_IN_ROM || (ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT && !CONFIG_NEWLIB_NANO_FORMAT)
#if (CONFIG_NEWLIB_NANO_FORMAT && (CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C2)) || ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT #if SSCANF_NANO_IN_ROM || (ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT && !CONFIG_NEWLIB_NANO_FORMAT)
TEST_ASSERT(fn_in_rom(sscanf)); TEST_ASSERT(fn_in_rom(sscanf));
#else #else
TEST_ASSERT_FALSE(fn_in_rom(sscanf)); TEST_ASSERT_FALSE(fn_in_rom(sscanf));
#endif // (CONFIG_NEWLIB_NANO_FORMAT && CONFIG_IDF_TARGET_x) || ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT #endif // SSCANF_NANO_IN_ROM || (ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT && !CONFIG_NEWLIB_NANO_FORMAT)
#if defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_SPIRAM) #if defined(CONFIG_IDF_TARGET_ESP32)
TEST_ASSERT(fn_in_rom(atoi));
TEST_ASSERT(fn_in_rom(strtol)); #if defined(CONFIG_SPIRAM_CACHE_WORKAROUND)
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) \ TEST_ASSERT_FALSE(fn_in_rom(atoi));
|| defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32C6) TEST_ASSERT_FALSE(fn_in_rom(strtol));
/* S3 and C3 always use these from ROM */
TEST_ASSERT(fn_in_rom(atoi));
TEST_ASSERT(fn_in_rom(strtol));
#else #else
TEST_ASSERT(fn_in_rom(atoi));
TEST_ASSERT(fn_in_rom(strtol));
#endif //CONFIG_SPIRAM_CACHE_WORKAROUND
#elif CONFIG_IDF_TARGET_ESP32S2
/* S2 do not have these in ROM */ /* S2 do not have these in ROM */
TEST_ASSERT_FALSE(fn_in_rom(atoi)); TEST_ASSERT_FALSE(fn_in_rom(atoi));
TEST_ASSERT_FALSE(fn_in_rom(strtol)); TEST_ASSERT_FALSE(fn_in_rom(strtol));
#endif // defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_SPIRAM) #else
TEST_ASSERT(fn_in_rom(atoi));
TEST_ASSERT(fn_in_rom(strtol));
#endif // defined(CONFIG_IDF_TARGET_ESP32)
} }
#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32H2)
#ifndef CONFIG_NEWLIB_NANO_FORMAT #ifndef CONFIG_NEWLIB_NANO_FORMAT
TEST_CASE("test 64bit int formats", "[newlib]") TEST_CASE("test 64bit int formats", "[newlib]")

View File

@ -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 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
#include <setjmp.h> #include <setjmp.h>
#include <stdio.h> #include <stdio.h>
#include <inttypes.h>
#include "unity.h" #include "unity.h"
#include "esp_system.h" #include "esp_system.h"
@ -17,7 +18,7 @@ typedef struct {
static __attribute__((noreturn)) void inner(setjmp_test_ctx_t *ctx) 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; ctx->inner_called = true;
longjmp(ctx->jmp_env, ctx->retval); longjmp(ctx->jmp_env, ctx->retval);
TEST_FAIL_MESSAGE("Should not reach here"); TEST_FAIL_MESSAGE("Should not reach here");

View File

@ -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 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */

View File

@ -13,7 +13,6 @@
#include "esp_pthread.h" #include "esp_pthread.h"
#include "freertos/portmacro.h" #include "freertos/portmacro.h"
#include "unity.h" #include "unity.h"
#include "unity_fixture.h"
/* non-static to prevent optimization */ /* non-static to prevent optimization */
atomic_ullong g_atomic64; atomic_ullong g_atomic64;
@ -22,17 +21,7 @@ atomic_ushort g_atomic16;
atomic_uchar g_atomic8; atomic_uchar g_atomic8;
TEST_GROUP(stdatomic); TEST_CASE("stdatomic - test_64bit_atomics", "[newlib_stdatomic]")
TEST_SETUP(stdatomic)
{
}
TEST_TEAR_DOWN(stdatomic)
{
}
TEST(stdatomic, test_64bit_atomics_fetch_op)
{ {
unsigned long long x64 = 0; unsigned long long x64 = 0;
g_atomic64 = 0; // calls atomic_store g_atomic64 = 0; // calls atomic_store
@ -53,7 +42,7 @@ TEST(stdatomic, test_64bit_atomics_fetch_op)
#endif #endif
} }
TEST(stdatomic, test_32bit_atomics_fetch_op) TEST_CASE("stdatomic - test_32bit_atomics", "[newlib_stdatomic]")
{ {
unsigned int x32 = 0; unsigned int x32 = 0;
g_atomic32 = 0; g_atomic32 = 0;
@ -74,7 +63,7 @@ TEST(stdatomic, test_32bit_atomics_fetch_op)
#endif #endif
} }
TEST(stdatomic, test_16bit_atomics_fetch_op) TEST_CASE("stdatomic - test_16bit_atomics", "[newlib_stdatomic]")
{ {
unsigned int x16 = 0; unsigned int x16 = 0;
g_atomic16 = 0; g_atomic16 = 0;
@ -95,7 +84,7 @@ TEST(stdatomic, test_16bit_atomics_fetch_op)
#endif #endif
} }
TEST(stdatomic, test_8bit_atomics_fetch_op) TEST_CASE("stdatomic - test_8bit_atomics", "[newlib_stdatomic]")
{ {
unsigned int x8 = 0; unsigned int x8 = 0;
g_atomic8 = 0; g_atomic8 = 0;
@ -117,7 +106,7 @@ TEST(stdatomic, test_8bit_atomics_fetch_op)
} }
#ifndef __clang__ #ifndef __clang__
TEST(stdatomic, test_64bit_atomics_op_fetch) TEST_CASE("stdatomic - test_64bit_atomics", "[newlib_stdatomic]")
{ {
unsigned long long x64 = 0; unsigned long long x64 = 0;
g_atomic64 = 0; // calls atomic_store 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_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; unsigned int x32 = 0;
g_atomic32 = 0; g_atomic32 = 0;
@ -149,7 +138,7 @@ TEST(stdatomic, test_32bit_atomics_op_fetch)
TEST_ASSERT_EQUAL_HEX32(0xDDDDDDDDU, g_atomic32); 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; unsigned int x16 = 0;
g_atomic16 = 0; g_atomic16 = 0;
@ -165,7 +154,7 @@ TEST(stdatomic, test_16bit_atomics_op_fetch)
TEST_ASSERT_EQUAL_HEX16(0xDDDD, g_atomic16); 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; unsigned int x8 = 0;
g_atomic8 = 0; g_atomic8 = 0;
@ -184,7 +173,7 @@ TEST(stdatomic, test_8bit_atomics_op_fetch)
#endif // #ifndef __clang__ #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; \ g_atomic ## n = 0; \
pthread_t thread1; \ pthread_t thread1; \
@ -242,7 +231,7 @@ static void *test_thread_##NAME (void *arg) \
return NULL; \ return NULL; \
} \ } \
\ \
TEST(stdatomic, test_ ##NAME) \ TEST_CASE("stdatomic - test_" #NAME, "[newlib_stdatomic]") \
{ \ { \
pthread_t thread_id1; \ pthread_t thread_id1; \
pthread_t thread_id2; \ 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 (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_postdec, long double, , --, 0, -(2*ITER_COUNT))
TEST_RACE_OPERATION (long_double_predec, 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);
}

View File

@ -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 * 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(adjtime(NULL, &tv_outdelta), 0);
TEST_ASSERT_EQUAL(tv_outdelta.tv_sec, 0); TEST_ASSERT_EQUAL(tv_outdelta.tv_sec, 0);
// the correction will be equal to (1_000_000us >> 6) = 15_625 us. // 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 >= 15600);
TEST_ASSERT_TRUE(1000000L - tv_outdelta.tv_usec <= 15650); 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 #ifdef CONFIG_RTC_CLK_SRC_EXT_CRYS
printf("External (crystal) Frequency = %d Hz\n", rtc_clk_slow_freq_get_hz()); printf("External (crystal) Frequency = %d Hz\n", rtc_clk_slow_freq_get_hz());
#else #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 #endif
TEST_ASSERT(clock_settime(CLOCK_REALTIME, NULL) == -1); 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); ESP_LOGI("TAG", "sizeof(time_t): %d (%d-bit)", sizeof(time_t), sizeof(time_t)*8);
TEST_ASSERT_EQUAL(8, sizeof(time_t)); 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 tm tm = {4, 14, 3, 19, 0, 138, 0, 0, 0};
struct timeval timestamp = { mktime(&tm), 0 }; struct timeval timestamp = { mktime(&tm), 0 };
#if !CONFIG_NEWLIB_NANO_FORMAT #if !CONFIG_NEWLIB_NANO_FORMAT
@ -488,6 +492,9 @@ TEST_CASE("test time functions wide 64 bits", "[newlib]")
static char origin_buffer[32]; static char origin_buffer[32];
char strftime_buf[64]; 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; int year = 2018;
struct tm tm = {0, 14, 3, 19, 0, year - 1900, 0, 0, 0}; struct tm tm = {0, 14, 3, 19, 0, year - 1900, 0, 0, 0};
time_t t = mktime(&tm); time_t t = mktime(&tm);
@ -548,8 +555,8 @@ extern int64_t s_microseconds_offset;
static const uint64_t s_start_timestamp = 1606838354; static const uint64_t s_start_timestamp = 1606838354;
static RTC_NOINIT_ATTR uint64_t s_saved_time; static __NOINIT_ATTR uint64_t s_saved_time;
static RTC_NOINIT_ATTR uint64_t s_time_in_reboot; static __NOINIT_ATTR uint64_t s_time_in_reboot;
typedef enum { typedef enum {
TYPE_REBOOT_ABORT = 0, TYPE_REBOOT_ABORT = 0,
@ -570,6 +577,9 @@ static void print_counters(void)
static void set_initial_condition(type_reboot_t type_reboot, int error_time) static void set_initial_condition(type_reboot_t type_reboot, int error_time)
{ {
s_saved_time = 0;
s_time_in_reboot = 0;
print_counters(); print_counters();
struct timeval tv = { .tv_sec = s_start_timestamp, .tv_usec = 0, }; struct timeval tv = { .tv_sec = s_start_timestamp, .tv_usec = 0, };

View File

@ -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('options', marks=[pytest.mark.supported_targets]),
pytest.param('single_core_esp32', marks=[pytest.mark.esp32]),
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()

View File

@ -0,0 +1,2 @@
# Test all chips with nano off, nano on is tested in options config
CONFIG_NEWLIB_NANO_FORMAT=n

View File

@ -0,0 +1,2 @@
# Test with misc newlib config options turned on
CONFIG_NEWLIB_NANO_FORMAT=y

View File

@ -0,0 +1,2 @@
CONFIG_IDF_TARGET="esp32"
CONFIG_SPIRAM=y

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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