[asterisk-commits] rmudgett: branch rmudgett/stasis_cache r409107 - /team/rmudgett/stasis_cache/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Feb 27 11:13:03 CST 2014


Author: rmudgett
Date: Thu Feb 27 11:12:57 2014
New Revision: 409107

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=409107
Log:
test_devicestate.c: Revert -r409051.

The cache subscription actually doesn't get updated in a task processor
thread but immediately on the posting thread because its subscription
doesn't have an associated task processor.

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=409107&r1=409106&r2=409107
==============================================================================
--- team/rmudgett/stasis_cache/tests/test_devicestate.c (original)
+++ team/rmudgett/stasis_cache/tests/test_devicestate.c Thu Feb 27 11:12:57 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 */
+	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);
-
-	/* Check cache aggregate 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);
-
-	/* push remote state */
-	consumer_reset(consumer);
-	/* 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 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);
-
-	/* Check cache aggregate state */
+	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 */
 	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);
-
-	/* 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);
+	ast_test_validate(test, AST_DEVICE_INUSE == device_state->state);
 
 	/* 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);
-
-	/* Check cache aggregate state */
+	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 */
 	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);
-
-	/* 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);
+	ast_test_validate(test, AST_DEVICE_RINGINUSE == device_state->state);
 
 	/* 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);
-
-	/* 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);
+	consumer_reset(consumer);
 
 	return AST_TEST_PASS;
 }




More information about the asterisk-commits mailing list