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 const int SUCCESS = 0;
20
ThreadFun(void * arg)21 void *ThreadFun(void *arg)
22 {
23
24 return NULL;
25 }
26
27 /**
28 * @tc.name : pthread_attr_init_0100
29 * @tc.desc : Initialize the thread properties, the parameters are valid,
30 * and the parameter assignment can be passed normally
31 * @tc.level : Level 0
32 */
pthread_attr_init_0100(void)33 void pthread_attr_init_0100(void)
34 {
35 pthread_attr_t attr;
36 int back = pthread_attr_init(&attr);
37 EXPECT_EQ("pthread_attr_init_0100", back, SUCCESS);
38 }
39
40 /**
41 * @tc.name : pthread_attr_init_0200
42 * @tc.desc : Initialize the thread attributes, the parameters are valid, the parameter assignment can
43 * be passed normally, and the thread is created to pass the parameter pthread_attr_t
44 * @tc.level : Level 0
45 */
pthread_attr_init_0200(void)46 void pthread_attr_init_0200(void)
47 {
48 pthread_attr_t attr;
49 pthread_t myThread1;
50 int back = pthread_attr_init(&attr);
51 int result = pthread_create(&myThread1, &attr, ThreadFun, NULL);
52 pthread_join(myThread1, NULL);
53 EXPECT_EQ("pthread_attr_init_0200", back, SUCCESS);
54 EXPECT_EQ("pthread_attr_init_0200", result, SUCCESS);
55 }
56
main(int argc,char * argv[])57 int main(int argc, char *argv[])
58 {
59 pthread_attr_init_0100();
60 pthread_attr_init_0200();
61
62 return t_status;
63 }