Changeset 10944 in vbox for trunk/src/VBox/Runtime/testcase
- Timestamp:
- Jul 29, 2008 6:08:58 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 33809
- Location:
- trunk/src/VBox/Runtime/testcase
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/Makefile.kmk
r10940 r10944 87 87 tstTime-4 \ 88 88 tstTimer \ 89 tstTimerLR \ 89 90 tstTimeSpec \ 90 91 tstTSC \ … … 297 298 tstTimer_SOURCES = tstTimer.cpp 298 299 300 tstTimerLR_SOURCES = tstTimerLR.cpp 301 299 302 tstTimeSpec_SOURCES = tstTimeSpec.cpp 300 303 -
trunk/src/VBox/Runtime/testcase/tstTimerLR.cpp
r10941 r10944 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT Testcase - Timers.3 * IPRT Testcase - Low Resolution Timers. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-200 7Sun Microsystems, Inc.7 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 49 49 static volatile uint64_t gu64Prev; 50 50 51 static DECLCALLBACK(void) Timer Callback(PRTTIMER pTimer, void *pvUser, uint64_t iTick)51 static DECLCALLBACK(void) TimerLRCallback(RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick) 52 52 { 53 53 gcTicks++; … … 126 126 } aTests[] = 127 127 { 128 { 32, 2000, 0, 0 }, 129 { 20, 2000, 0, 0 }, 130 { 10, 2000, 0, 0 }, 131 { 8, 2000, 0, 0 }, 132 { 2, 2000, 0, 0 }, 133 { 1, 2000, 0, 0 } 128 { 1000, 2500, 3, 3 }, /* (keep in mind the immediate first tick) */ 129 { 250, 2000, 6, 10 }, 130 { 100, 2000, 17, 23 }, 134 131 }; 135 132 … … 137 134 for (i = 0; i < ELEMENTS(aTests); i++) 138 135 { 139 aTests[i].cLower = (aTests[i].uMilliesWait - aTests[i].uMilliesWait / 10) / aTests[i].uMilliesInterval;140 aTests[i].cUpper = (aTests[i].uMilliesWait + aTests[i].uMilliesWait / 10) / aTests[i].uMilliesInterval;136 //aTests[i].cLower = (aTests[i].uMilliesWait - aTests[i].uMilliesWait / 10) / aTests[i].uMilliesInterval; 137 //aTests[i].cUpper = (aTests[i].uMilliesWait + aTests[i].uMilliesWait / 10) / aTests[i].uMilliesInterval; 141 138 142 139 RTPrintf("\n" … … 148 145 */ 149 146 gcTicks = 0; 150 PRTTIMER pTimer;147 RTTIMERLR hTimerLR; 151 148 gu64Max = 0; 152 149 gu64Min = UINT64_MAX; 153 150 gu64Prev = 0; 154 rc = RTTimer Create(&pTimer, aTests[i].uMilliesInterval, TimerCallback, NULL);151 rc = RTTimerLRCreateEx(&hTimerLR, aTests[i].uMilliesInterval * (uint64_t)1000000, 0, TimerLRCallback, NULL); 155 152 if (RT_FAILURE(rc)) 156 153 { 157 RTPrintf("RTTimer Create(,%d,) -> %d\n", aTests[i].uMilliesInterval, rc);154 RTPrintf("RTTimerLRCreateEX(,%u*1M,,,) -> %d\n", aTests[i].uMilliesInterval, rc); 158 155 cErrors++; 159 156 continue; … … 161 158 162 159 /* 163 * Active waiting for 2 seconds and then destroy it.160 * Start the timer an actively wait for it for the period requested. 164 161 */ 165 162 uint64_t uTSBegin = RTTimeNanoTS(); 163 rc = RTTimerLRStart(hTimerLR, 0); 164 if (RT_FAILURE(rc)) 165 { 166 RTPrintf("tstTimer: FAILURE - RTTimerLRStart() -> %Rrc\n", rc); 167 cErrors++; 168 } 169 166 170 while (RTTimeNanoTS() - uTSBegin < (uint64_t)aTests[i].uMilliesWait * 1000000) 167 171 /* nothing */; 172 173 /* don't stop it, destroy it because there are potential races in destroying an active timer. */ 174 rc = RTTimerLRDestroy(hTimerLR); 175 if (RT_FAILURE(rc)) 176 { 177 RTPrintf("tstTimer: FAILURE - RTTimerLRDestroy() -> %d gcTicks=%d\n", rc, gcTicks); 178 cErrors++; 179 } 180 168 181 uint64_t uTSEnd = RTTimeNanoTS(); 169 182 uint64_t uTSDiff = uTSEnd - uTSBegin; 170 183 RTPrintf("uTS=%RI64 (%RU64 - %RU64)\n", uTSDiff, uTSBegin, uTSEnd); 171 if (RT_FAILURE(rc)) 172 RTPrintf("warning: RTThreadSleep ended prematurely with %d\n", rc); 173 rc = RTTimerDestroy(pTimer); 174 if (RT_FAILURE(rc)) 175 { 176 RTPrintf("tstTimer: FAILURE - RTTimerDestroy() -> %d gcTicks=%d\n", rc, gcTicks); 177 cErrors++; 178 continue; 179 } 184 185 /* Check that it really stopped. */ 180 186 unsigned cTicks = gcTicks; 181 RTThreadSleep( 100);187 RTThreadSleep(aTests[i].uMilliesInterval * 2); 182 188 if (gcTicks != cTicks) 183 189 { 184 RTPrintf("tstTimer: FAILURE - RTTimer Destroy() didn't really stop the timer! gcTicks=%d cTicks=%d\n", gcTicks, cTicks);190 RTPrintf("tstTimer: FAILURE - RTTimerLRDestroy() didn't really stop the timer! gcTicks=%d cTicks=%d\n", gcTicks, cTicks); 185 191 cErrors++; 186 192 continue; … … 204 210 RTPrintf(" min=%RU64 max=%RU64\n", gu64Min, gu64Max); 205 211 } 212 213 /* 214 * Test multiple timers running at once. 215 */ 216 /** @todo multiple LR timer testcase. */ 206 217 207 218 /*
Note:
See TracChangeset
for help on using the changeset viewer.