Author: rmudgett Date: Mon Nov 24 14:39:01 2014 New Revision: 428605 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=428605 Log: test_channel_feature_hooks.c: Fix unit test for DTMF hooks.
Fix the failing /channels/features/test_features_channel_dtmf unit test. DTMF emulation does not work without a stream of packets to prod the emulation code. Review: https://reviewboard.asterisk.org/r/4199/ ........ Merged revisions 428604 from http://svn.asterisk.org/svn/asterisk/branches/13 Modified: trunk/ (props changed) trunk/tests/test_channel_feature_hooks.c Propchange: trunk/ ------------------------------------------------------------------------------ Binary property 'branch-13-merged' - no diff available. Modified: trunk/tests/test_channel_feature_hooks.c URL: http://svnview.digium.com/svn/asterisk/trunk/tests/test_channel_feature_hooks.c?view=diff&rev=428605&r1=428604&r2=428605 ============================================================================== --- trunk/tests/test_channel_feature_hooks.c (original) +++ trunk/tests/test_channel_feature_hooks.c Mon Nov 24 14:39:01 2014 @@ -76,12 +76,10 @@ /*! \brief Wait until a channel is not bridged */ static void wait_for_unbridged(struct ast_channel *channel) { - struct timespec short_sleep = {0, 1000000}; ast_channel_lock(channel); while (ast_channel_is_bridged(channel)) { ast_channel_unlock(channel); - while ((nanosleep(&short_sleep, &short_sleep) == -1) && (errno == EINTR)) { - } + test_nanosleep(0, 1000000); ast_channel_lock(channel); } ast_channel_unlock(channel); @@ -128,6 +126,29 @@ int *callback_executed = obj; (*callback_executed)++; return 0; +} + +/* Need to post null frames periodically so DTMF emulation can work. */ +static void stream_periodic_frames(struct ast_channel *chan, int ms, int interval_ms) +{ + long nanosecs; + + ast_assert(chan != NULL); + ast_assert(0 < ms); + ast_assert(0 < interval_ms); + + nanosecs = interval_ms * 1000000L; + while (0 < ms) { + ast_queue_frame(chan, &ast_null_frame); + + if (interval_ms < ms) { + ms -= interval_ms; + } else { + nanosecs = ms * 1000000L; + ms = 0; + } + test_nanosleep(0, nanosecs); + } } AST_TEST_DEFINE(test_features_channel_dtmf) @@ -185,7 +206,7 @@ ast_queue_frame(chan_alice, &f); ast_queue_frame(chan_alice, &f); - test_nanosleep(1, 0); + stream_periodic_frames(chan_alice, 1000, 20); /* Remove the channels from the bridge */ ast_test_validate(test, !ast_bridge_depart(chan_alice)); @@ -208,7 +229,7 @@ ast_queue_frame(chan_alice, &f); ast_queue_frame(chan_alice, &f); - test_nanosleep(1, 0); + stream_periodic_frames(chan_alice, 1000, 20); /* Remove the channels from the bridge */ ast_test_validate(test, !ast_bridge_depart(chan_alice)); -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits
