sl@0
|
1 |
|
sl@0
|
2 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
// All rights reserved.
|
sl@0
|
4 |
// This component and the accompanying materials are made available
|
sl@0
|
5 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
// which accompanies this distribution, and is available
|
sl@0
|
7 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
//
|
sl@0
|
9 |
// Initial Contributors:
|
sl@0
|
10 |
// Nokia Corporation - initial contribution.
|
sl@0
|
11 |
//
|
sl@0
|
12 |
// Contributors:
|
sl@0
|
13 |
//
|
sl@0
|
14 |
// Description:
|
sl@0
|
15 |
// Name : tcapclockblocks.cpp
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "tcapclock.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
// -----------------------------------------------------------------------------
|
sl@0
|
22 |
// CTesttrapsignal::Testcapclocksettime1()
|
sl@0
|
23 |
//
|
sl@0
|
24 |
// API tested: clock_settime()
|
sl@0
|
25 |
// Description: Capability test for clock_settime()
|
sl@0
|
26 |
// -----------------------------------------------------------------------------
|
sl@0
|
27 |
|
sl@0
|
28 |
TInt Ctestcapclock::Testcapclocksettime1()
|
sl@0
|
29 |
{
|
sl@0
|
30 |
int ret, ret1 = KErrGeneral;
|
sl@0
|
31 |
clockid_t clockid;
|
sl@0
|
32 |
struct timespec stmspec, gtmspec;
|
sl@0
|
33 |
ret = clock_getcpuclockid(0,&clockid);
|
sl@0
|
34 |
if (ret != 0)
|
sl@0
|
35 |
{
|
sl@0
|
36 |
ERR_PRINTF2(_L("Failed to retrieve the clock id of the calling process and errno is %d"),errno);
|
sl@0
|
37 |
goto close;
|
sl@0
|
38 |
}
|
sl@0
|
39 |
stmspec.tv_sec = 2;
|
sl@0
|
40 |
stmspec.tv_nsec = 100000;
|
sl@0
|
41 |
ret = clock_settime(clockid,&stmspec);
|
sl@0
|
42 |
if (ret != 0)
|
sl@0
|
43 |
{
|
sl@0
|
44 |
ERR_PRINTF2(_L("Failed to get the time of specified clock id and errno is %d"),errno);
|
sl@0
|
45 |
return errno;
|
sl@0
|
46 |
}
|
sl@0
|
47 |
INFO_PRINTF1(_L("clock_settime() successfully able to set the time") );
|
sl@0
|
48 |
ret = clock_gettime(clockid,>mspec);
|
sl@0
|
49 |
if (ret != 0)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
ERR_PRINTF2(_L("Failed to get the time of specified clock id and errno is %d"),errno);
|
sl@0
|
52 |
goto close;
|
sl@0
|
53 |
}
|
sl@0
|
54 |
if (gtmspec.tv_sec < stmspec.tv_sec)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
ERR_PRINTF2(_L("Failed to retrieve resolution of the clock id specified and errno is %d"),errno);
|
sl@0
|
57 |
goto close;
|
sl@0
|
58 |
}
|
sl@0
|
59 |
INFO_PRINTF1(_L("clock_gettime() successfully able to get the time") );
|
sl@0
|
60 |
ret1 = KErrNone;
|
sl@0
|
61 |
|
sl@0
|
62 |
close:
|
sl@0
|
63 |
return ret1;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
//End of file
|