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 <malloc.h>
17 #include <sched.h>
18 #include <signal.h>
19 #include <unistd.h>
20 #include "functionalext.h"
21
22 const int STACK_SIZE = 1024 * 8192;
23 const int SUCCESS = 0;
test(void * p)24 void *test(void *p)
25 {
26 return NULL;
27 }
28
29 /**
30 * @tc.name : clone_0100
31 * @tc.desc : Each parameter is valid, and a new thread can be created through the clone function.
32 * @tc.level : Level 0
33 */
clone_0100(void)34 void clone_0100(void)
35 {
36 void *stack = malloc(STACK_SIZE);
37 int cpid = -1;
38 cpid = clone((int (*)(void *))test, (char *)stack + STACK_SIZE, CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, NULL);
39 sleep(1);
40 EXPECT_NE("clone_0100", cpid, -1);
41 }
42
main(int argc,char * argv[])43 int main(int argc, char *argv[])
44 {
45 clone_0100();
46 return t_status;
47 }