tstTime-2.cpp revision c97989161fbe75bc14cea477a5443bbf474dd3ad
/* $Id$ */
/** @file
* innotek Portable Runtime Testcase - Simple RTTime test.
*/
/*
* Copyright (C) 2006-2007 innotek 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-2: TESTING...\n");
/*
* RTNanoTimeTS() shall never return something which
* is less or equal to the return of the previous call.
*/
for (i = 0; i < NUMBER_OF_CALLS; i++)
RTTimeNanoTS();
int64_t i64Diff = u64OSElapsedTS >= u64RTElapsedTS ? u64OSElapsedTS - u64RTElapsedTS : u64RTElapsedTS - u64OSElapsedTS;
{
RTPrintf("tstTime-2: error: total time differs too much! u64OSElapsedTS=%#llx u64RTElapsedTS=%#llx delta=%lld\n",
cErrors++;
}
else
RTPrintf("tstTime-2: total time difference: u64OSElapsedTS=%#llx u64RTElapsedTS=%#llx delta=%lld\n",
#endif
if (!cErrors)
RTPrintf("tstTime-2: SUCCESS\n");
else
return !!cErrors;
}