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