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