• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
4  * Copyright (c) 2012 Wanlong Gao <gaowanlong@cn.fujitsu.com>
5  */
6 
7 /*\
8  * [Description]
9  *
10  * Verify that clone(2) fails with
11  *
12  * - EINVAL if child stack is set to NULL
13  */
14 
15 #include <stdlib.h>
16 #include "tst_test.h"
17 #include "clone_platform.h"
18 
19 static int child_fn(void *arg LTP_ATTRIBUTE_UNUSED);
20 
21 static struct tcase {
22 	int (*child_fn)(void *arg);
23 	void *child_stack;
24 	int exp_errno;
25 	char err_desc[10];
26 } tcases[] = {
27 	{child_fn, NULL, EINVAL, "NULL stack"},
28 };
29 
child_fn(void * arg LTP_ATTRIBUTE_UNUSED)30 static int child_fn(void *arg LTP_ATTRIBUTE_UNUSED)
31 {
32 	exit(0);
33 }
34 
verify_clone(unsigned int nr)35 static void verify_clone(unsigned int nr)
36 {
37 	struct tcase *tc = &tcases[nr];
38 
39 	TST_EXP_FAIL(ltp_clone(0, tc->child_fn, NULL,
40 				CHILD_STACK_SIZE, tc->child_stack),
41 				tc->exp_errno, "%s", tc->err_desc);
42 }
43 
44 static struct tst_test test = {
45 	.tcnt = ARRAY_SIZE(tcases),
46 	.test = verify_clone,
47 };
48