42#define TZDIR "/usr/share/lib/zoneinfo"
44#define TZDIR "/usr/share/zoneinfo"
50 const char *
zones[] = {
"America/Chicago",
"America/New_York" };
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);
110 snprintf(syscmd,
sizeof(syscmd),
"rm -rf %s", tmpdir);
122 info->name =
"time_str_to_unit";
123 info->category =
"/main/stdtime/";
124 info->summary =
"Verify string to time unit conversions";
176 info->name =
"time_create_by_unit";
177 info->category =
"/main/stdtime/";
178 info->summary =
"Verify unit value to timeval conversions";
199 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
202 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
205 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
216 info->name =
"time_create_by_unit_str";
217 info->category =
"/main/stdtime/";
218 info->summary =
"Verify value with unit as a string to timeval conversions";
239 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
242 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
245 ast_test_validate(
test, tv.tv_sec == 1 && tv.tv_usec == 500000);
256 info->name =
"time_tv_to_usec";
257 info->category =
"/main/stdtime/";
258 info->summary =
"Verify conversion of a timeval structure to microseconds";
Asterisk main include file. File version handling, generic pbx functions.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
char * mkdtemp(char *template_s)
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
void ast_localtime_wakeup_monitor(struct ast_test *info)
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
AST_TEST_DEFINE(test_timezone_watch)
static int load_module(void)
static int unload_module(void)
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(ast_time_t sec, ast_suseconds_t usec)
Create a timeval object initialized to given values.
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.
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.
ast_suseconds_t ast_time_tv_to_usec(const struct timeval *tv)
Convert a timeval structure to microseconds.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().