Changeset 126 for pjproject/trunk/pjlib/src/pjlib-test/timestamp.c
- Timestamp:
- Jan 20, 2006 9:03:36 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pjlib-test/timestamp.c
r65 r126 20 20 #include <pj/os.h> 21 21 #include <pj/log.h> 22 #include <pj/rand.h> 22 23 23 24 … … 49 50 int timestamp_test(void) 50 51 { 51 enum { CONSECUTIVE_LOOP = 100 0};52 enum { CONSECUTIVE_LOOP = 100 }; 52 53 volatile unsigned i; 53 54 pj_timestamp freq, t1, t2; 55 pj_time_val tv1, tv2; 54 56 unsigned elapsed; 55 57 pj_status_t rc; … … 75 77 rc = pj_get_timestamp(&t1); 76 78 if (rc != PJ_SUCCESS) { 77 app_perror("...ERROR: gettimestamp", rc);79 app_perror("...ERROR: pj_get_timestamp", rc); 78 80 return -1001; 79 81 } 82 rc = pj_gettimeofday(&tv1); 83 if (rc != PJ_SUCCESS) { 84 app_perror("...ERROR: pj_gettimeofday", rc); 85 return -1002; 86 } 80 87 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 87 91 rc = pj_get_timestamp(&t2); 88 92 if (rc != PJ_SUCCESS) { 89 app_perror("...ERROR: gettimestamp", rc);90 return -100 2;93 app_perror("...ERROR: pj_get_timestamp", rc); 94 return -1003; 91 95 } 96 rc = pj_gettimeofday(&tv2); 97 if (rc != PJ_SUCCESS) { 98 app_perror("...ERROR: pj_gettimeofday", rc); 99 return -1004; 100 } 101 92 102 /* compare t2 with t1, expecting t2 >= t1. */ 93 103 if (t2.u32.hi < t1.u32.hi || 94 104 (t2.u32.hi == t1.u32.hi && t2.u32.lo < t1.u32.lo)) 95 105 { 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; 98 114 } 99 115 }
Note: See TracChangeset
for help on using the changeset viewer.