lib/test_sysctl.c covers proc_dointvec(), proc_douintvec(),
proc_dostring(), proc_do_large_bitmap() and proc_dou8vec_minmax(), but
none of the jiffies converters.  Their int paths report the sign
separately from the magnitude, which is a shape the existing entries do
not exercise at all.

Add one entry per affected int converter: proc_dointvec_jiffies(),
proc_dointvec_ms_jiffies() and proc_dointvec_userhz_jiffies().  Each is
seeded with HZ jiffies, which is one second in every converter's own
unit, so the three read back as 1, 1000 and 100 respectively.

Signed-off-by: Zhan Xusheng <[email protected]>
---
 lib/test_sysctl.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c
index 909cfcf76dbf..7718cf4ffd47 100644
--- a/lib/test_sysctl.c
+++ b/lib/test_sysctl.c
@@ -15,6 +15,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/init.h>
+#include <linux/jiffies.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/printk.h>
@@ -48,6 +49,10 @@ struct test_sysctl_data {
 
        int boot_int;
 
+       int int_jiffies;
+       int int_ms_jiffies;
+       int int_userhz_jiffies;
+
        unsigned int uint_0001;
 
        char string_0001[65];
@@ -67,6 +72,11 @@ static struct test_sysctl_data test_data = {
 
        .boot_int = 0,
 
+       /* One second in each converter's unit; all three store HZ jiffies. */
+       .int_jiffies = HZ,
+       .int_ms_jiffies = HZ,
+       .int_userhz_jiffies = HZ,
+
        .uint_0001 = 314,
 
        .string_0001 = "(none)",
@@ -113,6 +123,27 @@ static const struct ctl_table test_table[] = {
                .extra1         = SYSCTL_ZERO,
                .extra2         = SYSCTL_ONE,
        },
+       {
+               .procname       = "int_jiffies",
+               .data           = &test_data.int_jiffies,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec_jiffies,
+       },
+       {
+               .procname       = "int_ms_jiffies",
+               .data           = &test_data.int_ms_jiffies,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec_ms_jiffies,
+       },
+       {
+               .procname       = "int_userhz_jiffies",
+               .data           = &test_data.int_userhz_jiffies,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec_userhz_jiffies,
+       },
        {
                .procname       = "uint_0001",
                .data           = &test_data.uint_0001,
-- 
2.43.0


Reply via email to