tstTime.cpp revision e86794d5ed13ea3053cb8f12be80630236ef2943
/* $Id$ */
/** @file
* InnoTek Portable Runtime Testcase - Simple RTTime tests.
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#ifdef __WIN__
# include <Windows.h>
#else /* posix */
#endif
{
#ifdef __WIN__
return u64 * 100;
/** @todo fix a different timesource on l4. */
return RTTimeNanoTS();
#else /* posix */
#endif
}
int main()
{
unsigned cErrors = 0;
int i;
RTR3Init();
SUPInit();
RTPrintf("tstTime: TESTING...\n");
/*
* RTNanoTimeTS() shall never return something which
* is less or equal to the return of the previous call.
*/
for (i = 0; i < 100*_1M; i++)
{
{
/** @todo wrapping detection. */
cErrors++;
u64 = RTTimeNanoTS();
}
{
RTPrintf("tstTime: error: i=%#010x u64=%#llx u64Prev=%#llx delta=%lld\n", i, u64, u64Prev, u64 - u64Prev);
cErrors++;
u64 = RTTimeNanoTS();
}
{
u64 = RTTimeNanoTS();
}
}
int64_t i64Diff = u64OSElapsedTS >= u64RTElapsedTS ? u64OSElapsedTS - u64RTElapsedTS : u64RTElapsedTS - u64OSElapsedTS;
{
RTPrintf("tstTime: error: total time differs too much! u64OSElapsedTS=%#llx u64RTElapsedTS=%#llx delta=%lld\n",
cErrors++;
}
else
RTPrintf("tstTime: total time difference: u64OSElapsedTS=%#llx u64RTElapsedTS=%#llx delta=%lld\n",
if (!cErrors)
RTPrintf("tstTime: SUCCESS\n");
else
return !!cErrors;
}