Changeset 5065


Ignore:
Timestamp:
Apr 13, 2015 12:14:02 PM (9 years ago)
Author:
nanang
Message:

Re #1842: Updated pjsua app to avoid stdout buffering, and also adjusted python tests accordingly.

Location:
pjproject/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_config.c

    r4868 r5065  
    212212    puts  (""); 
    213213 
     214    fflush(stdout); 
     215} 
     216 
     217static void log_writer_nobuf(int level, const char *buffer, int len) 
     218{ 
     219    pj_log_write(level, buffer, len); 
    214220    fflush(stdout); 
    215221} 
     
    12521258        case OPT_STDOUT_NO_BUF: 
    12531259            setvbuf(stdout, NULL, _IONBF, 0); 
     1260            cfg->log_cfg.cb = &log_writer_nobuf; 
    12541261            break; 
    12551262#endif 
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_legacy.c

    r4851 r5065  
    2424#define THIS_FILE       "pjsua_app_legacy.c" 
    2525 
     26 
     27/* An attempt to avoid stdout buffering for python tests: 
     28 * - call 'fflush(stdout)' after each call to 'printf()/puts()' 
     29 * - apply 'setbuf(stdout, 0)', but it is not guaranteed by the standard: 
     30 *   http://stackoverflow.com/questions/1716296 
     31 */ 
     32#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ 
     33    (defined (_MSC_VER) && _MSC_VER >= 1400) 
     34/* Variadic macro is introduced in C99; MSVC supports it in since 2005. */ 
     35#  define printf(...) {printf(__VA_ARGS__);fflush(stdout);} 
     36#  define puts(s) {puts(s);fflush(stdout);} 
     37#endif 
     38 
     39 
    2640static pj_bool_t        cmd_echo; 
    2741 
     
    3953    pjsua_enum_buddies(ids, &count); 
    4054 
    41     if (count == 0) 
     55    if (count == 0) { 
    4256        puts(" -none-"); 
    43     else { 
     57    } else { 
    4458        for (i=0; i<(int)count; ++i) { 
    4559            pjsua_buddy_info info; 
     
    10891103        } 
    10901104        if (result.nb_result != PJSUA_APP_NO_NB) { 
    1091             if (result.nb_result == -1 || result.nb_result == 0) 
     1105            if (result.nb_result == -1 || result.nb_result == 0) { 
    10921106                puts("You can't do that with transfer call!"); 
    1093             else { 
     1107            } else { 
    10941108                pjsua_buddy_info binfo; 
    10951109                pjsua_buddy_get_info(result.nb_result-1, &binfo); 
     
    16701684} 
    16711685 
     1686 
    16721687/* 
    16731688 * Main "user interface" loop. 
  • pjproject/trunk/tests/pjsua/mod_call.py

    r2078 r5065  
    5454 
    5555        # Wait until call is connected in both endpoints 
    56         time.sleep(0.2) 
     56        ##time.sleep(0.2) 
    5757        caller.expect(const.STATE_CONFIRMED) 
    5858        callee.expect(const.STATE_CONFIRMED) 
     
    6161        caller.sync_stdout() 
    6262        callee.sync_stdout() 
    63         time.sleep(0.1) 
    64         caller.sync_stdout() 
    65         callee.sync_stdout() 
    66  
    67         # Test that media is okay 
    68         time.sleep(0.3) 
     63        ##time.sleep(0.1) 
     64        caller.sync_stdout() 
     65        callee.sync_stdout() 
     66 
     67        # Test that media is okay 
     68        ##time.sleep(0.3) 
    6969        check_media(caller, callee) 
    7070        check_media(callee, caller) 
     
    7474        caller.expect("INVITE sip:") 
    7575        callee.expect("INVITE sip:") 
     76        callee.expect(const.MEDIA_HOLD) 
     77        caller.expect(const.MEDIA_HOLD) 
     78         
     79        # Synchronize stdout 
     80        caller.sync_stdout() 
     81        callee.sync_stdout() 
     82 
     83        # Release hold 
     84        ##time.sleep(0.5) 
     85        caller.send("v") 
     86        caller.expect("INVITE sip:") 
     87        callee.expect("INVITE sip:") 
     88        callee.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold") 
     89        caller.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold") 
     90 
     91        # Synchronize stdout 
     92        caller.sync_stdout() 
     93        callee.sync_stdout() 
     94 
     95        # Test that media is okay 
     96        check_media(caller, callee) 
     97        check_media(callee, caller) 
     98 
     99        # Synchronize stdout 
     100        caller.sync_stdout() 
     101        callee.sync_stdout() 
     102 
     103        # Hold call by callee 
     104        callee.send("H") 
     105        callee.expect("INVITE sip:") 
     106        caller.expect("INVITE sip:") 
    76107        caller.expect(const.MEDIA_HOLD) 
    77108        callee.expect(const.MEDIA_HOLD) 
     
    82113 
    83114        # Release hold 
    84         time.sleep(0.5) 
    85         caller.send("v") 
    86         caller.expect("INVITE sip:") 
    87         callee.expect("INVITE sip:") 
     115        ##time.sleep(0.1) 
     116        callee.send("v") 
     117        callee.expect("INVITE sip:") 
     118        caller.expect("INVITE sip:") 
    88119        caller.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold") 
    89120        callee.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold") 
     
    94125 
    95126        # Test that media is okay 
    96         check_media(caller, callee) 
    97         check_media(callee, caller) 
    98  
    99         # Synchronize stdout 
    100         caller.sync_stdout() 
    101         callee.sync_stdout() 
    102  
    103         # Hold call by callee 
    104         callee.send("H") 
    105         callee.expect("INVITE sip:") 
    106         caller.expect("INVITE sip:") 
    107         caller.expect(const.MEDIA_HOLD) 
    108         callee.expect(const.MEDIA_HOLD) 
    109          
    110         # Synchronize stdout 
    111         caller.sync_stdout() 
    112         callee.sync_stdout() 
    113  
    114         # Release hold 
    115         time.sleep(0.1) 
    116         callee.send("v") 
    117         callee.expect("INVITE sip:") 
    118         caller.expect("INVITE sip:") 
    119         callee.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold") 
    120         caller.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold") 
    121  
    122         # Synchronize stdout 
    123         caller.sync_stdout() 
    124         callee.sync_stdout() 
    125  
    126         # Test that media is okay 
    127127        # Wait for some time for ICE negotiation 
    128         time.sleep(0.6) 
     128        ##time.sleep(0.6) 
    129129        check_media(caller, callee) 
    130130        check_media(callee, caller) 
     
    145145 
    146146        # Test that media is okay 
    147         time.sleep(0.1) 
     147        ##time.sleep(0.1) 
    148148        check_media(caller, callee) 
    149149        check_media(callee, caller) 
     
    161161 
    162162        # Test that media is okay 
    163         time.sleep(0.1) 
     163        ##time.sleep(0.1) 
    164164        check_media(caller, callee) 
    165165        check_media(callee, caller) 
     
    194194         
    195195        # Test that media is still okay 
    196         time.sleep(0.1) 
     196        ##time.sleep(0.1) 
    197197        check_media(caller, callee) 
    198198        check_media(callee, caller) 
     
    208208         
    209209        # Test that media is still okay 
    210         time.sleep(0.1) 
     210        ##time.sleep(0.1) 
    211211        check_media(callee, caller) 
    212212        check_media(caller, callee) 
    213213 
    214214        # Hangup call 
    215         time.sleep(0.1) 
     215        ##time.sleep(0.1) 
    216216        caller.send("h") 
    217217 
  • pjproject/trunk/tests/pjsua/scripts-call/300_ice_1_1.py

    r2084 r5065  
    77                "Callee=use ICE, caller=use ICE", 
    88                [ 
    9                         InstanceParam("callee", "--null-audio --use-ice --max-calls=1", enable_buffer=True), 
    10                         InstanceParam("caller", "--null-audio --use-ice --max-calls=1", enable_buffer=True) 
     9                        InstanceParam("callee", "--null-audio --use-ice --max-calls=1"), 
     10                        InstanceParam("caller", "--null-audio --use-ice --max-calls=1") 
    1111                ] 
    1212                ) 
  • pjproject/trunk/tests/pjsua/scripts-call/305_ice_comp_1_2.py

    r2196 r5065  
    77                "Callee=use ICE, caller=use ICE", 
    88                [ 
    9                         InstanceParam("callee", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp", enable_buffer=True), 
    10                         InstanceParam("caller", "--null-audio --use-ice --max-calls=1", enable_buffer=True) 
     9                        InstanceParam("callee", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp"), 
     10                        InstanceParam("caller", "--null-audio --use-ice --max-calls=1") 
    1111                ] 
    1212                ) 
  • pjproject/trunk/tests/pjsua/scripts-call/305_ice_comp_2_1.py

    r2196 r5065  
    77                "Callee=use ICE, caller=use ICE", 
    88                [ 
    9                         InstanceParam("callee", "--null-audio --use-ice --max-calls=1", enable_buffer=True), 
    10                         InstanceParam("caller", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp", enable_buffer=True) 
     9                        InstanceParam("callee", "--null-audio --use-ice --max-calls=1"), 
     10                        InstanceParam("caller", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp") 
    1111                ] 
    1212                ) 
  • pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_2.py

    r2084 r5065  
    3232sendto_cfg = sip.SendtoCfg( "caller sends only one component",  
    3333                            pjsua_args=args, sdp=sdp, resp_code=200,  
    34                             resp_inc=include, resp_exc=exclude, 
    35                             enable_buffer = True) 
     34                            resp_inc=include, resp_exc=exclude) 
    3635 
  • pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_3.py

    r2376 r5065  
    3131sendto_cfg = sip.SendtoCfg( "caller sends two components without a=rtcp line",  
    3232                            pjsua_args=args, sdp=sdp, resp_code=200,  
    33                             resp_inc=include, resp_exc=exclude, 
    34                             enable_buffer = True) 
     33                            resp_inc=include, resp_exc=exclude) 
    3534 
  • pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_4.py

    r2376 r5065  
    3131sendto_cfg = sip.SendtoCfg( "pjsua with --ice-no-rtcp ignores RTCP things in the SDP",  
    3232                            pjsua_args=args, sdp=sdp, resp_code=200,  
    33                             resp_inc=include, resp_exc=exclude, 
    34                             enable_buffer = True) 
     33                            resp_inc=include, resp_exc=exclude) 
    3534 
Note: See TracChangeset for help on using the changeset viewer.