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 <pthread.h>
17 #include "functionalext.h"
18
19 #define TEST_CONDATTR_VALUE 60
20 #define TEST_CONDATTR_ERROR_VALUE 3
21
22 /**
23 * @tc.name : pthread_condattr_setclock_0100
24 * @tc.desc : Correct parameters, set the clock property of the condition variable
25 * @tc.level : Level 0
26 */
pthread_condattr_setclock_0100(void)27 void pthread_condattr_setclock_0100(void)
28 {
29 pthread_condattr_t attr;
30 pthread_condattr_init(&attr);
31 int ret = pthread_condattr_setclock(&attr, TEST_CONDATTR_VALUE);
32 EXPECT_EQ("pthread_condattr_setclock_0100", ret, CMPFLAG);
33 pthread_condattr_destroy(&attr);
34 }
35
36 /**
37 * @tc.name : pthread_condattr_setclock_0200
38 * @tc.desc : Error parameter, set the clock property of the condition variable
39 * @tc.level : Level 0
40 */
pthread_condattr_setclock_0200(void)41 void pthread_condattr_setclock_0200(void)
42 {
43 pthread_condattr_t attr;
44 pthread_condattr_init(&attr);
45 int ret = pthread_condattr_setclock(&attr, -1);
46 EXPECT_EQ("pthread_condattr_setclock_0200", ret, EINVAL);
47
48 ret = pthread_condattr_setclock(&attr, TEST_CONDATTR_ERROR_VALUE);
49 EXPECT_EQ("pthread_condattr_setclock_0200", ret, EINVAL);
50
51 pthread_condattr_destroy(&attr);
52 }
53
main(void)54 int main(void)
55 {
56 pthread_condattr_setclock_0100();
57 pthread_condattr_setclock_0200();
58 return t_status;
59 }