1 /* 2 * Copyright (c) 2019 Peter Bigot Consulting 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /* Tests that gmtime matches gmtime_r */ 8 9 #include <string.h> 10 #include <zephyr/ztest.h> 11 #include "timeutil_test.h" 12 ZTEST(timeutil_api,test_gmtime)13ZTEST(timeutil_api, test_gmtime) 14 { 15 struct tm tm = { 16 /* Initialize an unset field */ 17 .tm_isdst = 1234, 18 }; 19 time_t time = 1561994005; 20 21 zassert_equal(&tm, gmtime_r(&time, &tm), 22 "gmtime_r return failed"); 23 24 struct tm *tp = gmtime(&time); 25 26 zassert_true(memcmp(&tm, tp, sizeof(tm)) == 0, 27 "gmtime disagrees with gmtime_r"); 28 } 29