1 /**
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <time.h>
17 #include "functionalext.h"
18
19 extern int __clock_getres_time64 (clockid_t, struct timespec *);
20
21 /**
22 * @tc.name : clock_getres_0100
23 * @tc.desc : Verify that the resolution in the specified poem can be found (the parameter is CLOCK_REALTIME)
24 * @tc.level : Level 0
25 */
clock_getres_0100(void)26 void clock_getres_0100(void)
27 {
28 struct timespec ts;
29 int result = clock_getres(CLOCK_REALTIME, &ts);
30 EXPECT_EQ("clock_getres_0100", result, 0);
31 }
32
33 /**
34 * @tc.name : clock_getres_0200
35 * @tc.desc : Verify that the resolution in the specified poem can be found (the parameter is CLOCK_TAI)
36 * @tc.level : Level 0
37 */
clock_getres_0200(void)38 void clock_getres_0200(void)
39 {
40 struct timespec ts;
41 int result = clock_getres(CLOCK_TAI, &ts);
42 EXPECT_EQ("clock_getres_0200", result, 0);
43 }
44
45 /**
46 * @tc.name : clock_getres_0300
47 * @tc.desc : Verify that the resolution in the specified poem can be found (the parameter is CLOCK_MONOTONIC)
48 * @tc.level : Level 0
49 */
clock_getres_0300(void)50 void clock_getres_0300(void)
51 {
52 struct timespec ts;
53 int result = clock_getres(CLOCK_MONOTONIC, &ts);
54 EXPECT_EQ("clock_getres_0300", result, 0);
55 }
56
57 /**
58 * @tc.name : clock_getres_0400
59 * @tc.desc : Verify that the resolution in the specified poem can be found (the parameter is CLOCK_BOOTTIME)
60 * @tc.level : Level 0
61 */
clock_getres_0400(void)62 void clock_getres_0400(void)
63 {
64 struct timespec ts;
65 int result = clock_getres(CLOCK_BOOTTIME, &ts);
66 EXPECT_EQ("clock_getres_0400", result, 0);
67 }
68
69 /**
70 * @tc.name : clock_getres_0500
71 * @tc.desc : Verify that the resolution in the specified poem cannot be found (parameter is 100)
72 * @tc.level : Level 2
73 */
clock_getres_0500(void)74 void clock_getres_0500(void)
75 {
76 struct timespec ts;
77 int result = clock_getres(100, &ts);
78 EXPECT_EQ("clock_getres_0500", result, -1);
79 }
80
81 /**
82 * @tc.name : clock_getres_time64_0100
83 * @tc.desc : Verify that the resolution in the specified poem can be found (the parameter is CLOCK_REALTIME)
84 * @tc.level : Level 0
85 */
clock_getres_time64_0100(void)86 void clock_getres_time64_0100(void)
87 {
88 struct timespec ts;
89 int result = __clock_getres_time64(CLOCK_REALTIME, &ts);
90 EXPECT_EQ("clock_getres_time64_0100", result, 0);
91 }
92
main(void)93 int main(void)
94 {
95 clock_getres_0100();
96 clock_getres_0200();
97 clock_getres_0300();
98 clock_getres_0400();
99 clock_getres_0500();
100 clock_getres_time64_0100();
101 return t_status;
102 }