Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libpthread PR/51890: Ngie Cooper: include and erro...



details:   https://anonhg.NetBSD.org/src/rev/baeb2621ddd3
branches:  trunk
changeset: 350693:baeb2621ddd3
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jan 16 16:27:06 2017 +0000

description:
PR/51890: Ngie Cooper: include and error message fixes.

diffstat:

 tests/lib/libpthread/t_swapcontext.c |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r 2997fda77ac9 -r baeb2621ddd3 tests/lib/libpthread/t_swapcontext.c
--- a/tests/lib/libpthread/t_swapcontext.c      Mon Jan 16 16:23:41 2017 +0000
+++ b/tests/lib/libpthread/t_swapcontext.c      Mon Jan 16 16:27:06 2017 +0000
@@ -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 @@
        
        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 @@
 
        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));
 }



Home | Main Index | Thread Index | Old Index