struct stasis_message *msg;
struct stasis_message_type *type;
struct ast_endpoint_snapshot *actual_snapshot;
+ int expected_count;
int actual_count;
+ int i;
+ int got_channel = 0;
+ int got_endpoint = 0;
switch (cmd) {
case TEST_INIT:
ast_hangup(chan);
chan = NULL;
- actual_count = stasis_message_sink_wait_for_count(sink, 3,
+ expected_count = 3;
+ actual_count = stasis_message_sink_wait_for_count(sink, expected_count,
STASIS_SINK_DEFAULT_WAIT);
- ast_test_validate(test, 3 == actual_count);
-
- msg = sink->messages[1];
- type = stasis_message_type(msg);
- ast_test_validate(test, ast_channel_snapshot_type() == type);
-
- msg = sink->messages[2];
- type = stasis_message_type(msg);
- ast_test_validate(test, ast_endpoint_snapshot_type() == type);
+ ast_test_validate(test, expected_count == actual_count);
+
+ for (i = 0; i < expected_count; i++) {
+ msg = sink->messages[i];
+ type = stasis_message_type(msg);
+ if (type == ast_channel_snapshot_type()) {
+ got_channel = 1;
+ }
+ if (type == ast_endpoint_snapshot_type()) {
+ got_endpoint = 1;
+ }
+ }
+ ast_test_validate(test, got_channel && got_endpoint);
actual_snapshot = stasis_message_data(msg);
ast_test_validate(test, 0 == actual_snapshot->num_channels);