[asterisk-commits] rmudgett: branch rmudgett/stasis_cache r409051 - /team/rmudgett/stasis_cache/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Feb 27 09:52:20 CST 2014
Author: rmudgett
Date: Thu Feb 27 09:52:14 2014
New Revision: 409051
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=409051
Log:
test_devicestate.c: Check cache after getting events.
You cannot check the cache immediately after calling stasis_publish().
The cache is itself subscribed to the stasis events and executed in a task
processor thread.
Modified:
team/rmudgett/stasis_cache/tests/test_devicestate.c
Modified: team/rmudgett/stasis_cache/tests/test_devicestate.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/stasis_cache/tests/test_devicestate.c?view=diff&rev=409051&r1=409050&r2=409051
==============================================================================
--- team/rmudgett/stasis_cache/tests/test_devicestate.c (original)
+++ team/rmudgett/stasis_cache/tests/test_devicestate.c Thu Feb 27 09:52:14 2014
@@ -455,69 +455,69 @@
ast_test_validate(test, !res);
/* push local state */
+ consumer_reset(consumer);
ast_publish_device_state(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE);
- /* Check cache aggregate state immediately */
+ consumer_wait_for(consumer);
+ ast_test_validate(test, AST_DEVICE_NOT_INUSE == consumer->state);
+ ast_test_validate(test, AST_DEVICE_NOT_INUSE == consumer->aggregate_state);
+ ast_test_validate(test, 2 == consumer->event_count);
+
+ /* Check cache aggregate state */
ao2_cleanup(msg);
msg = stasis_cache_get_by_eid(ast_device_state_cache(), ast_device_state_message_type(), UNIT_TEST_DEVICE_IDENTIFIER, NULL);
device_state = stasis_message_data(msg);
ast_test_validate(test, AST_DEVICE_NOT_INUSE == device_state->state);
- consumer_wait_for(consumer);
- ast_test_validate(test, AST_DEVICE_NOT_INUSE == consumer->state);
- ast_test_validate(test, AST_DEVICE_NOT_INUSE == consumer->aggregate_state);
- ast_test_validate(test, 2 == consumer->event_count);
+ /* push remote state */
consumer_reset(consumer);
-
- /* push remote state */
/* this will not produce a new aggregate state message since the aggregate state does not change */
consumer->sig_on_non_aggregate_state = 1;
ast_publish_device_state_full(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, foreign_eid);
-
- /* Check cache aggregate state immediately */
- ao2_cleanup(msg);
- msg = stasis_cache_get_by_eid(ast_device_state_cache(), ast_device_state_message_type(), UNIT_TEST_DEVICE_IDENTIFIER, NULL);
- device_state = stasis_message_data(msg);
- ast_test_validate(test, AST_DEVICE_NOT_INUSE == device_state->state);
/* Check for expected events. */
consumer_wait_for(consumer);
ast_test_validate(test, AST_DEVICE_NOT_INUSE == consumer->state);
ast_test_validate(test, AST_DEVICE_TOTAL == consumer->aggregate_state);
ast_test_validate(test, 1 == consumer->event_count);
- consumer_reset(consumer);
-
- /* push remote state different from local state */
- ast_publish_device_state_full(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, foreign_eid);
-
- /* Check cache aggregate state immediately */
+
+ /* Check cache aggregate state */
ao2_cleanup(msg);
msg = stasis_cache_get_by_eid(ast_device_state_cache(), ast_device_state_message_type(), UNIT_TEST_DEVICE_IDENTIFIER, NULL);
device_state = stasis_message_data(msg);
- ast_test_validate(test, AST_DEVICE_INUSE == device_state->state);
+ ast_test_validate(test, AST_DEVICE_NOT_INUSE == device_state->state);
+
+ /* push remote state different from local state */
+ consumer_reset(consumer);
+ ast_publish_device_state_full(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, foreign_eid);
/* Check for expected events. */
consumer_wait_for(consumer);
ast_test_validate(test, AST_DEVICE_INUSE == consumer->state);
ast_test_validate(test, AST_DEVICE_INUSE == consumer->aggregate_state);
ast_test_validate(test, 2 == consumer->event_count);
- consumer_reset(consumer);
-
- /* push local state that will cause aggregated state different from local non-aggregate state */
- ast_publish_device_state(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_RINGING, AST_DEVSTATE_CACHABLE);
-
- /* Check cache aggregate state immediately */
+
+ /* Check cache aggregate state */
ao2_cleanup(msg);
msg = stasis_cache_get_by_eid(ast_device_state_cache(), ast_device_state_message_type(), UNIT_TEST_DEVICE_IDENTIFIER, NULL);
device_state = stasis_message_data(msg);
- ast_test_validate(test, AST_DEVICE_RINGINUSE == device_state->state);
+ ast_test_validate(test, AST_DEVICE_INUSE == device_state->state);
+
+ /* push local state that will cause aggregated state different from local non-aggregate state */
+ consumer_reset(consumer);
+ ast_publish_device_state(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_RINGING, AST_DEVSTATE_CACHABLE);
/* Check for expected events. */
consumer_wait_for(consumer);
ast_test_validate(test, AST_DEVICE_RINGING == consumer->state);
ast_test_validate(test, AST_DEVICE_RINGINUSE == consumer->aggregate_state);
ast_test_validate(test, 2 == consumer->event_count);
- consumer_reset(consumer);
+
+ /* Check cache aggregate state */
+ ao2_cleanup(msg);
+ msg = stasis_cache_get_by_eid(ast_device_state_cache(), ast_device_state_message_type(), UNIT_TEST_DEVICE_IDENTIFIER, NULL);
+ device_state = stasis_message_data(msg);
+ ast_test_validate(test, AST_DEVICE_RINGINUSE == device_state->state);
return AST_TEST_PASS;
}
More information about the asterisk-commits
mailing list