#include "../../../../src/libs/zbxsysinfo/sysinfo.h"
#include "../../../../src/libs/zbxsysinfo/common/system.h"
#define LONG_DATETIME_LENGTH 30
#define SHORT_DATETIME_LENGTH 19
static zbx_timespec_t timespec;
time_t __wrap_time(time_t *seconds);
int __wrap_gettimeofday(struct timeval *__restrict tv, void *tz);
static void zbx_mock_time(void)
static int time_parsed = 0;
zbx_mock_handle_t param_handle;
memset(&tm, 0, sizeof(tm));
memset(×pec, 0, sizeof(timespec));
if (ZBX_MOCK_SUCCESS != (error = zbx_mock_in_parameter("timestamp", ¶m_handle)) ||
ZBX_MOCK_SUCCESS != (error = zbx_mock_string(param_handle, ×tamp)))
fail_msg("Cannot get expected 'timestamp' parameter from test case data: %s",
zbx_mock_error_string(error));
length = strlen(timestamp);
if (SHORT_DATETIME_LENGTH == length || LONG_DATETIME_LENGTH == length)
if (6 != sscanf(timestamp, "%04d-%02d-%02d,%02d:%02d:%02d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
&tm.tm_hour, &tm.tm_min, &tm.tm_sec) || 1900 > tm.tm_year || 1 > tm.tm_mon ||
12 < tm.tm_mon || 1 > tm.tm_mday || 31 < tm.tm_mday || 0 > tm.tm_hour ||
23 < tm.tm_hour || 0 > tm.tm_min || 59 < tm.tm_min || 0 > tm.tm_sec || 59 < tm.tm_sec)
fail_msg("Cannot parse date and time part of 'timestamp' parameter: %s", timestamp);