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 policy and scheduling parameters remain unchanged when the 12 * sched_ss_repl_period is not greater than or equal to the 13 * sched_ss_init_budget member. 14 * 15 * Steps: 16 * 1. Get the old policy and priority. 17 * 2. Call sched_setscheduler with invalid args. 18 * 3. Check that the policy and priority have not changed. 19 * 20 * @pt:SS 21 */ 22#include <sched.h> 23#include <stdio.h> 24#include <errno.h> 25#include <unistd.h> 26#include "posixtest.h" 27 28#if defined(_POSIX_SPORADIC_SERVER)&&(_POSIX_SPORADIC_SERVER != -1) 29 30int main(){ 31 int policy, result; 32 int old_priority, old_policy, new_policy; 33 struct sched_param param; 34 35 if(sched_getparam(getpid(), ¶m) != 0) { 36 perror("An error occurs when calling sched_getparam()"); 37 return PTS_UNRESOLVED; 38 } 39 old_priority = param.sched_priority; 40 41 old_policy = sched_getscheduler(getpid()); 42 if(old_policy == -1) { 43 perror("An error occurs when calling sched_getscheduler()"); 44 return PTS_UNRESOLVED; 45 } 46 47 /* set a sched_ss_repl_period lower than the sched_ss_init_budget */ 48 param.sched_ss_repl_period.tv_sec = 1; 49 param.sched_ss_repl_period.tv_nsec = 0; 50 51 param.sched_ss_init_budget.tv_sec = 2; 52 param.sched_ss_init_budget.tv_nsec = 0; 53 54 param.sched_priority = sched_get_priority_max(SCHED_SPORADIC); 55 56 result = sched_setscheduler(0, SCHED_SPORADIC, ¶m); 57 58 if(sched_getparam(getpid(), ¶m) != 0) { 59 perror("An error occurs when calling sched_getparam()"); 60 return PTS_UNRESOLVED; 61 } 62 63 new_policy = sched_getscheduler(getpid()); 64 if(new_policy == -1) { 65 perror("An error occurs when calling sched_getscheduler()"); 66 return PTS_UNRESOLVED; 67 } 68 69 70 if(old_policy == new_policy && 71 old_priority == param.sched_priority) { 72 printf("Test PASSED\n"); 73 return PTS_PASS; 74 } 75 76 if(param.sched_priority != old_priority) { 77 printf("The param has changed\n"); 78 } 79 if(new_policy != old_policy) { 80 printf("The policy has changed\n"); 81 } 82 return PTS_FAIL; 83 84 85} 86#else 87int main() 88{ 89 printf("Does not support SS (SPORADIC SERVER)\n"); 90 return PTS_UNSUPPORTED; 91} 92#endif 93