1f6603c60Sopenharmony_ci/*
2f6603c60Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3f6603c60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4f6603c60Sopenharmony_ci * you may not use this file except in compliance with the License.
5f6603c60Sopenharmony_ci * You may obtain a copy of the License at
6f6603c60Sopenharmony_ci *
7f6603c60Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8f6603c60Sopenharmony_ci *
9f6603c60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10f6603c60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11f6603c60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12f6603c60Sopenharmony_ci * See the License for the specific language governing permissions and
13f6603c60Sopenharmony_ci * limitations under the License.
14f6603c60Sopenharmony_ci */
15f6603c60Sopenharmony_ci#include <stdio.h>
16f6603c60Sopenharmony_ci#include <string.h>
17f6603c60Sopenharmony_ci#include <limits.h>
18f6603c60Sopenharmony_ci#include <semaphore.h>
19f6603c60Sopenharmony_ci#include <pthread.h>
20f6603c60Sopenharmony_ci#include <gtest/gtest.h>
21f6603c60Sopenharmony_ci#include "utils.h"
22f6603c60Sopenharmony_ci#include "log.h"
23f6603c60Sopenharmony_ci#include "KernelConstants.h"
24f6603c60Sopenharmony_ci#include "PthreadTest.h"
25f6603c60Sopenharmony_ci
26f6603c60Sopenharmony_ciusing namespace testing::ext;
27f6603c60Sopenharmony_ci
28f6603c60Sopenharmony_ci/**
29f6603c60Sopenharmony_ci * @tc.number   SUB_KERNEL_PTHREAD_ATTR_SETDETACHSTATE_0100
30f6603c60Sopenharmony_ci * @tc.name     basic test about pthread_attr_setdetachstate
31f6603c60Sopenharmony_ci * @tc.desc     [C- SOFTWARE -0200]
32f6603c60Sopenharmony_ci */
33f6603c60Sopenharmony_ciHWTEST_F(PthreadTest, testPthreadAttrSetdetachstate, Function | MediumTest | Level3)
34f6603c60Sopenharmony_ci{
35f6603c60Sopenharmony_ci    pthread_t tid;
36f6603c60Sopenharmony_ci    pthread_attr_t attr;
37f6603c60Sopenharmony_ci    int param;
38f6603c60Sopenharmony_ci
39f6603c60Sopenharmony_ci    // PTHREAD_CREATE_DETACHED
40f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_init(&attr), 0);
41f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED), 0) << "> return errno";
42f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getdetachstate(&attr, &param), 0);
43f6603c60Sopenharmony_ci    EXPECT_EQ(param, PTHREAD_CREATE_DETACHED);
44f6603c60Sopenharmony_ci
45f6603c60Sopenharmony_ci    ASSERT_EQ(pthread_create(&tid, &attr, ThreadPublic, nullptr), 0) << "> return errno";
46f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_destroy(&attr), 0);
47f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_join(tid, nullptr), EINVAL) << "> return errno";
48f6603c60Sopenharmony_ci
49f6603c60Sopenharmony_ci    // PTHREAD_CREATE_JOINABLE
50f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_init(&attr), 0);
51f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE), 0) << "> return errno";
52f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getdetachstate(&attr, &param), 0);
53f6603c60Sopenharmony_ci    EXPECT_EQ(param, PTHREAD_CREATE_JOINABLE);
54f6603c60Sopenharmony_ci
55f6603c60Sopenharmony_ci    ASSERT_EQ(pthread_create(&tid, &attr, ThreadPublic, nullptr), 0) << "> return errno";
56f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_destroy(&attr), 0);
57f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_join(tid, nullptr), 0) << "> return errno";
58f6603c60Sopenharmony_ci}
59f6603c60Sopenharmony_ci
60f6603c60Sopenharmony_civoid *ThreadPthreadAttrSetscope(void *arg)
61f6603c60Sopenharmony_ci{
62f6603c60Sopenharmony_ci    pthread_attr_t attr;
63f6603c60Sopenharmony_ci    int getScope;
64f6603c60Sopenharmony_ci    int setScope = PTHREAD_SCOPE_PROCESS;
65f6603c60Sopenharmony_ci
66f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_getattr_np(pthread_self(), &attr), 0) << "> return errno";
67f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getscope(&attr, &getScope), 0) << "> return errno";
68f6603c60Sopenharmony_ci    LOG("getScope = %d", getScope);
69f6603c60Sopenharmony_ci    EXPECT_EQ(getScope, setScope);
70f6603c60Sopenharmony_ci    return arg;
71f6603c60Sopenharmony_ci}
72f6603c60Sopenharmony_ci
73f6603c60Sopenharmony_ci/**
74f6603c60Sopenharmony_ci * @tc.number   SUB_KERNEL_PTHREAD_ATTR_SCOPE_ALL_0100
75f6603c60Sopenharmony_ci * @tc.name     Comprehensivetest test about competitive scope
76f6603c60Sopenharmony_ci * @tc.desc     [C- SOFTWARE -0200]
77f6603c60Sopenharmony_ci */
78f6603c60Sopenharmony_ciHWTEST_F(PthreadTest, testPthreadAttrSetscope, Function | MediumTest | Level3)
79f6603c60Sopenharmony_ci{
80f6603c60Sopenharmony_ci    pthread_t tid;
81f6603c60Sopenharmony_ci    pthread_attr_t attr;
82f6603c60Sopenharmony_ci    int getScope;
83f6603c60Sopenharmony_ci    const int setScope = PTHREAD_SCOPE_PROCESS;
84f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_init(&attr), 0);
85f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getscope(&attr, &getScope), 0) << "> return errno";
86f6603c60Sopenharmony_ci    LOG("getScope = %d", getScope);
87f6603c60Sopenharmony_ci
88f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_setscope(&attr, setScope), 0) << "> return errno";
89f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getscope(&attr, &getScope), 0) << "> return errno";
90f6603c60Sopenharmony_ci    LOG("getScope = %d", getScope);
91f6603c60Sopenharmony_ci    EXPECT_EQ(getScope, setScope);
92f6603c60Sopenharmony_ci
93f6603c60Sopenharmony_ci    ASSERT_EQ(pthread_create(&tid, &attr, ThreadPthreadAttrSetscope, nullptr), 0) << "> return errno";
94f6603c60Sopenharmony_ci
95f6603c60Sopenharmony_ci    Msleep(20);
96f6603c60Sopenharmony_ci    pthread_join(tid, nullptr);
97f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_destroy(&attr), 0);
98f6603c60Sopenharmony_ci}
99f6603c60Sopenharmony_ci
100f6603c60Sopenharmony_civoid *ThreadPthreadAttrSetguardsize(void *arg)
101f6603c60Sopenharmony_ci{
102f6603c60Sopenharmony_ci    pthread_attr_t attr;
103f6603c60Sopenharmony_ci    size_t getGuardSize;
104f6603c60Sopenharmony_ci    const size_t setGuardSize = DEF_PROCESS_GUARD_SIZE * 2;
105f6603c60Sopenharmony_ci
106f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_getattr_np(pthread_self(), &attr), 0) << "> return errno";
107f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getguardsize(&attr, &getGuardSize), 0) << "> return errno";
108f6603c60Sopenharmony_ci    LOG("getGuardSize = %ld", getGuardSize);
109f6603c60Sopenharmony_ci    EXPECT_EQ(getGuardSize, setGuardSize);
110f6603c60Sopenharmony_ci    return arg;
111f6603c60Sopenharmony_ci}
112f6603c60Sopenharmony_ci
113f6603c60Sopenharmony_ci/**
114f6603c60Sopenharmony_ci * @tc.number   SUB_KERNEL_PTHREAD_ATTR_SETGUARDSIZE_0100
115f6603c60Sopenharmony_ci * @tc.name     basic test about pthread_attr_setguardsize
116f6603c60Sopenharmony_ci * @tc.desc     [C- SOFTWARE -0200]
117f6603c60Sopenharmony_ci */
118f6603c60Sopenharmony_ciHWTEST_F(PthreadTest, testPthreadAttrSetguardsize, Function | MediumTest | Level3)
119f6603c60Sopenharmony_ci{
120f6603c60Sopenharmony_ci    pthread_t tid;
121f6603c60Sopenharmony_ci    pthread_attr_t attr;
122f6603c60Sopenharmony_ci    size_t getGuardSize;
123f6603c60Sopenharmony_ci    const size_t setGuardSize = DEF_PROCESS_GUARD_SIZE * 2;
124f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_init(&attr), 0);
125f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getguardsize(&attr, &getGuardSize), 0) << "> return errno";
126f6603c60Sopenharmony_ci    LOG("getGuardSize = %ld", getGuardSize);
127f6603c60Sopenharmony_ci
128f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_setguardsize(&attr, setGuardSize), 0) << "> return errno";
129f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getguardsize(&attr, &getGuardSize), 0) << "> return errno";
130f6603c60Sopenharmony_ci    LOG("getGuardSize = %ld", getGuardSize);
131f6603c60Sopenharmony_ci    EXPECT_EQ(getGuardSize, setGuardSize);
132f6603c60Sopenharmony_ci
133f6603c60Sopenharmony_ci    ASSERT_EQ(pthread_create(&tid, &attr, ThreadPthreadAttrSetguardsize, nullptr), 0) << "> return errno";
134f6603c60Sopenharmony_ci
135f6603c60Sopenharmony_ci    Msleep(20);
136f6603c60Sopenharmony_ci    pthread_join(tid, nullptr);
137f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_destroy(&attr), 0);
138f6603c60Sopenharmony_ci}
139f6603c60Sopenharmony_ci
140f6603c60Sopenharmony_civoid *ThreadPthreadAttrSetstacksize(void *arg)
141f6603c60Sopenharmony_ci{
142f6603c60Sopenharmony_ci    pthread_attr_t attr;
143f6603c60Sopenharmony_ci    size_t stackSize;
144f6603c60Sopenharmony_ci    size_t guardSize;
145f6603c60Sopenharmony_ci
146f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_getattr_np(pthread_self(), &attr), 0) << "> return errno";
147f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getstacksize(&attr, &stackSize), 0) << "> return errno";
148f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getguardsize(&attr, &guardSize), 0) << "> return errno";
149f6603c60Sopenharmony_ci    LOG("stackSize = %ld", stackSize);
150f6603c60Sopenharmony_ci    LOG("guardSize = %ld", guardSize);
151f6603c60Sopenharmony_ci    // must >= setsize
152f6603c60Sopenharmony_ci    EXPECT_GE(stackSize, PTHREAD_STACK_MIN);
153f6603c60Sopenharmony_ci    return arg;
154f6603c60Sopenharmony_ci}
155f6603c60Sopenharmony_ci
156f6603c60Sopenharmony_ci/**
157f6603c60Sopenharmony_ci * @tc.number   SUB_KERNEL_PTHREAD_ATTR_SETSTACKSIZE_0100
158f6603c60Sopenharmony_ci * @tc.name     basic test about pthread_attr_setstacksize
159f6603c60Sopenharmony_ci * @tc.desc     [C- SOFTWARE -0200]
160f6603c60Sopenharmony_ci */
161f6603c60Sopenharmony_ciHWTEST_F(PthreadTest, testPthreadAttrSetstacksize, Function | MediumTest | Level3)
162f6603c60Sopenharmony_ci{
163f6603c60Sopenharmony_ci    pthread_t tid;
164f6603c60Sopenharmony_ci    pthread_attr_t attr;
165f6603c60Sopenharmony_ci    size_t stackSize;
166f6603c60Sopenharmony_ci
167f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_init(&attr), 0);
168f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getstacksize(&attr, &stackSize), 0) << "> return errno";
169f6603c60Sopenharmony_ci    stackSize = PTHREAD_STACK_MIN;
170f6603c60Sopenharmony_ci    LOG("PTHREAD_STACK_MIN = %d", PTHREAD_STACK_MIN);
171f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_setstacksize(&attr, stackSize), 0) << "> return errno";
172f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getstacksize(&attr, &stackSize), 0) << "> return errno";
173f6603c60Sopenharmony_ci    LOG("stackSize = %d", stackSize);
174f6603c60Sopenharmony_ci    EXPECT_EQ(stackSize, PTHREAD_STACK_MIN);
175f6603c60Sopenharmony_ci
176f6603c60Sopenharmony_ci    ASSERT_EQ(pthread_create(&tid, &attr, ThreadPthreadAttrSetstacksize, nullptr), 0) << "> return errno";
177f6603c60Sopenharmony_ci
178f6603c60Sopenharmony_ci    Msleep(20);
179f6603c60Sopenharmony_ci    pthread_join(tid, nullptr);
180f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_destroy(&attr), 0);
181f6603c60Sopenharmony_ci}
182f6603c60Sopenharmony_ci
183f6603c60Sopenharmony_ci/**
184f6603c60Sopenharmony_ci * @tc.number   SUB_KERNEL_PTHREAD_ATTR_SETSTACKSIZE_0200
185f6603c60Sopenharmony_ci * @tc.name     test pthread_attr_setstacksize EINVAL
186f6603c60Sopenharmony_ci * @tc.desc     [C- SOFTWARE -0200]
187f6603c60Sopenharmony_ci */
188f6603c60Sopenharmony_ciHWTEST_F(PthreadTest, testPthreadAttrSetstacksizeEINVAL, Function | MediumTest | Level3)
189f6603c60Sopenharmony_ci{
190f6603c60Sopenharmony_ci    pthread_attr_t attr;
191f6603c60Sopenharmony_ci    size_t stackSize;
192f6603c60Sopenharmony_ci
193f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_init(&attr), 0);
194f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getstacksize(&attr, &stackSize), 0) << "> return errno";
195f6603c60Sopenharmony_ci    stackSize = PTHREAD_STACK_MIN - 1;
196f6603c60Sopenharmony_ci    LOG("PTHREAD_STACK_MIN = %d", PTHREAD_STACK_MIN);
197f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_setstacksize(&attr, stackSize), EINVAL) << "> return errno";
198f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_destroy(&attr), 0);
199f6603c60Sopenharmony_ci}
200f6603c60Sopenharmony_ci
201f6603c60Sopenharmony_civoid *ThreadPthreadAttrSetstack(void *arg)
202f6603c60Sopenharmony_ci{
203f6603c60Sopenharmony_ci    pthread_attr_t attr;
204f6603c60Sopenharmony_ci    void *stackAddr1 = nullptr;
205f6603c60Sopenharmony_ci    size_t stackSize = 0;
206f6603c60Sopenharmony_ci
207f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_getattr_np(pthread_self(), &attr), 0) << "> return errno";
208f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getstack(&attr, &stackAddr1, &stackSize), 0) << "> return errno";
209f6603c60Sopenharmony_ci    EXPECT_GE(stackSize, PTHREAD_STACK_MIN);
210f6603c60Sopenharmony_ci    return arg;
211f6603c60Sopenharmony_ci}
212f6603c60Sopenharmony_ci
213f6603c60Sopenharmony_ci/**
214f6603c60Sopenharmony_ci * @tc.number   SUB_KERNEL_PTHREAD_ATTR_SETSTACK_0100
215f6603c60Sopenharmony_ci * @tc.name     basic test about pthread_attr_setstack
216f6603c60Sopenharmony_ci * @tc.desc     [C- SOFTWARE -0200]
217f6603c60Sopenharmony_ci */
218f6603c60Sopenharmony_ciHWTEST_F(PthreadTest, testPthreadAttrSetstack, Function | MediumTest | Level3)
219f6603c60Sopenharmony_ci{
220f6603c60Sopenharmony_ci    pthread_t tid;
221f6603c60Sopenharmony_ci    pthread_attr_t attr;
222f6603c60Sopenharmony_ci    void *stackAddr = nullptr;
223f6603c60Sopenharmony_ci    size_t stackSize;
224f6603c60Sopenharmony_ci
225f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_init(&attr), 0);
226f6603c60Sopenharmony_ci
227f6603c60Sopenharmony_ci    stackAddr = malloc(PTHREAD_STACK_MIN);
228f6603c60Sopenharmony_ci    ASSERT_NE(stackAddr, nullptr);
229f6603c60Sopenharmony_ci    LOG("stackAddr = %p", stackAddr);
230f6603c60Sopenharmony_ci
231f6603c60Sopenharmony_ci    stackSize = PTHREAD_STACK_MIN;
232f6603c60Sopenharmony_ci    posix_memalign(&stackAddr, getpagesize(), stackSize);
233f6603c60Sopenharmony_ci    LOG("getpagesize() = %d", getpagesize());
234f6603c60Sopenharmony_ci    LOG("stackAddr = %p", stackAddr);
235f6603c60Sopenharmony_ci
236f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_setstack(&attr, stackAddr, stackSize), 0) << "> return errno";
237f6603c60Sopenharmony_ci    LOG("stackAddr = %p", stackAddr);
238f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getstack(&attr, &stackAddr, &stackSize), 0) << "> return errno";
239f6603c60Sopenharmony_ci    LOG("stackAddr = %p", stackAddr);
240f6603c60Sopenharmony_ci    EXPECT_EQ(stackSize, PTHREAD_STACK_MIN);
241f6603c60Sopenharmony_ci
242f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_create(&tid, &attr, ThreadPthreadAttrSetstack, stackAddr), 0) << "> return errno";
243f6603c60Sopenharmony_ci    Msleep(100);
244f6603c60Sopenharmony_ci    pthread_join(tid, nullptr);
245f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_destroy(&attr), 0);
246f6603c60Sopenharmony_ci}
247f6603c60Sopenharmony_ci
248f6603c60Sopenharmony_ci/**
249f6603c60Sopenharmony_ci * @tc.number   SUB_KERNEL_PTHREAD_ATTR_GETSTACK_0100
250f6603c60Sopenharmony_ci * @tc.name     test pthread_attr_setstack about return EINVAL
251f6603c60Sopenharmony_ci * @tc.desc     [C- SOFTWARE -0200]
252f6603c60Sopenharmony_ci */
253f6603c60Sopenharmony_ciHWTEST_F(PthreadTest, testPthreadAttrGetstackEINVAL, Function | MediumTest | Level3)
254f6603c60Sopenharmony_ci{
255f6603c60Sopenharmony_ci    pthread_attr_t attr;
256f6603c60Sopenharmony_ci    void *stackAddr = nullptr;
257f6603c60Sopenharmony_ci    size_t stackSize;
258f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_init(&attr), 0);
259f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getstack(&attr, &stackAddr, &stackSize), EINVAL) << "> return errno != EINVAL";
260f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_destroy(&attr), 0);
261f6603c60Sopenharmony_ci}
262f6603c60Sopenharmony_ci
263f6603c60Sopenharmony_civoid *ThreadPthreadGetattrNp(void *arg)
264f6603c60Sopenharmony_ci{
265f6603c60Sopenharmony_ci    pthread_attr_t attr;
266f6603c60Sopenharmony_ci    size_t stackSize;
267f6603c60Sopenharmony_ci    size_t guardSize;
268f6603c60Sopenharmony_ci    int param;
269f6603c60Sopenharmony_ci
270f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_getattr_np(pthread_self(), &attr), 0) << "> return errno";
271f6603c60Sopenharmony_ci
272f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getstacksize(&attr, &stackSize), 0) << "> return errno";
273f6603c60Sopenharmony_ci    // must >= DEF_PROCESS_STACK_SIZE
274f6603c60Sopenharmony_ci    EXPECT_GE(stackSize, DEF_PROCESS_STACK_SIZE);
275f6603c60Sopenharmony_ci
276f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getguardsize(&attr, &guardSize), 0) << "> return errno";
277f6603c60Sopenharmony_ci    EXPECT_EQ(guardSize, DEF_PROCESS_GUARD_SIZE);
278f6603c60Sopenharmony_ci
279f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_getdetachstate(&attr, &param), 0);
280f6603c60Sopenharmony_ci    EXPECT_EQ(param, DEF_PROCESS_DETACHSTATE);
281f6603c60Sopenharmony_ci
282f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_attr_destroy(&attr), 0);
283f6603c60Sopenharmony_ci
284f6603c60Sopenharmony_ci    LOG("stackSize = %ld", stackSize);
285f6603c60Sopenharmony_ci    LOG("guardSize; = %ld", guardSize);
286f6603c60Sopenharmony_ci    return arg;
287f6603c60Sopenharmony_ci}
288f6603c60Sopenharmony_ci
289f6603c60Sopenharmony_ci/**
290f6603c60Sopenharmony_ci * @tc.number   SUB_KERNEL_PTHREAD_GETATTR_NP_0100
291f6603c60Sopenharmony_ci * @tc.name     basic about about pthread_getattr_np
292f6603c60Sopenharmony_ci * @tc.desc     [C- SOFTWARE -0200]
293f6603c60Sopenharmony_ci */
294f6603c60Sopenharmony_ciHWTEST_F(PthreadTest, testPthreadGetattrNp, Function | MediumTest | Level3)
295f6603c60Sopenharmony_ci{
296f6603c60Sopenharmony_ci    pthread_t tid;
297f6603c60Sopenharmony_ci    EXPECT_EQ(pthread_create(&tid, nullptr, ThreadPthreadGetattrNp, nullptr), 0) << "> return errno";
298f6603c60Sopenharmony_ci    Msleep(100);
299f6603c60Sopenharmony_ci    pthread_join(tid, nullptr);
300f6603c60Sopenharmony_ci}
301