Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libpthread Also exercise pthread_attr_setstacksize.
details: https://anonhg.NetBSD.org/src/rev/424fdc7c3b76
branches: trunk
changeset: 778020:424fdc7c3b76
user: joerg <joerg%NetBSD.org@localhost>
date: Mon Mar 12 20:17:16 2012 +0000
description:
Also exercise pthread_attr_setstacksize.
diffstat:
tests/lib/libpthread/t_join.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diffs (78 lines):
diff -r 2277bad6f33b -r 424fdc7c3b76 tests/lib/libpthread/t_join.c
--- a/tests/lib/libpthread/t_join.c Mon Mar 12 20:16:52 2012 +0000
+++ b/tests/lib/libpthread/t_join.c Mon Mar 12 20:17:16 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_join.c,v 1.7 2011/12/12 23:54:18 joerg Exp $ */
+/* $NetBSD: t_join.c,v 1.8 2012/03/12 20:17:16 joerg Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_join.c,v 1.7 2011/12/12 23:54:18 joerg Exp $");
+__RCSID("$NetBSD: t_join.c,v 1.8 2012/03/12 20:17:16 joerg Exp $");
#include <errno.h>
#include <pthread.h>
@@ -43,6 +43,8 @@
extern int check_stack_alignment(void);
#endif
+#define STACKSIZE 65536
+
static bool error;
static void *threadfunc1(void *);
@@ -72,6 +74,7 @@
void *val = NULL;
uintptr_t i;
int rv;
+ pthread_attr_t attr;
caller = pthread_self();
@@ -94,11 +97,15 @@
ATF_REQUIRE(rv != 0);
ATF_REQUIRE_EQ(rv, EDEADLK);
+ ATF_REQUIRE(pthread_attr_init(&attr) == 0);
+
for (i = 0; i < __arraycount(thread); i++) {
error = true;
- rv = pthread_create(&thread[i], NULL, threadfunc2, (void *)i);
+ ATF_REQUIRE(pthread_attr_setstacksize(&attr, STACKSIZE * (i + 1)) == 0);
+
+ rv = pthread_create(&thread[i], &attr, threadfunc2, (void *)i);
ATF_REQUIRE_EQ(rv, 0);
@@ -128,6 +135,8 @@
ATF_REQUIRE(rv != 0);
}
+ ATF_REQUIRE(pthread_attr_destroy(&attr) == 0);
+
pthread_exit(NULL);
return NULL;
@@ -138,9 +147,16 @@
{
static uintptr_t i = 0;
uintptr_t j;
+ pthread_attr_t attr;
+ size_t stacksize;
j = (uintptr_t)arg;
+ ATF_REQUIRE(pthread_attr_get_np(pthread_self(), &attr) == 0);
+ ATF_REQUIRE(pthread_attr_getstacksize(&attr, &stacksize) == 0);
+ ATF_REQUIRE(stacksize == STACKSIZE * (j + 1));
+ ATF_REQUIRE(pthread_attr_destroy(&attr) == 0);
+
if (i++ == j)
error = false;
Home |
Main Index |
Thread Index |
Old Index