esp_rom: Fix esp32.rom.newlib-time.ld should includes all time ROM functions/data

- Added UT
Closes: https://github.com/espressif/esp-idf/issues/4925
This commit is contained in:
KonstantinKondrashov
2020-03-17 17:02:24 +08:00
committed by bot
parent 4fe04f1151
commit 9aeac7f6cb
6 changed files with 36 additions and 10 deletions

View File

@@ -193,3 +193,21 @@ TEST_CASE("newlib: can link 'system', 'raise'", "[newlib]")
{
printf("system: %p, raise: %p\n", &system, &raise);
}
TEST_CASE("newlib: rom and toolchain localtime func gives the same result", "[newlib]")
{
// This UNIX time represents 2020-03-12 15:00:00 EDT (19:00 GMT)
// as can be verified with 'date --date @1584039600'
const time_t seconds = 1584039600;
setenv("TZ", "EST5EDT,M3.2.0,M11.1.0", 1); // America/New_York
tzset();
struct tm *tm = localtime(&seconds);
tm->tm_isdst = 1;
static char buf[32];
strftime(buf, sizeof(buf), "%F %T %Z", tm);
static char test_result[64];
sprintf(test_result, "%s (tm_isdst = %d)", buf, tm->tm_isdst);
printf("%s\n", test_result);
TEST_ASSERT_EQUAL_STRING("2020-03-12 15:00:00 EDT (tm_isdst = 1)", test_result);
}