Add smoke test for gettimeofday()

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2026-02-23 14:00:23 +01:00
parent 60cfb78882
commit 5c6ec6bcc0
2 changed files with 16 additions and 0 deletions

View File

@@ -10,3 +10,7 @@ clock_gettime_available:CLOCK_REALTIME
# CLOCK_BOOTTIME is available.
clock_gettime(CLOCK_MONOTONIC) smoke test
clock_gettime_available:CLOCK_MONOTONIC
# Used in library/timing.c and programs/test/benchmark.c
gettimeofday() smoke test
gettimeofday_available:

View File

@@ -13,6 +13,7 @@
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
#else /* defined(MBEDTLS_PLATFORM_IS_UNIXLIKE) */
@@ -54,3 +55,14 @@ void clock_gettime_available(int clockid)
TEST_LE_S(1, ts.tv_sec);
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_PLATFORM_IS_UNIXLIKE */
void gettimeofday_available()
{
struct timeval tv = { 0, 0 };
memset(&tv, 0, sizeof(tv));
int ret = gettimeofday(&tv, NULL);
TEST_ASSERT_ERRNO(ret == 0);
TEST_LE_S(1, tv.tv_sec);
}
/* END_CASE */