42 #define TZDIR "/usr/share/lib/zoneinfo" 44 #define TZDIR "/usr/share/zoneinfo" 50 const char *
zones[] = {
"America/Chicago",
"America/New_York" };
53 struct ast_tm atm[ARRAY_LEN(zones)];
54 char tmpdir[] =
"/tmp/timezone.XXXXXX";
55 char tzfile[50], syscmd[256];
59 info->name =
"timezone_watch";
60 info->category =
"/main/stdtime/";
61 info->summary =
"Verify deleting timezone file purges cache";
63 "Verifies that the caching engine properly destroys a timezone entry when its file is deleted.";
73 snprintf(tzfile,
sizeof(tzfile),
"%s/test", tmpdir);
85 snprintf(syscmd,
sizeof(syscmd),
"%s " TZDIR "/%s %s", type == 0 ?
"cp" :
"ln -sf", zones[i], tzfile);
106 snprintf(syscmd,
sizeof(syscmd),
"rm -rf %s", tmpdir);
118 info->name =
"time_str_to_unit";
119 info->category =
"/main/stdtime/";
120 info->summary =
"Verify string to time unit conversions";
172 info->name =
"time_create_by_unit";
173 info->category =
"/main/stdtime/";
174 info->summary =
"Verify unit value to timeval conversions";
195 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
198 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
201 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
212 info->name =
"time_create_by_unit_str";
213 info->category =
"/main/stdtime/";
214 info->summary =
"Verify value with unit as a string to timeval conversions";
235 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
238 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
241 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
252 info->name =
"time_tv_to_usec";
253 info->category =
"/main/stdtime/";
254 info->summary =
"Verify conversion of a timeval structure to microseconds";
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
ast_suseconds_t ast_time_tv_to_usec(const struct timeval *tv)
Convert a timeval structure to microseconds.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
struct timeval ast_time_create_by_unit_str(unsigned long val, const char *unit)
Convert the given unit value, and create a timeval object from it.
#define AST_TEST_REGISTER(cb)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
static int unload_module(void)
#define ast_test_status_update(a, b, c...)
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
char * mkdtemp(char *template_s)
#define AST_TEST_UNREGISTER(cb)
static int load_module(void)
AST_TEST_DEFINE(test_timezone_watch)
struct timeval ast_time_create(ast_time_t sec, ast_suseconds_t usec)
Create a timeval object initialized to given values.
enum TIME_UNIT ast_time_str_to_unit(const char *unit)
Convert a string to a time unit enumeration value.
struct timeval ast_time_create_by_unit(unsigned long val, enum TIME_UNIT unit)
Convert the given unit value, and create a timeval object from it.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
void ast_localtime_wakeup_monitor(struct ast_test *info)