summaryrefslogtreecommitdiff
path: root/lib/libpthread/t_swapcontext.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpthread/t_swapcontext.c')
-rw-r--r--lib/libpthread/t_swapcontext.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libpthread/t_swapcontext.c b/lib/libpthread/t_swapcontext.c
index 8fd231404542..677c51fc8601 100644
--- a/lib/libpthread/t_swapcontext.c
+++ b/lib/libpthread/t_swapcontext.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_swapcontext.c,v 1.2 2014/08/25 16:31:15 bouyer Exp $ */
+/* $NetBSD: t_swapcontext.c,v 1.3 2017/01/16 16:27:06 christos Exp $ */
/*
* Copyright (c) 2012 Emmanuel Dreyfus. All rights reserved.
@@ -28,10 +28,13 @@
#include <sys/cdefs.h>
__RCSID("$NetBSD");
+#include <sys/types.h>
+#include <errno.h>
#include <pthread.h>
-#include <ucontext.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <ucontext.h>
#include <atf-c.h>
@@ -77,7 +80,8 @@ threadfunc(void *arg)
oself = (void *)pthread_self();
printf("before swapcontext self = %p\n", oself);
- PTHREAD_REQUIRE(swapcontext(&octx, &nctx));
+ ATF_REQUIRE_MSG(swapcontext(&octx, &nctx) != -1, "swapcontext failed: %s",
+ strerror(errno));
/* NOTREACHED */
return NULL;
@@ -99,7 +103,8 @@ ATF_TC_BODY(swapcontext1, tc)
printf("Testing if swapcontext() alters pthread_self()\n");
- PTHREAD_REQUIRE(getcontext(&nctx));
+ ATF_REQUIRE_MSG(getcontext(&nctx) != -1, "getcontext failed: %s",
+ strerror(errno));
PTHREAD_REQUIRE(pthread_create(&thread, NULL, threadfunc, NULL));
PTHREAD_REQUIRE(pthread_join(thread, NULL));
}