1/*
2 *  This program is free software; you can redistribute it and/or modify
3 *  it under the terms of the GNU General Public License version 2.
4 *
5 *  This program is distributed in the hope that it will be useful,
6 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
7 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8 *  GNU General Public License for more details.
9 *
10 *
11 * Test that the values that can be returned by sched_getscheduler() are
12 * defined in the sched.h header
13 */
14#include <stdio.h>
15#include <sched.h>
16#include <errno.h>
17#include "posixtest.h"
18
19struct unique {
20	int value;
21	char *name;
22} sym[] = {
23#ifdef SCHED_FIFO
24	{
25		 SCHED_FIFO, "SCHED_FIFO"
26	},
27#endif
28#ifdef SCHED_RR
29	{
30		 SCHED_RR, "SCHED_RR"
31	},
32#endif
33#ifdef SCHED_SPORADIC
34	{
35	  SCHED_SPORADIC,"SCHED_SPORADIC"
36	},
37#endif
38#ifdef SCHED_OTHER
39	{
40		 SCHED_OTHER, "SCHED_OTHER"
41	},
42#endif
43	{
44		 0, 0
45	}
46};
47
48
49int main(int argc, char **argv)
50{
51	int result = -1;
52	struct unique *tst;
53
54	tst = sym;
55	result = sched_getscheduler(0);
56
57	if(result == -1){
58		printf("Returned code is -1.\n");
59		return PTS_FAIL;
60	}
61	if(errno != 0 ) {
62		perror("Unexpected error");
63		return PTS_FAIL;
64	}
65
66	while (tst->name) {
67		if(result == tst->value) {
68			printf("Test PASSED\n");
69			return PTS_PASS;
70		}
71		tst++;
72	}
73
74	printf("The resulting scheduling policy is not one of standard policy.\nIt could be an implementation defined policy.");
75	return PTS_UNRESOLVED;
76}
77
78
79