[LTP] [PATCH 2/2] needs_root: Add setting of needs_root

Zhao Gongyi zhaogongyi@huawei.com
Wed Oct 12 11:15:26 CEST 2022


Add setting of  needs_root, otherwise run the test without root
will fail and report EACCESS or EPERM.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
 testcases/kernel/syscalls/bind/bind06.c                       | 1 +
 testcases/kernel/syscalls/cma/process_vm_readv02.c            | 1 +
 testcases/kernel/syscalls/cma/process_vm_readv03.c            | 1 +
 testcases/kernel/syscalls/cma/process_vm_writev02.c           | 1 +
 testcases/kernel/syscalls/copy_file_range/copy_file_range01.c | 1 +
 testcases/kernel/syscalls/ipc/msgget/msgget03.c               | 1 +
 testcases/kernel/syscalls/preadv/preadv03.c                   | 1 +
 testcases/kernel/syscalls/pwritev/pwritev03.c                 | 1 +
 testcases/kernel/syscalls/sendto/sendto03.c                   | 1 +
 testcases/kernel/syscalls/setsockopt/setsockopt05.c           | 1 +
 testcases/kernel/syscalls/setsockopt/setsockopt06.c           | 1 +
 testcases/kernel/syscalls/setsockopt/setsockopt07.c           | 1 +
 testcases/kernel/syscalls/setsockopt/setsockopt08.c           | 1 +
 testcases/kernel/syscalls/setsockopt/setsockopt09.c           | 1 +
 testcases/kernel/syscalls/swapon/swapon01.c                   | 1 +
 15 files changed, 15 insertions(+)

