Ignore:
Timestamp:
Jan 7, 2006 6:44:25 PM (18 years ago)
Author:
bennylp
Message:

Added test functions for UAC transaction

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/test-pjsip/test.c

    r107 r109  
    2323#include <pjsip_core.h> 
    2424 
     25#define THIS_FILE   "test.c" 
     26 
    2527#define DO_TEST(test)   do { \ 
    26                             PJ_LOG(3, ("test", "Running %s...", #test));  \ 
     28                            PJ_LOG(3, (THIS_FILE, "Running %s...", #test));  \ 
    2729                            rc = test; \ 
    28                             PJ_LOG(3, ("test",  \ 
     30                            PJ_LOG(3, (THIS_FILE,  \ 
    2931                                       "%s(%d)",  \ 
    3032                                       (rc ? "..ERROR" : "..success"), rc)); \ 
     
    4345 
    4446    pjsip_strerror(rc, errbuf, sizeof(errbuf)); 
    45     PJ_LOG(3,("test", "%s: [pj_status_t=%d] %s", msg, rc, errbuf)); 
     47    PJ_LOG(3,(THIS_FILE, "%s: [pj_status_t=%d] %s", msg, rc, errbuf)); 
    4648 
     49} 
     50 
     51void flush_events(unsigned duration) 
     52{ 
     53    pj_time_val stop_time; 
     54 
     55    pj_gettimeofday(&stop_time); 
     56    stop_time.msec += duration; 
     57    pj_time_val_normalize(&stop_time); 
     58 
     59    /* Process all events for the specified duration. */ 
     60    for (;;) { 
     61        pj_time_val timeout = {0, 1}, now; 
     62 
     63        pjsip_endpt_handle_events(endpt, &timeout); 
     64 
     65        pj_gettimeofday(&now); 
     66        if (PJ_TIME_VAL_GTE(now, stop_time)) 
     67            break; 
     68    } 
    4769} 
    4870 
     
    6082    int line; 
    6183 
    62     pj_log_set_level(3); 
     84    pj_log_set_level(5); 
     85    /* 
    6386    pj_log_set_decor(PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME |  
    6487                     PJ_LOG_HAS_MICRO_SEC); 
     88     */ 
    6589 
    6690    if ((rc=pj_init()) != PJ_SUCCESS) { 
     
    80104    } 
    81105 
    82     PJ_LOG(3,("","")); 
     106    PJ_LOG(3,(THIS_FILE,"")); 
     107 
     108    /* Init logger module. */ 
     109    init_msg_logger(); 
     110    msg_logger_set_enabled(1); 
     111 
     112    /* Start transaction layer module. */ 
     113    rc = pjsip_tsx_layer_init(endpt); 
     114    if (rc != PJ_SUCCESS) { 
     115        app_perror("   Error initializing transaction module", rc); 
     116        goto on_return; 
     117    } 
     118 
     119    /* Create loop transport. */ 
     120    rc = pjsip_loop_start(endpt, NULL); 
     121    if (rc != PJ_SUCCESS) { 
     122        app_perror("   error: unable to create datagram loop transport",  
     123                   rc); 
     124        goto on_return; 
     125    } 
    83126 
    84127    //DO_TEST(uri_test()); 
     
    86129    //DO_TEST(txdata_test()); 
    87130    //DO_TEST(transport_udp_test()); 
    88     DO_TEST(transport_loop_test()); 
    89     //DO_TEST(tsx_uac_test()); 
     131    //DO_TEST(transport_loop_test()); 
     132    //DO_TEST(tsx_basic_test()); 
     133    DO_TEST(tsx_uac_test()); 
    90134 
    91135on_return: 
     
    94138    pj_caching_pool_destroy(&caching_pool); 
    95139 
    96     PJ_LOG(3,("test", "")); 
     140    PJ_LOG(3,(THIS_FILE, "")); 
    97141  
    98142    pj_thread_get_stack_info(pj_thread_this(), &filename, &line); 
    99     PJ_LOG(3,("test", "Stack max usage: %u, deepest: %s:%u",  
     143    PJ_LOG(3,(THIS_FILE, "Stack max usage: %u, deepest: %s:%u",  
    100144                      pj_thread_get_stack_max_usage(pj_thread_this()), 
    101145                      filename, line)); 
    102146    if (rc == 0) 
    103         PJ_LOG(3,("test", "Looks like everything is okay!..")); 
     147        PJ_LOG(3,(THIS_FILE, "Looks like everything is okay!..")); 
    104148    else 
    105         PJ_LOG(3,("test", "Test completed with error(s)")); 
     149        PJ_LOG(3,(THIS_FILE, "Test completed with error(s)")); 
    106150 
    107151    return 0; 
Note: See TracChangeset for help on using the changeset viewer.