sl@0: sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Name : tcapclockblocks.cpp sl@0: // sl@0: // sl@0: sl@0: #include "tcapclock.h" sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTesttrapsignal::Testcapclocksettime1() sl@0: // sl@0: // API tested: clock_settime() sl@0: // Description: Capability test for clock_settime() sl@0: // ----------------------------------------------------------------------------- sl@0: sl@0: TInt Ctestcapclock::Testcapclocksettime1() sl@0: { sl@0: int ret, ret1 = KErrGeneral; sl@0: clockid_t clockid; sl@0: struct timespec stmspec, gtmspec; sl@0: ret = clock_getcpuclockid(0,&clockid); sl@0: if (ret != 0) sl@0: { sl@0: ERR_PRINTF2(_L("Failed to retrieve the clock id of the calling process and errno is %d"),errno); sl@0: goto close; sl@0: } sl@0: stmspec.tv_sec = 2; sl@0: stmspec.tv_nsec = 100000; sl@0: ret = clock_settime(clockid,&stmspec); sl@0: if (ret != 0) sl@0: { sl@0: ERR_PRINTF2(_L("Failed to get the time of specified clock id and errno is %d"),errno); sl@0: return errno; sl@0: } sl@0: INFO_PRINTF1(_L("clock_settime() successfully able to set the time") ); sl@0: ret = clock_gettime(clockid,>mspec); sl@0: if (ret != 0) sl@0: { sl@0: ERR_PRINTF2(_L("Failed to get the time of specified clock id and errno is %d"),errno); sl@0: goto close; sl@0: } sl@0: if (gtmspec.tv_sec < stmspec.tv_sec) sl@0: { sl@0: ERR_PRINTF2(_L("Failed to retrieve resolution of the clock id specified and errno is %d"),errno); sl@0: goto close; sl@0: } sl@0: INFO_PRINTF1(_L("clock_gettime() successfully able to get the time") ); sl@0: ret1 = KErrNone; sl@0: sl@0: close: sl@0: return ret1; sl@0: } sl@0: sl@0: //End of file