Home | History | Annotate | Download | only in sched_getscheduler
      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 
     19 struct unique {
     20 	int value;
     21 	char *name;
     22 } sym[] = {
     23 #ifdef SCHED_FIFO
     24 	{
     25 	SCHED_FIFO, "SCHED_FIFO"},
     26 #endif
     27 #ifdef SCHED_RR
     28 	{
     29 	SCHED_RR, "SCHED_RR"},
     30 #endif
     31 #ifdef SCHED_SPORADIC
     32 	{
     33 	SCHED_SPORADIC, "SCHED_SPORADIC"},
     34 #endif
     35 #ifdef SCHED_OTHER
     36 	{
     37 	SCHED_OTHER, "SCHED_OTHER"},
     38 #endif
     39 	{
     40 	0, 0}
     41 };
     42 
     43 int main(void)
     44 {
     45 	int result = -1;
     46 	struct unique *tst;
     47 
     48 	tst = sym;
     49 	result = sched_getscheduler(0);
     50 
     51 	if (result == -1) {
     52 		printf("Returned code is -1.\n");
     53 		return PTS_FAIL;
     54 	}
     55 	if (errno != 0) {
     56 		perror("Unexpected error");
     57 		return PTS_FAIL;
     58 	}
     59 
     60 	while (tst->name) {
     61 		if (result == tst->value) {
     62 			printf("Test PASSED\n");
     63 			return PTS_PASS;
     64 		}
     65 		tst++;
     66 	}
     67 
     68 	printf("The resulting scheduling policy is not one of standard "
     69 	       "policy.\nIt could be an implementation defined policy.");
     70 	return PTS_UNRESOLVED;
     71 }
     72