Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/sys Add a test case to ensure that _lwp_creat...
details: https://anonhg.NetBSD.org/src/rev/716982919555
branches: trunk
changeset: 1010784:716982919555
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Jun 06 18:11:21 2020 +0000
description:
Add a test case to ensure that _lwp_create() fails with the
expected error code when a bad new-lwp-id pointer is passed.
diffstat:
tests/lib/libc/sys/t_lwp_create.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diffs (48 lines):
diff -r 27787457f273 -r 716982919555 tests/lib/libc/sys/t_lwp_create.c
--- a/tests/lib/libc/sys/t_lwp_create.c Sat Jun 06 17:39:35 2020 +0000
+++ b/tests/lib/libc/sys/t_lwp_create.c Sat Jun 06 18:11:21 2020 +0000
@@ -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_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 @@
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);
Home |
Main Index |
Thread Index |
Old Index