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 sched_setparam() function return zero on success. 12 */ 13#include <sched.h> 14#include <stdio.h> 15#include <errno.h> 16#include "posixtest.h" 17 18int main(){ 19 int result; 20 struct sched_param param; 21 22 if(sched_getparam(0, ¶m) == -1) { 23 perror("An error occurs when calling sched_getparam()"); 24 return PTS_UNRESOLVED; 25 } 26 27 result = sched_setparam(0, ¶m); 28 29 if(result == 0) { 30 printf("Test PASSED\n"); 31 return PTS_PASS; 32 } else if(errno == EPERM) { 33 printf("This process does not have the permission to set its own scheduling parameter.\nTry to launch this test as root.\n"); 34 return PTS_UNRESOLVED; 35 } else { 36 printf("returned code is not 0.\n"); 37 return PTS_FAIL; 38 } 39} 40 41