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 <stdio.h>
17 #include <pthread.h>
18 #include "test.h"
19
20 pthread_t pid;
21 int flag = 0;
22
threadfunc(void * arg)23 void *threadfunc(void *arg)
24 {
25 sleep(2);
26 flag++;
27 return 0;
28 }
29
30 /**
31 * @tc.name : pthread_join_0100
32 * @tc.desc : The parameters are valid, verify that the main thread does not wait for other threads to end the
33 * scene
34 * @tc.level : Level 0
35 */
pthread_join_0100(void)36 void pthread_join_0100(void)
37 {
38 flag = 0;
39 pthread_create(&pid, NULL, threadfunc, NULL);
40 int result = pthread_join(pid, NULL);
41 if (result != 0) {
42 t_error("%s pthread_join error get result is %d are not want 0\n", __func__, result);
43 }
44 if (flag != 1) {
45 t_error("%s pthread_join error get flag is %d are not want 1\n", __func__, flag);
46 }
47 }
48
main(int argc,char * argv[])49 int main(int argc, char *argv[])
50 {
51 pthread_join_0100();
52 return t_status;
53 }