Module Name: src Committed By: thorpej Date: Sat Jun 6 18:11:21 UTC 2020
Modified Files: src/tests/lib/libc/sys: t_lwp_create.c Log Message: Add a test case to ensure that _lwp_create() fails with the expected error code when a bad new-lwp-id pointer is passed. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_lwp_create.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/lib/libc/sys/t_lwp_create.c diff -u src/tests/lib/libc/sys/t_lwp_create.c:1.2 src/tests/lib/libc/sys/t_lwp_create.c:1.3 --- src/tests/lib/libc/sys/t_lwp_create.c:1.2 Tue May 22 09:23:39 2012 +++ src/tests/lib/libc/sys/t_lwp_create.c Sat Jun 6 18:11:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_lwp_create.c,v 1.2 2012/05/22 09:23:39 martin Exp $ */ +/* $NetBSD: t_lwp_create.c,v 1.3 2020/06/06 18:11:21 thorpej Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -119,6 +119,30 @@ ATF_TC_BODY(lwp_create_works, tc) ATF_REQUIRE(lid == the_lwp_id); } +ATF_TC(lwp_create_bad_lid_ptr); +ATF_TC_HEAD(lwp_create_bad_lid_ptr, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify _lwp_create() fails as expected with bad lid pointer"); +} + +ATF_TC_BODY(lwp_create_bad_lid_ptr, tc) +{ + ucontext_t uc; + int error; + int serrno; + void *stack; + static const size_t ssize = 16*1024; + + stack = malloc(ssize); + _lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize); + + error = _lwp_create(&uc, 0, NULL); + serrno = errno; + ATF_REQUIRE(error == -1); + ATF_REQUIRE(serrno == EFAULT); +} + INVALID_UCONTEXT(generic, no_uc_cpu, "not setting cpu registers") uc->uc_flags &= ~_UC_CPU; } @@ -206,6 +230,7 @@ INVALID_UCONTEXT(vax, psl_cm, "setting C ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, lwp_create_works); + ATF_TP_ADD_TC(tp, lwp_create_bad_lid_ptr); ATF_TP_ADD_TC(tp, lwp_create_generic_fail_no_uc_cpu); #ifdef __alpha__ ATF_TP_ADD_TC(tp, lwp_create_alpha_fail_pslset);