aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2011-06-15 16:49:34 +0000
committerrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2011-06-15 16:49:34 +0000
commit416c0d88788e4c5e7b6129b47184ee3cb7b99ea3 (patch)
tree3e0e15763076bb6aa6b3576e908989b31f6cfe03 /tests
parent2964f0b2162c32cb18bd8deb2743cdc5952c4d06 (diff)
Merged revisions 323669-323670 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r323669 | rmudgett | 2011-06-15 11:43:18 -0500 (Wed, 15 Jun 2011) | 21 lines [regression] Voicemail MWI is no longer sent. When leaving a voicemail, the MWI message is never sent. The same thing happens when checking a voicemail and marking it as read. If you restart Asterisk, everything comes up at that state correctly, but changes to the messages in voicemail causes the light to not be set appropriately. Very easy to reproduce. * Made ast_event_check_subscriber() return TRUE if there are ANY subscribers to an event type when there are no restricting ie values passed. This allows an event being queued to be queued. (closes issue ASTERISK-18002) Reported by: lmadsen Tested by: lmadsen, irroot Patches: jira_asterisk_18002_v1.8.patch uploaded by rmudgett (License #5621) (closes issue ASTERISK-18019) ........ r323670 | rmudgett | 2011-06-15 11:43:31 -0500 (Wed, 15 Jun 2011) | 7 lines Add a test to the event unit tests to catch ASTERISK-18002. The new tests check to see if there are ANY subscribers to the event type when ast_event_check_subscriber() is not passed any specific ie values. (issue ASTERISK-18002) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@323671 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'tests')
-rw-r--r--tests/test_event.c87
1 files changed, 65 insertions, 22 deletions
diff --git a/tests/test_event.c b/tests/test_event.c
index 5f0c1003c..bc84b1857 100644
--- a/tests/test_event.c
+++ b/tests/test_event.c
@@ -312,7 +312,7 @@ AST_TEST_DEFINE(event_sub_test)
.expected_count = 2,
},
[TEST_SUBS_CUSTOM_RAW] = {
- .expected_count = 1,
+ .expected_count = 2,
},
[TEST_SUBS_CUSTOM_UINT] = {
.expected_count = 1,
@@ -344,28 +344,13 @@ AST_TEST_DEFINE(event_sub_test)
break;
}
- /*
- * Subscription TEST_SUBS_ALL_STR:
- * - allocate normally
- * - subscribe to ALL events with a DEVICE STR IE check
- */
- ast_test_status_update(test, "Adding TEST_SUBS_ALL_STR subscription\n");
- test_subs[TEST_SUBS_ALL_STR].sub = ast_event_subscribe(AST_EVENT_ALL, event_sub_cb,
- test_subs_class_type_str(TEST_SUBS_ALL_STR), &test_subs[TEST_SUBS_ALL_STR].data,
- AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "FOO/bar",
+ ast_test_status_update(test, "Check that NO CUSTOM subscribers exist\n");
+ sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM,
AST_EVENT_IE_END);
- if (!test_subs[TEST_SUBS_ALL_STR].sub) {
- ast_test_status_update(test, "Failed to create TEST_SUBS_ALL_STR subscription\n");
- res = AST_TEST_FAIL;
- goto return_cleanup;
- }
-
- if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_ALL_STR].sub),
- test_subs_class_type_str(TEST_SUBS_ALL_STR))) {
- ast_test_status_update(test,
- "Unexpected subscription description on TEST_SUBS_ALL_STR subscription\n");
+ if (sub_res != AST_EVENT_SUB_NONE) {
+ ast_test_status_update(test, "CUSTOM subscriptions should not exist! (%d)\n",
+ sub_res);
res = AST_TEST_FAIL;
- goto return_cleanup;
}
/*
@@ -392,6 +377,39 @@ AST_TEST_DEFINE(event_sub_test)
goto return_cleanup;
}
+ ast_test_status_update(test, "Check that a CUSTOM subscriber exists\n");
+ sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM,
+ AST_EVENT_IE_END);
+ if (sub_res != AST_EVENT_SUB_EXISTS) {
+ ast_test_status_update(test, "A CUSTOM subscription should exist! (%d)\n",
+ sub_res);
+ res = AST_TEST_FAIL;
+ }
+
+ /*
+ * Subscription TEST_SUBS_ALL_STR:
+ * - allocate normally
+ * - subscribe to ALL events with a DEVICE STR IE check
+ */
+ ast_test_status_update(test, "Adding TEST_SUBS_ALL_STR subscription\n");
+ test_subs[TEST_SUBS_ALL_STR].sub = ast_event_subscribe(AST_EVENT_ALL, event_sub_cb,
+ test_subs_class_type_str(TEST_SUBS_ALL_STR), &test_subs[TEST_SUBS_ALL_STR].data,
+ AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "FOO/bar",
+ AST_EVENT_IE_END);
+ if (!test_subs[TEST_SUBS_ALL_STR].sub) {
+ ast_test_status_update(test, "Failed to create TEST_SUBS_ALL_STR subscription\n");
+ res = AST_TEST_FAIL;
+ goto return_cleanup;
+ }
+
+ if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_ALL_STR].sub),
+ test_subs_class_type_str(TEST_SUBS_ALL_STR))) {
+ ast_test_status_update(test,
+ "Unexpected subscription description on TEST_SUBS_ALL_STR subscription\n");
+ res = AST_TEST_FAIL;
+ goto return_cleanup;
+ }
+
/*
* Subscription TEST_SUBS_CUSTOM_RAW:
* - allocate normally
@@ -576,7 +594,7 @@ AST_TEST_DEFINE(event_sub_test)
/*
* Exercise the API call to check for existing subscriptions.
*/
- ast_test_status_update(test, "Checking for subscribers to events\n");
+ ast_test_status_update(test, "Checking for subscribers to specific events\n");
/* Check STR matching. */
sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM,
@@ -678,6 +696,31 @@ AST_TEST_DEFINE(event_sub_test)
res = AST_TEST_FAIL;
}
+ ast_test_status_update(test, "Special event posting test\n");
+
+ /*
+ * Event to check if event is even posted.
+ *
+ * Matching subscriptions:
+ * TEST_SUBS_CUSTOM_RAW
+ */
+ event = ast_event_new(AST_EVENT_CUSTOM,
+ AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "Mula",
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar"),
+ AST_EVENT_IE_END);
+ if (!event) {
+ ast_test_status_update(test, "Failed to create event\n");
+ res = AST_TEST_FAIL;
+ goto return_cleanup;
+ }
+ if (ast_event_queue(event)) {
+ ast_event_destroy(event);
+ event = NULL;
+ ast_test_status_update(test, "Failed to queue event\n");
+ res = AST_TEST_FAIL;
+ goto return_cleanup;
+ }
+
/*
* Subscription TEST_SUBS_CUSTOM_ANY:
* - allocate normally