os/ossrv/genericopenlibs/posixrealtimeextensions/test/testcapclock/src/tcapclockblocks.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/posixrealtimeextensions/test/testcapclock/src/tcapclockblocks.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,66 @@
     1.4 +
     1.5 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// under the terms of "Eclipse Public License v1.0"
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +// Name        : tcapclockblocks.cpp
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include "tcapclock.h"
    1.23 +
    1.24 +// -----------------------------------------------------------------------------
    1.25 +// CTesttrapsignal::Testcapclocksettime1()
    1.26 +// 
    1.27 +// API tested: clock_settime()
    1.28 +// Description: Capability test for clock_settime()
    1.29 +// -----------------------------------------------------------------------------
    1.30 +
    1.31 +TInt Ctestcapclock::Testcapclocksettime1()
    1.32 +	{
    1.33 +	int ret, ret1 = KErrGeneral;
    1.34 +	clockid_t clockid;
    1.35 +	struct timespec stmspec, gtmspec;
    1.36 +	ret = clock_getcpuclockid(0,&clockid);
    1.37 +	if (ret != 0)
    1.38 +		{
    1.39 +	 	ERR_PRINTF2(_L("Failed to retrieve the clock id of the calling process and errno is %d"),errno);
    1.40 +	 	goto close;	
    1.41 +		}
    1.42 +	stmspec.tv_sec = 2;
    1.43 +	stmspec.tv_nsec = 100000;
    1.44 +	ret = clock_settime(clockid,&stmspec);
    1.45 +	if (ret != 0)
    1.46 +		{
    1.47 +	 	ERR_PRINTF2(_L("Failed to get the time of specified clock id and errno is %d"),errno);
    1.48 +	 	return errno;	
    1.49 +		}	
    1.50 +	INFO_PRINTF1(_L("clock_settime() successfully able to set the time") );
    1.51 +	ret = clock_gettime(clockid,&gtmspec);
    1.52 +	if (ret != 0)
    1.53 +		{
    1.54 +	 	ERR_PRINTF2(_L("Failed to get the time of specified clock id and errno is %d"),errno);
    1.55 +	 	goto close;	
    1.56 +		}
    1.57 +	if (gtmspec.tv_sec < stmspec.tv_sec)
    1.58 +		{
    1.59 +	 	ERR_PRINTF2(_L("Failed to retrieve resolution of the clock id specified and errno is %d"),errno);
    1.60 +	 	goto close;			
    1.61 +		}
    1.62 +	INFO_PRINTF1(_L("clock_gettime() successfully able to get the time") );
    1.63 +	ret1 = KErrNone;
    1.64 +	
    1.65 +	close:
    1.66 +	return ret1;	
    1.67 +	}
    1.68 +
    1.69 +//End of file