[svn-commits] mmichelson: branch mmichelson/threadpool r377475 - /team/mmichelson/threadpoo...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Sun Dec 9 13:06:36 CST 2012
Author: mmichelson
Date: Sun Dec 9 13:06:35 2012
New Revision: 377475
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=377475
Log:
Add some useful debugging in threadpool test failure conditions.
Modified:
team/mmichelson/threadpool/tests/test_threadpool.c
Modified: team/mmichelson/threadpool/tests/test_threadpool.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/threadpool/tests/test_threadpool.c?view=diff&rev=377475&r1=377474&r2=377475
==============================================================================
--- team/mmichelson/threadpool/tests/test_threadpool.c (original)
+++ team/mmichelson/threadpool/tests/test_threadpool.c Sun Dec 9 13:06:35 2012
@@ -67,7 +67,6 @@
{
struct test_listener_data *tld = listener->private_data;
SCOPED_MUTEX(lock, &tld->lock);
- ast_log(LOG_NOTICE, "State changed: num_active: %d, num_idle: %d\n", active_threads, idle_threads);
tld->num_active = active_threads;
tld->num_idle = idle_threads;
ast_cond_signal(&tld->cond);
@@ -97,7 +96,6 @@
static void test_destroy(void *private_data)
{
struct test_listener_data *tld = private_data;
- ast_debug(1, "Poop\n");
ast_cond_destroy(&tld->cond);
ast_mutex_destroy(&tld->lock);
ast_free(tld);
@@ -162,7 +160,7 @@
}
}
-static enum ast_test_result_state wait_for_completion(struct simple_task_data *std)
+static enum ast_test_result_state wait_for_completion(struct ast_test *test, struct simple_task_data *std)
{
struct timeval start = ast_tvnow();
struct timespec end = {
@@ -177,12 +175,13 @@
}
if (!std->task_executed) {
+ ast_test_status_update(test, "Task execution did not occur\n");
res = AST_TEST_FAIL;
}
return res;
}
-static enum ast_test_result_state wait_for_empty_notice(struct test_listener_data *tld)
+static enum ast_test_result_state wait_for_empty_notice(struct ast_test *test, struct test_listener_data *tld)
{
struct timeval start = ast_tvnow();
struct timespec end = {
@@ -197,6 +196,7 @@
}
if (!tld->empty_notice) {
+ ast_test_status_update(test, "Test listener never told that threadpool is empty\n");
res = AST_TEST_FAIL;
}
@@ -443,12 +443,12 @@
* so the newly-created thread should immediately execute
* the waiting task.
*/
- res = wait_for_completion(std);
- if (res == AST_TEST_FAIL) {
- goto end;
- }
-
- res = wait_for_empty_notice(tld);
+ res = wait_for_completion(test, std);
+ if (res == AST_TEST_FAIL) {
+ goto end;
+ }
+
+ res = wait_for_empty_notice(test, tld);
if (res == AST_TEST_FAIL) {
goto end;
}
@@ -510,12 +510,12 @@
ast_threadpool_push(pool, simple_task, std);
- res = wait_for_completion(std);
- if (res == AST_TEST_FAIL) {
- goto end;
- }
-
- res = wait_for_empty_notice(tld);
+ res = wait_for_completion(test, std);
+ if (res == AST_TEST_FAIL) {
+ goto end;
+ }
+
+ res = wait_for_empty_notice(test, tld);
if (res == AST_TEST_FAIL) {
goto end;
}
@@ -583,20 +583,20 @@
ast_threadpool_push(pool, simple_task, std2);
ast_threadpool_push(pool, simple_task, std3);
- res = wait_for_completion(std1);
- if (res == AST_TEST_FAIL) {
- goto end;
- }
- res = wait_for_completion(std2);
- if (res == AST_TEST_FAIL) {
- goto end;
- }
- res = wait_for_completion(std3);
- if (res == AST_TEST_FAIL) {
- goto end;
- }
-
- res = wait_for_empty_notice(tld);
+ res = wait_for_completion(test, std1);
+ if (res == AST_TEST_FAIL) {
+ goto end;
+ }
+ res = wait_for_completion(test, std2);
+ if (res == AST_TEST_FAIL) {
+ goto end;
+ }
+ res = wait_for_completion(test, std3);
+ if (res == AST_TEST_FAIL) {
+ goto end;
+ }
+
+ res = wait_for_empty_notice(test, tld);
if (res == AST_TEST_FAIL) {
goto end;
}
@@ -661,12 +661,12 @@
ast_threadpool_set_size(pool, 1);
- res = wait_for_completion(std1);
- if (res == AST_TEST_FAIL) {
- goto end;
- }
-
- res = wait_for_empty_notice(tld);
+ res = wait_for_completion(test, std1);
+ if (res == AST_TEST_FAIL) {
+ goto end;
+ }
+
+ res = wait_for_empty_notice(test, tld);
if (res == AST_TEST_FAIL) {
goto end;
}
@@ -678,12 +678,12 @@
/* Now make sure the threadpool reactivates when we add a second task */
ast_threadpool_push(pool, simple_task, std2);
- res = wait_for_completion(std2);
- if (res == AST_TEST_FAIL) {
- goto end;
- }
-
- res = wait_for_empty_notice(tld);
+ res = wait_for_completion(test, std2);
+ if (res == AST_TEST_FAIL) {
+ goto end;
+ }
+
+ res = wait_for_empty_notice(test, tld);
if (res == AST_TEST_FAIL) {
goto end;
}
More information about the svn-commits
mailing list