• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
20  * @tc.name      : pthread_attr_setscope_0100
21  * @tc.desc      : Set contention scope attribute in thread attributes object with PTHREAD_SCOPE_SYSTEM
22  * @tc.level     : Level 0
23  */
pthread_attr_setscope_0100(void)24 void pthread_attr_setscope_0100(void)
25 {
26     pthread_attr_t attr;
27     pthread_attr_init(&attr);
28     int ret = pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
29     EXPECT_EQ("pthread_attr_setscope_0100", ret, CMPFLAG);
30     pthread_attr_destroy(&attr);
31 }
32 
33 /**
34  * @tc.name      : pthread_attr_setscope_0200
35  * @tc.desc      : Set contention scope attribute in thread attributes object with PTHREAD_SCOPE_PROCESS
36  * @tc.level     : Level 2
37  */
pthread_attr_setscope_0200(void)38 void pthread_attr_setscope_0200(void)
39 {
40     pthread_attr_t attr;
41     pthread_attr_init(&attr);
42     int ret = pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS);
43     EXPECT_EQ("pthread_attr_setscope_0200", ret, ENOTSUP);
44     pthread_attr_destroy(&attr);
45 }
46 
47 /**
48  * @tc.name      : pthread_attr_setscope_0300
49  * @tc.desc      : Set contention scope attribute in thread attributes object with -1
50  * @tc.level     : Level 2
51  */
pthread_attr_setscope_0300(void)52 void pthread_attr_setscope_0300(void)
53 {
54     pthread_attr_t attr;
55     pthread_attr_init(&attr);
56     int ret = pthread_attr_setscope(&attr, -1);
57     EXPECT_EQ("pthread_attr_setscope_0300", ret, EINVAL);
58     pthread_attr_destroy(&attr);
59 }
60 
main(void)61 int main(void)
62 {
63     pthread_attr_setscope_0100();
64     pthread_attr_setscope_0200();
65     pthread_attr_setscope_0300();
66     return t_status;
67 }