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 sched_setparam() sets errno == EINVAL when the 12 * sched_ss_repl_period is not greater than or equal to the 13 * sched_ss_init_budget member. 14 * 15 * @pt:SS 16 */ 17#include <sched.h> 18#include <stdio.h> 19#include <errno.h> 20#include <unistd.h> 21#include "posixtest.h" 22 23 24#if defined(_POSIX_SPORADIC_SERVER)&&(_POSIX_SPORADIC_SERVER != -1) 25 26int main(){ 27 int policy, result; 28 struct sched_param param; 29 30 if(sched_getparam(0, ¶m) != 0) { 31 perror("An error occurs when calling sched_getparam()"); 32 return PTS_UNRESOLVED; 33 } 34 35 /* set a sched_ss_repl_period lower than the sched_ss_init_budget */ 36 param.sched_ss_repl_period.tv_sec = 1; 37 param.sched_ss_repl_period.tv_nsec = 0; 38 39 param.sched_ss_init_budget.tv_sec = 2; 40 param.sched_ss_init_budget.tv_nsec = 0; 41 42 result = sched_setparam(0,¶m); 43 44 if(result == -1 && errno == EINVAL){ 45 printf("Test PASSED\n"); 46 return PTS_PASS; 47 } else if(result != -1) { 48 printf("The returned code is not -1.\n"); 49 return PTS_FAIL; 50 } else if(errno == EPERM) { 51 printf("This process does not have the permission to set its own scheduling parameter.\nTry to launch this test as root\n"); 52 return PTS_UNRESOLVED; 53 } else { 54 perror("Unknow error"); 55 return PTS_FAIL; 56 } 57} 58 59#endif 60