2019-07-02 00:00:07 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Peter Bigot Consulting
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Tests that gmtime matches gmtime_r */
|
|
|
|
|
|
|
|
#include <string.h>
|
2022-07-19 22:16:24 +08:00
|
|
|
#include <zephyr/ztest.h>
|
2019-07-02 00:00:07 +08:00
|
|
|
#include "timeutil_test.h"
|
|
|
|
|
2022-08-21 16:36:13 +08:00
|
|
|
ZTEST(timeutil_api, test_gmtime)
|
2019-07-02 00:00:07 +08:00
|
|
|
{
|
2019-07-31 02:39:20 +08:00
|
|
|
struct tm tm = {
|
|
|
|
/* Initialize an unset field */
|
|
|
|
.tm_isdst = 1234,
|
|
|
|
};
|
2019-07-02 00:00:07 +08:00
|
|
|
time_t time = 1561994005;
|
|
|
|
|
|
|
|
zassert_equal(&tm, gmtime_r(&time, &tm),
|
|
|
|
"gmtime_r return failed");
|
|
|
|
|
|
|
|
struct tm *tp = gmtime(&time);
|
|
|
|
|
|
|
|
zassert_true(memcmp(&tm, tp, sizeof(tm)) == 0,
|
|
|
|
"gmtime disagrees with gmtime_r");
|
|
|
|
}
|