summaryrefslogtreecommitdiff
path: root/qpid/extras/dispatch/tests
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2013-04-29 19:48:59 +0000
committerTed Ross <tross@apache.org>2013-04-29 19:48:59 +0000
commit170134a81e51549f2e22c0d96303e5ab8be6fec9 (patch)
tree7f709bb09913cc9010d1a25613d80027bda853b8 /qpid/extras/dispatch/tests
parent80abf8f30a3e135f40417813a4c79a9cb67a0bf3 (diff)
downloadqpid-python-170134a81e51549f2e22c0d96303e5ab8be6fec9.tar.gz
QPID-4788 - Fixed linked-list corruption when an immediate timer is re-scheduled. Added test.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1477300 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/extras/dispatch/tests')
-rw-r--r--qpid/extras/dispatch/tests/timer_test.c25
-rw-r--r--qpid/extras/dispatch/tests/tool_test.c41
2 files changed, 66 insertions, 0 deletions
diff --git a/qpid/extras/dispatch/tests/timer_test.c b/qpid/extras/dispatch/tests/timer_test.c
index be20d2aabb..93725dde4b 100644
--- a/qpid/extras/dispatch/tests/timer_test.c
+++ b/qpid/extras/dispatch/tests/timer_test.c
@@ -94,6 +94,30 @@ static char* test_immediate(void *context)
}
+static char* test_immediate_reschedule(void *context)
+{
+ while(fire_head());
+ fire_mask = 0;
+
+ dx_timer_schedule(timers[0], 0);
+ dx_timer_schedule(timers[0], 0);
+
+ if (fire_mask != 0) return "pass 1 - Premature firing";
+ if (fire_head() > 1) return "pass 1 - Too many firings";
+ if (fire_mask != 1) return "pass 1 - Incorrect fire mask";
+
+ fire_mask = 0;
+ dx_timer_schedule(timers[0], 0);
+ dx_timer_schedule(timers[0], 0);
+
+ if (fire_mask != 0) return "pass 2 - Premature firing";
+ if (fire_head() > 1) return "pass 2 - Too many firings";
+ if (fire_mask != 1) return "pass 2 - Incorrect fire mask";
+
+ return 0;
+}
+
+
static char* test_immediate_plus_delayed(void *context)
{
while(fire_head());
@@ -369,6 +393,7 @@ int timer_tests(void)
TEST_CASE(test_quiet, 0);
TEST_CASE(test_immediate, 0);
+ TEST_CASE(test_immediate_reschedule, 0);
TEST_CASE(test_immediate_plus_delayed, 0);
TEST_CASE(test_single, 0);
TEST_CASE(test_two_inorder, 0);
diff --git a/qpid/extras/dispatch/tests/tool_test.c b/qpid/extras/dispatch/tests/tool_test.c
index 7923ee3381..ba047d928c 100644
--- a/qpid/extras/dispatch/tests/tool_test.c
+++ b/qpid/extras/dispatch/tests/tool_test.c
@@ -148,11 +148,52 @@ static char* test_deq_basic(void *context)
}
+static char* test_deq_basic2(void *context)
+{
+ item_list_t list;
+ item_t item[10];
+ item_t *ptr;
+ int idx;
+ char *subtest;
+
+ DEQ_INIT(list);
+ if (DEQ_SIZE(list) != 0) return "Expected zero initial size";
+
+ for (idx = 0; idx < 10; idx++) {
+ DEQ_ITEM_INIT(&item[idx]);
+ item[idx].letter = '0' + idx;
+ }
+
+ DEQ_INSERT_TAIL(list, &item[0]);
+ if (DEQ_SIZE(list) != 1) return "Expected 1 items in list";
+ subtest = list_well_formed(list, "0");
+ if (subtest) return subtest;
+
+ ptr = DEQ_HEAD(list);
+ DEQ_REMOVE_HEAD(list);
+ if (ptr->letter != '0') return "Expected item '0'";
+ if (DEQ_SIZE(list) != 0) return "Expected 0 items in list";
+
+ DEQ_INSERT_TAIL(list, &item[0]);
+ if (DEQ_SIZE(list) != 1) return "Expected 1 items in list";
+ subtest = list_well_formed(list, "0");
+ if (subtest) return subtest;
+
+ ptr = DEQ_HEAD(list);
+ DEQ_REMOVE_HEAD(list);
+ if (ptr->letter != '0') return "Expected item '0'";
+ if (DEQ_SIZE(list) != 0) return "Expected 0 items in list";
+
+ return 0;
+}
+
+
int tool_tests(void)
{
int result = 0;
TEST_CASE(test_deq_basic, 0);
+ TEST_CASE(test_deq_basic2, 0);
return result;
}