/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* Copyright 2016 Joyent, Inc.
*/
/*
* Test and verify that pthrad_attr_get_np works as we expect.
*
* Verify the following:
* o ESRCH
* o stack size is set to a valid value after a thread is created.
* o main thread can grab an alternate thread's info.
* o custom guard size is honored
* o detach state
* - detached 1
* - joinable 2
* - changing 2
* o daemon state
* - enabled 1
* - disabled 2
* o scope
* - system 1
* - process 2
* o inheritable
* - inherit 1
* - explicit 2
* o priority
* - honors change 2
* o policy
* - honours change 2
*
*
* For each of the cases above we explicitly go through and create the set of
* attributes as marked above and then inside of a thread, verify that the
* attributes match what we expect. Because each case ends up in creating a
* detached thread, we opt to have both it and the main thread enter a barrier
* to indicate that we have completed the test successfully.
*/
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <ucontext.h>
#include <sched.h>
#include <strings.h>
#include <stdlib.h>
/*
* Currently these are only defined in thr_uberdata.h. Rather than trying and
* fight with libc headers, just explicitly define them here.
*/
#define PTHREAD_CREATE_NONDAEMON_NP 0
extern int pthread_attr_setdaemonstate_np(pthread_attr_t *, int);
extern int pthread_attr_getdaemonstate_np(const pthread_attr_t *, int *);
/*
* Verify that the stack pointer of a context is consistent with where the
* attributes indicate.
*/
static void
{
void *stk;
}
static void
pgn_test_fini(void)
{
int ret;
}
static void
pgn_test_init(void)
{
}
/* ARGSUSED */
static void *
{
return (NULL);
}
static void
pgn_set_one(void)
{
int ret;
/*
* Verify it's not joinable.
*/
/*
* At this point we let the test continue and wait on the barrier. We'll
* wake up when the other thread is done.
*/
}
/* ARGSUSED */
static void *
{
/*
* Now that we've validated the basics, go ahead and test the changes,
* which include making sure that we see updates via
* pthread_setschedparam() and pthread_detach().
*/
return (NULL);
}
static void
pgn_set_two(void)
{
/*
* At this point we let the test continue and wait on the barrier. We'll
* wake up when the other thread is done.
*/
}
/* ARGSUSED */
static void *
{
return (NULL);
}
void
pgn_set_three(void)
{
}
int
main(void)
{
int ret;
pgn_set_one();
pgn_set_two();
exit(0);
}