File: 2-1.c

package info (click to toggle)
posixtestsuite 1.5.2-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,372 kB
  • ctags: 10,551
  • sloc: ansic: 117,313; xml: 7,497; sh: 1,148; makefile: 315; perl: 34
file content (48 lines) | stat: -rw-r--r-- 1,207 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* 
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *
 * Test that the scheduling parameters are returned for the calling process
 * when pid = 0.
 */
#include <stdio.h>
#include <sched.h>
#include <errno.h>
#include <unistd.h>
#include "posixtest.h"

int main(int argc, char **argv)
{	       

	struct sched_param param0;
	struct sched_param param1;
	int result0;
	int result1;

	param0.sched_priority = -1;
	param1.sched_priority = -1;

	result0 = sched_getparam(0, &param0);
	result1 = sched_getparam(getpid(), &param1);
	
	if(result0 == result1 &&
	   param0.sched_priority == param1.sched_priority &&
	   errno == 0) {
		printf("Test PASSED\n");
		return PTS_PASS;
	} else {
		printf("Different results between pid == 0 and pid == getpid().\n");
		return PTS_FAIL;
	}

	printf("This code should not be executed.\n");
        return PTS_UNRESOLVED;
}