• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2019 Linus Walleij <linus.walleij@linaro.org>
4  *
5  * Description:
6  * Basic ioprio_get() test. Gets the current process I/O priority and
7  * checks that the values are sane.
8  */
9 #include <sys/types.h>
10 #include <sys/syscall.h>
11 
12 #include "tst_test.h"
13 #include "lapi/syscalls.h"
14 #include "ioprio.h"
15 
run(void)16 static void run(void)
17 {
18 	int prio, class;
19 
20 	/* Get the I/O priority for the current process */
21 	TEST(sys_ioprio_get(IOPRIO_WHO_PROCESS, 0));
22 
23 	if (TST_RET == -1) {
24 		tst_res(TFAIL | TTERRNO, "ioprio_get failed");
25 		return;
26 	}
27 
28 	class = IOPRIO_PRIO_CLASS(TST_RET);
29 	prio = IOPRIO_PRIO_LEVEL(TST_RET);
30 
31 	if (!prio_in_range(prio)) {
32 		tst_res(TFAIL, "ioprio out of range (%d)", prio);
33 		return;
34 	}
35 
36 	if (!class_in_range(class)) {
37 		tst_res(TFAIL, "ioprio class of range (%d)", class);
38 		return;
39 	}
40 
41 	tst_res(TPASS, "ioprio_get returned class %s prio %d",
42 		to_class_str[class], prio);
43 }
44 
45 static struct tst_test test = {
46 	.test_all = run,
47 };
48