[LTP] [PATCH 1/3] ioprio: Move fallback constants and structs to LAPI header
Petr Vorel
pvorel@suse.cz
Tue Jun 20 14:01:57 CEST 2023
Originally lapi headers were only for common headers, for fallback
constants and structs usable only in test for particular subsystem,
we mix them together with other helper functions in header placed in the
test directory. But later we started to move to lapi also these
fallbacks (e.g. fanotify.h in a05dbc4fa).
+ Remove unused headers in the tests.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
include/lapi/ioprio.h | 47 +++++++++++++++++++
testcases/kernel/syscalls/ioprio/ioprio.h | 42 ++---------------
.../kernel/syscalls/ioprio/ioprio_get01.c | 3 --
.../kernel/syscalls/ioprio/ioprio_set01.c | 3 --
.../kernel/syscalls/ioprio/ioprio_set02.c | 3 --
.../kernel/syscalls/ioprio/ioprio_set03.c | 3 --
6 files changed, 51 insertions(+), 50 deletions(-)
create mode 100644 include/lapi/ioprio.h
diff --git a/include/lapi/ioprio.h b/include/lapi/ioprio.h
new file mode 100644
index 000000000..871aa0278
--- /dev/null
+++ b/include/lapi/ioprio.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2019 Linus Walleij <linus.walleij@linaro.org>
+ */
+
+#ifndef LAPI_IOPRIO_H__
+#define LAPI_IOPRIO_H__
+
+#include "config.h"
+
+#ifdef HAVE_LINUX_IOPRIO_H
+# include <linux/ioprio.h>
+#else
+
+enum {
+ IOPRIO_CLASS_NONE = 0,
+ IOPRIO_CLASS_RT,
+ IOPRIO_CLASS_BE,
+ IOPRIO_CLASS_IDLE,
+};
+
+enum {
+ IOPRIO_WHO_PROCESS = 1,
+ IOPRIO_WHO_PGRP,
+ IOPRIO_WHO_USER,
+};
+
+# define IOPRIO_CLASS_SHIFT (13)
+# define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
+
+# define IOPRIO_PRIO_CLASS(data) ((data) >> IOPRIO_CLASS_SHIFT)
+# define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data)
+
+#endif
+
+/* The RT and BE I/O priority classes have 8 priority levels 0..7 */
+#ifdef IOPRIO_NR_LEVELS
+# define IOPRIO_PRIO_NUM IOPRIO_NR_LEVELS
+#else
+# define IOPRIO_PRIO_NUM 8
+#endif
+
+#ifndef IOPRIO_PRIO_LEVEL
+# define IOPRIO_PRIO_LEVEL(data) ((data) & IOPRIO_PRIO_MASK)
+#endif
+
+#endif /* LAPI_IOPRIO_H__ */
diff --git a/testcases/kernel/syscalls/ioprio/ioprio.h b/testcases/kernel/syscalls/ioprio/ioprio.h
index 4d4828807..dbe27c15f 100644
--- a/testcases/kernel/syscalls/ioprio/ioprio.h
+++ b/testcases/kernel/syscalls/ioprio/ioprio.h
@@ -1,48 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (c) 2019 Linus Walleij <linus.walleij@linaro.org>
+ * Copyright (c) 2023 Linux Test Project
*/
#ifndef LTP_IOPRIO_H
#define LTP_IOPRIO_H
-#include "config.h"
-
-#ifdef HAVE_LINUX_IOPRIO_H
-# include <linux/ioprio.h>
-#else
-
-enum {
- IOPRIO_CLASS_NONE = 0,
- IOPRIO_CLASS_RT,
- IOPRIO_CLASS_BE,
- IOPRIO_CLASS_IDLE,
-};
-
-enum {
- IOPRIO_WHO_PROCESS = 1,
- IOPRIO_WHO_PGRP,
- IOPRIO_WHO_USER,
-};
-
-# define IOPRIO_CLASS_SHIFT (13)
-# define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
-
-# define IOPRIO_PRIO_CLASS(data) ((data) >> IOPRIO_CLASS_SHIFT)
-# define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data)
-
-#endif
-
-/* The RT and BE I/O priority classes have 8 priority levels 0..7 */
-#ifdef IOPRIO_NR_LEVELS
-# define IOPRIO_PRIO_NUM IOPRIO_NR_LEVELS
-#else
-# define IOPRIO_PRIO_NUM 8
-#endif
-
-#ifndef IOPRIO_PRIO_LEVEL
-# define IOPRIO_PRIO_LEVEL(data) ((data) & IOPRIO_PRIO_MASK)
-#endif
+#include "lapi/ioprio.h"
+#include "lapi/syscalls.h"
static const char * const to_class_str[] = {
[IOPRIO_CLASS_NONE] = "NONE",
@@ -106,4 +72,4 @@ static inline void ioprio_check_setting(int class, int prio, int report)
newprio);
}
-#endif
+#endif /* LTP_IOPRIO_H */
diff --git a/testcases/kernel/syscalls/ioprio/ioprio_get01.c b/testcases/kernel/syscalls/ioprio/ioprio_get01.c
index 6e822434e..ceac5a758 100644
--- a/testcases/kernel/syscalls/ioprio/ioprio_get01.c
+++ b/testcases/kernel/syscalls/ioprio/ioprio_get01.c
@@ -6,11 +6,8 @@
* Basic ioprio_get() test. Gets the current process I/O priority and
* checks that the values are sane.
*/
-#include <sys/types.h>
-#include <sys/syscall.h>
#include "tst_test.h"
-#include "lapi/syscalls.h"
#include "ioprio.h"
static void run(void)
diff --git a/testcases/kernel/syscalls/ioprio/ioprio_set01.c b/testcases/kernel/syscalls/ioprio/ioprio_set01.c
index 19953ba36..243337bd2 100644
--- a/testcases/kernel/syscalls/ioprio/ioprio_set01.c
+++ b/testcases/kernel/syscalls/ioprio/ioprio_set01.c
@@ -7,11 +7,8 @@
* bumps it up one notch, then down two notches and checks that the
* new priority is reported back correctly.
*/
-#include <sys/types.h>
-#include <sys/syscall.h>
#include "tst_test.h"
-#include "lapi/syscalls.h"
#include "ioprio.h"
static int orig_class;
diff --git a/testcases/kernel/syscalls/ioprio/ioprio_set02.c b/testcases/kernel/syscalls/ioprio/ioprio_set02.c
index 328a130cb..0faf03767 100644
--- a/testcases/kernel/syscalls/ioprio/ioprio_set02.c
+++ b/testcases/kernel/syscalls/ioprio/ioprio_set02.c
@@ -7,11 +7,8 @@
* Tests to set all 8 priority levels for best effort priority, then
* switches to test all 8 priority levels for idle priority.
*/
-#include <sys/types.h>
-#include <sys/syscall.h>
#include "tst_test.h"
-#include "lapi/syscalls.h"
#include "ioprio.h"
static void run(void)
diff --git a/testcases/kernel/syscalls/ioprio/ioprio_set03.c b/testcases/kernel/syscalls/ioprio/ioprio_set03.c
index d6b44df85..b67887205 100644
--- a/testcases/kernel/syscalls/ioprio/ioprio_set03.c
+++ b/testcases/kernel/syscalls/ioprio/ioprio_set03.c
@@ -6,11 +6,8 @@
* Negative ioprio_set() test. Test some non-working priorities to make
* sure they don't work.
*/
-#include <sys/types.h>
-#include <sys/syscall.h>
#include "tst_test.h"
-#include "lapi/syscalls.h"
#include "ioprio.h"
static void run(void)
--
2.40.1
More information about the ltp
mailing list