Module Name: src
Committed By: christos
Date: Mon Jan 16 16:27:06 UTC 2017
Modified Files:
src/tests/lib/libpthread: t_swapcontext.c
Log Message:
PR/51890: Ngie Cooper: include and error message fixes.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libpthread/t_swapcontext.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/libpthread/t_swapcontext.c
diff -u src/tests/lib/libpthread/t_swapcontext.c:1.2 src/tests/lib/libpthread/t_swapcontext.c:1.3
--- src/tests/lib/libpthread/t_swapcontext.c:1.2 Mon Aug 25 12:31:15 2014
+++ src/tests/lib/libpthread/t_swapcontext.c Mon Jan 16 11:27:06 2017
@@ -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));
}