public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/access01: Fix the test to run both under nobody and root
@ 2016-05-16  3:19 Xiao Yang
  2016-05-16 12:23 ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: Xiao Yang @ 2016-05-16  3:19 UTC (permalink / raw)
  To: ltp

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/access/access01.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/testcases/kernel/syscalls/access/access01.c b/testcases/kernel/syscalls/access/access01.c
index 7d19d08..a447607 100644
--- a/testcases/kernel/syscalls/access/access01.c
+++ b/testcases/kernel/syscalls/access/access01.c
@@ -27,6 +27,8 @@
  */
 #include <errno.h>
 #include <unistd.h>
+#include <sys/types.h>
+#include <string.h>
 #include "tst_test.h"
 
 #define FNAME_RWX "accessfile_rwx"
@@ -117,8 +119,26 @@ static void verify_access(unsigned int n)
 		verify_success(tc);
 }
 
+static void verify_root(struct tcase *tc)
+{
+	if (!strcmp(tc->fname, FNAME_X))
+		tc->exp_errno = 0;
+
+	if (!strcmp(tc->fname, FNAME_R) || !strcmp(tc->fname, FNAME_W)) {
+		if (strstr(tc->name, "X_OK") == NULL)
+			tc->exp_errno = 0;
+	}
+}
+
 static void setup(void)
 {
+	unsigned int i;
+
+	if (geteuid() == 0) {
+		for (i = 0; i < ARRAY_SIZE(tcases); i++)
+			verify_root(&tcases[i]);
+	}
+
 	SAFE_TOUCH(FNAME_RWX, 0777, NULL);
 	SAFE_TOUCH(FNAME_R, 0444, NULL);
 	SAFE_TOUCH(FNAME_W, 0222, NULL);
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-05-17 13:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-16  3:19 [LTP] [PATCH] syscalls/access01: Fix the test to run both under nobody and root Xiao Yang
2016-05-16 12:23 ` Cyril Hrubis
2016-05-17  1:03   ` Xiao Yang
2016-05-17  6:01   ` [LTP] [PATCH v2] " Xiao Yang
2016-05-17 13:45     ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox