1/*
2 * Copyright (c) 2004, Intel Corporation. All rights reserved.
3 * Created by:  crystal.xiong REMOVE-THIS AT intel DOT com
4 * This file is licensed under the GPL license.  For the full content
5 * of this license, see the COPYING file at the top level of this
6 * source tree.
7 *
8 * Test pthread_attr_setschedpolicy()
9 *
10 * Fix coding style:  Peter W. Morreale <pmorreale AT novell DOT com>
11 *
12 * Steps:
13 * 1.  Initialize a pthread_attr_t object using pthread_attr_init()
14 * 2.  Call pthread_attr_setschedpolicy with invalid policy
15 *
16 */
17
18#include <pthread.h>
19#include <stdio.h>
20#include <errno.h>
21#include <string.h>
22#include "posixtest.h"
23
24#define ERR_MSG(f, rc) printf("Failed: func: %s rc: %s (%u)\n", \
25				f, strerror(rc), rc)
26
27#define INVALIDPOLICY 999
28
29int main(void)
30{
31	int rc;
32	pthread_attr_t attr;
33	int status = PTS_PASS;
34
35	rc = pthread_attr_init(&attr);
36	if (rc != 0) {
37		ERR_MSG("pthread_attr_init()", rc);
38		return PTS_UNRESOLVED;
39	}
40
41	rc = pthread_attr_setschedpolicy(&attr, INVALIDPOLICY);
42	if (rc != EINVAL) {
43		ERR_MSG("pthread_attr_setschedpolicy()", rc);
44		status = PTS_FAIL;
45	}
46
47	pthread_attr_destroy(&attr);
48
49	if (status == PTS_PASS)
50		printf("Test PASSED\n");
51	return status;
52}
53