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 priority remain unchanged when the sched_ss_repl_period is not
12 * greater than or equal to the sched_ss_init_budget member.
13 *
14 * @pt:SS
15 */
16#include <sched.h>
17#include <stdio.h>
18#include <unistd.h>
19#include "posixtest.h"
20
21#if defined(_POSIX_SPORADIC_SERVER)&&(_POSIX_SPORADIC_SERVER != -1)
22
23int main(){
24	int old_priority;
25	struct sched_param param;
26
27	if(sched_getparam(0, &param) == -1) {
28		perror("An error occurs when calling sched_getparam()");
29		return PTS_UNRESOLVED;
30	}
31	old_priority = param.sched_priority;
32
33	/* set a sched_ss_repl_period lower than the sched_ss_init_budget */
34	param.sched_ss_repl_period.tv_sec = 1;
35	param.sched_ss_repl_period.tv_nsec = 0;
36
37	param.sched_ss_init_budget.tv_sec = 2;
38	param.sched_ss_init_budget.tv_nsec = 0;
39
40	param.sched_priority++;
41	sched_setparam(0,&param);
42
43	if(sched_getparam(0, &param) != 0){
44		perror("An error occurs when calling sched_getparam()");
45		return PTS_UNRESOLVED;
46	}
47
48	if(param.sched_priority == old_priority){
49		printf("Test PASSED\n");
50		return PTS_PASS;
51	} else {
52		printf("The priority have changed.\n");
53		return PTS_FAIL;
54	}
55}
56
57#else
58int main()
59{
60	printf("Does not support SS (SPORADIC SERVER)\n");
61	return PTS_UNSUPPORTED;
62}
63
64#endif
65