diff --git a/testcases/kernel/syscalls/bind/bind06.c b/testcases/kernel/syscalls/bind/bind06.c
index 618cfce46..3b6e1c99e 100644
--- a/testcases/kernel/syscalls/bind/bind06.c
+++ b/testcases/kernel/syscalls/bind/bind06.c
@@ -100,6 +100,7 @@ static void run(void)

 static struct tst_test test = {
 	.test_all = run,
+	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.max_runtime = 300,
diff --git a/testcases/kernel/syscalls/cma/process_vm_readv02.c b/testcases/kernel/syscalls/cma/process_vm_readv02.c
index 2bd66a49f..97a1595e3 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv02.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv02.c
@@ -116,6 +116,7 @@ static void run(void)

 static struct tst_test test = {
 	.test_all = run,
+	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c b/testcases/kernel/syscalls/cma/process_vm_readv03.c
index 4caafe867..e2fc84e06 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
@@ -189,6 +189,7 @@ static void run(unsigned int i)

 static struct tst_test test = {
 	.test = run,
+	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/cma/process_vm_writev02.c b/testcases/kernel/syscalls/cma/process_vm_writev02.c
index 991110d24..794b9d04f 100644
--- a/testcases/kernel/syscalls/cma/process_vm_writev02.c
+++ b/testcases/kernel/syscalls/cma/process_vm_writev02.c
@@ -116,6 +116,7 @@ static void run(void)

 static struct tst_test test = {
 	.test_all = run,
+	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/copy_file_range/copy_file_range01.c b/testcases/kernel/syscalls/copy_file_range/copy_file_range01.c
index bbcb0ca3b..edcd5c368 100644
--- a/testcases/kernel/syscalls/copy_file_range/copy_file_range01.c
+++ b/testcases/kernel/syscalls/copy_file_range/copy_file_range01.c
@@ -225,6 +225,7 @@ static void cleanup(void)

 static struct tst_test test = {
 	.setup = setup,
+	.needs_root = 1,
 	.cleanup = cleanup,
 	.tcnt = ARRAY_SIZE(tcases),
 	.mount_device = 1,
diff --git a/testcases/kernel/syscalls/ipc/msgget/msgget03.c b/testcases/kernel/syscalls/ipc/msgget/msgget03.c
index 2257ae0f9..d3e4bbc59 100644
--- a/testcases/kernel/syscalls/ipc/msgget/msgget03.c
+++ b/testcases/kernel/syscalls/ipc/msgget/msgget03.c
@@ -72,6 +72,7 @@ static void cleanup(void)

 static struct tst_test test = {
 	.needs_tmpdir = 1,
+	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = verify_msgget,
diff --git a/testcases/kernel/syscalls/preadv/preadv03.c b/testcases/kernel/syscalls/preadv/preadv03.c
index 00b25c549..7b69c77f9 100644
--- a/testcases/kernel/syscalls/preadv/preadv03.c
+++ b/testcases/kernel/syscalls/preadv/preadv03.c
@@ -128,6 +128,7 @@ static void cleanup(void)

 static struct tst_test test = {
 	.tcnt = ARRAY_SIZE(tcases),
+	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.test = verify_direct_preadv,
diff --git a/testcases/kernel/syscalls/pwritev/pwritev03.c b/testcases/kernel/syscalls/pwritev/pwritev03.c
index 91a5e3c54..ded3c9b7a 100644
--- a/testcases/kernel/syscalls/pwritev/pwritev03.c
+++ b/testcases/kernel/syscalls/pwritev/pwritev03.c
@@ -127,6 +127,7 @@ static void cleanup(void)

 static struct tst_test test = {
 	.tcnt = ARRAY_SIZE(tcases),
+	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.test = verify_direct_pwritev,
diff --git a/testcases/kernel/syscalls/sendto/sendto03.c b/testcases/kernel/syscalls/sendto/sendto03.c
index 5d2c1e112..49dded5bb 100644
--- a/testcases/kernel/syscalls/sendto/sendto03.c
+++ b/testcases/kernel/syscalls/sendto/sendto03.c
@@ -208,6 +208,7 @@ static void cleanup(void)

 static struct tst_test test = {
 	.test = run,
+	.needs_root = 1,
 	.tcnt = ARRAY_SIZE(testcase_list),
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt05.c b/testcases/kernel/syscalls/setsockopt/setsockopt05.c
index 651583fb6..cfff4b970 100644
--- a/testcases/kernel/syscalls/setsockopt/setsockopt05.c
+++ b/testcases/kernel/syscalls/setsockopt/setsockopt05.c
@@ -93,6 +93,7 @@ static void run(void)

 static struct tst_test test = {
 	.test_all = run,
+	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.taint_check = TST_TAINT_W | TST_TAINT_D,
diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt06.c b/testcases/kernel/syscalls/setsockopt/setsockopt06.c
index 9c818646b..7daf293b1 100644
--- a/testcases/kernel/syscalls/setsockopt/setsockopt06.c
+++ b/testcases/kernel/syscalls/setsockopt/setsockopt06.c
@@ -120,6 +120,7 @@ static void cleanup(void)

 static struct tst_test test = {
 	.test_all = run,
+	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.max_runtime = 270,
diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt07.c b/testcases/kernel/syscalls/setsockopt/setsockopt07.c
index 616159a90..417fcd077 100644
--- a/testcases/kernel/syscalls/setsockopt/setsockopt07.c
+++ b/testcases/kernel/syscalls/setsockopt/setsockopt07.c
@@ -134,6 +134,7 @@ static void cleanup(void)

 static struct tst_test test = {
 	.test_all = run,
+	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.max_runtime = 150,
diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt08.c b/testcases/kernel/syscalls/setsockopt/setsockopt08.c
index 563444635..ce9409521 100644
--- a/testcases/kernel/syscalls/setsockopt/setsockopt08.c
+++ b/testcases/kernel/syscalls/setsockopt/setsockopt08.c
@@ -144,6 +144,7 @@ void run(void)

 static struct tst_test test = {
 	.setup = setup,
+	.needs_root = 1,
 	.test_all = run,
 	.taint_check = TST_TAINT_W | TST_TAINT_D,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt09.c b/testcases/kernel/syscalls/setsockopt/setsockopt09.c
index 98f7fd00e..08d07dd44 100644
--- a/testcases/kernel/syscalls/setsockopt/setsockopt09.c
+++ b/testcases/kernel/syscalls/setsockopt/setsockopt09.c
@@ -115,6 +115,7 @@ static void cleanup(void)

 static struct tst_test test = {
 	.test_all = run,
+	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.taint_check = TST_TAINT_W | TST_TAINT_D,
diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
index c334ae246..98dc92079 100644
--- a/testcases/kernel/syscalls/swapon/swapon01.c
+++ b/testcases/kernel/syscalls/swapon/swapon01.c
@@ -41,6 +41,7 @@ static void setup(void)

 static struct tst_test test = {
 	.needs_tmpdir = 1,
+	.needs_root = 1,
 	.test_all = verify_swapon,
 	.setup = setup
 };
--
2.17.1



More information about the ltp mailing list