Ignore:
Timestamp:
Jan 20, 2006 9:03:36 PM (18 years ago)
Author:
bennylp
Message:

Completed testing for WinCE port

File:
1 edited

Legend:

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

    r65 r126  
    2020#include <pj/os.h> 
    2121#include <pj/log.h> 
     22#include <pj/rand.h> 
    2223 
    2324 
     
    4950int timestamp_test(void) 
    5051{ 
    51     enum { CONSECUTIVE_LOOP = 1000 }; 
     52    enum { CONSECUTIVE_LOOP = 100 }; 
    5253    volatile unsigned i; 
    5354    pj_timestamp freq, t1, t2; 
     55    pj_time_val tv1, tv2; 
    5456    unsigned elapsed; 
    5557    pj_status_t rc; 
     
    7577    rc = pj_get_timestamp(&t1); 
    7678    if (rc != PJ_SUCCESS) { 
    77         app_perror("...ERROR: get timestamp", rc); 
     79        app_perror("...ERROR: pj_get_timestamp", rc); 
    7880        return -1001; 
    7981    } 
     82    rc = pj_gettimeofday(&tv1); 
     83    if (rc != PJ_SUCCESS) { 
     84        app_perror("...ERROR: pj_gettimeofday", rc); 
     85        return -1002; 
     86    } 
    8087    for (i=0; i<CONSECUTIVE_LOOP; ++i) { 
    81         /* 
    82         volatile unsigned j; 
    83         for (j=0; j<1000; ++j) 
    84             ; 
    85          */ 
    86         pj_thread_sleep(1); 
     88         
     89        pj_thread_sleep(pj_rand() % 100); 
     90 
    8791        rc = pj_get_timestamp(&t2); 
    8892        if (rc != PJ_SUCCESS) { 
    89             app_perror("...ERROR: get timestamp", rc); 
    90             return -1002; 
     93            app_perror("...ERROR: pj_get_timestamp", rc); 
     94            return -1003; 
    9195        } 
     96        rc = pj_gettimeofday(&tv2); 
     97        if (rc != PJ_SUCCESS) { 
     98            app_perror("...ERROR: pj_gettimeofday", rc); 
     99            return -1004; 
     100        } 
     101 
    92102        /* compare t2 with t1, expecting t2 >= t1. */ 
    93103        if (t2.u32.hi < t1.u32.hi || 
    94104            (t2.u32.hi == t1.u32.hi && t2.u32.lo < t1.u32.lo)) 
    95105        { 
    96             PJ_LOG(3,(THIS_FILE, "...ERROR: timestamp runs backwards!")); 
    97             return -1003; 
     106            PJ_LOG(3,(THIS_FILE, "...ERROR: timestamp run backwards!")); 
     107            return -1005; 
     108        } 
     109 
     110        /* compare tv2 with tv1, expecting tv2 >= tv1. */ 
     111        if (PJ_TIME_VAL_LT(tv2, tv1)) { 
     112            PJ_LOG(3,(THIS_FILE, "...ERROR: time run backwards!")); 
     113            return -1006; 
    98114        } 
    99115    } 
Note: See TracChangeset for help on using the changeset viewer.