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_COND_ATTR_VALUE 2
20 /**
21 * @tc.name : pthread_condattr_setpshared_0100
22 * @tc.desc : Correct parameter setting condition variable property value
23 * @tc.level : Level 0
24 */
pthread_condattr_setpshared_0100(void)25 void pthread_condattr_setpshared_0100(void)
26 {
27 pthread_condattr_t attr;
28 int ret = pthread_condattr_init(&attr);
29 EXPECT_EQ("pthread_condattr_setpshared_0100", ret, 0);
30
31 ret = pthread_condattr_setpshared(&attr, 1);
32 EXPECT_EQ("pthread_condattr_setpshared_0100", ret, 0);
33 pthread_condattr_destroy(&attr);
34 }
35
36 /**
37 * @tc.name : pthread_condattr_setpshared_0200
38 * @tc.desc : Exception parameter sets condition variable property value
39 * @tc.level : Level 2
40 */
pthread_condattr_setpshared_0200(void)41 void pthread_condattr_setpshared_0200(void)
42 {
43 pthread_condattr_t attr;
44 int ret = pthread_condattr_init(&attr);
45 EXPECT_EQ("pthread_condattr_setpshared_0200", ret, 0);
46
47 ret = pthread_condattr_setpshared(&attr, TEST_COND_ATTR_VALUE);
48 EXPECT_EQ("pthread_condattr_setpshared_0200", ret, EINVAL);
49 pthread_condattr_destroy(&attr);
50 }
51
main(void)52 int main(void)
53 {
54 pthread_condattr_setpshared_0100();
55 pthread_condattr_setpshared_0200();
56 return t_status;
57 }