aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_time.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-05-13 05:37:31 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-05-13 05:37:31 +0000
commit08b5d748944bb22ea4a32c74eb6bbfe9a1bfca8d (patch)
tree9d4eb039249b19afa0243f1406142d0958f96481 /tests/test_time.c
parent46202599e2b9535853f07ba9a6329eb78c72cf39 (diff)
Add kqueue(2) implementation to Asterisk in various places.
This will save a considerable amount of CPU on the BSDs, including Mac OS X, as it eliminates several places in the code that we previously used a busy loop. Additionally, this adds a res_timing interface, using kqueue timers. Review: https://reviewboard.asterisk.org/r/543/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@262852 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'tests/test_time.c')
-rw-r--r--tests/test_time.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/tests/test_time.c b/tests/test_time.c
index 21e4f3836..61a201498 100644
--- a/tests/test_time.c
+++ b/tests/test_time.c
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 2009, Digium, Inc.
+ * Copyright (C) 2010, Digium, Inc.
*
* Tilghman Lesher <tlesher AT digium DOT com>
*
@@ -48,10 +48,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
AST_TEST_DEFINE(test_timezone_watch)
{
- const char *zones[2] = { "America/Chicago", "America/New_York" };
+ const char *zones[] = { "America/Chicago", "America/New_York" };
int type, i, res = AST_TEST_PASS;
struct timeval tv = ast_tvnow();
- struct ast_tm atm[2];
+ struct ast_tm atm[ARRAY_LEN(zones)];
char tmpdir[] = "/tmp/timezone.XXXXXX";
char tzfile[50], syscmd[256];
@@ -73,15 +73,12 @@ AST_TEST_DEFINE(test_timezone_watch)
}
snprintf(tzfile, sizeof(tzfile), "%s/test", tmpdir);
- /* Allow system(3) to function correctly */
- ast_replace_sigchld();
-
for (type = 0; type < 2; type++) {
ast_test_status_update(test, "Executing %s test...\n", type == 0 ? "deletion" : "symlink");
for (i = 0; i < ARRAY_LEN(zones); i++) {
int system_res;
snprintf(syscmd, sizeof(syscmd), "%s " TZDIR "/%s %s", type == 0 ? "cp" : "ln -sf", zones[i], tzfile);
- if ((system_res = system(syscmd))) {
+ if ((system_res = ast_safe_system(syscmd))) {
ast_log(LOG_WARNING, "system(%s) returned non-zero: %d\n", syscmd, system_res);
}
ast_localtime_wakeup_monitor();
@@ -93,19 +90,18 @@ AST_TEST_DEFINE(test_timezone_watch)
}
}
- /* stat(2) only has resolution to 1 second - must wait, or the mtime is the same */
- usleep(1100000);
+ if (i + 1 != ARRAY_LEN(zones)) {
+ /* stat(2) only has resolution to 1 second - must wait, or the mtime is the same */
+ usleep(1100000);
+ }
}
}
snprintf(syscmd, sizeof(syscmd), "rm -rf %s", tmpdir);
- if (system(syscmd)) {
+ if (ast_safe_system(syscmd)) {
ast_log(LOG_WARNING, "system(%s) returned non-zero.\n", syscmd);
}
- /* Restore SIGCHLD handler */
- ast_unreplace_sigchld();
-
return res;
}