All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Doucha <mdoucha@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] Add verbose setup to creat08, creat09 and open10
Date: Mon, 30 Aug 2021 15:17:29 +0200	[thread overview]
Message-ID: <20210830131730.31935-1-mdoucha@suse.cz> (raw)

These tests are sensitive to proper UID/GID configuration so print
the detected values for debugging purposes in case of test failure.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 lib/tst_uid.c                             | 5 ++++-
 testcases/kernel/syscalls/creat/creat08.c | 2 ++
 testcases/kernel/syscalls/creat/creat09.c | 2 ++
 testcases/kernel/syscalls/open/open10.c   | 2 ++
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/tst_uid.c b/lib/tst_uid.c
index a73cafa46..2163b1494 100644
--- a/lib/tst_uid.c
+++ b/lib/tst_uid.c
@@ -23,8 +23,11 @@ gid_t tst_get_free_gid_(const char *file, const int lineno, gid_t skip)
 		if (ret == skip || getgrgid(ret))
 			continue;
 
-		if (errno == 0 || errno == ENOENT || errno == ESRCH)
+		if (errno == 0 || errno == ENOENT || errno == ESRCH) {
+			tst_res_(file, lineno, TINFO | TERRNO,
+				"Found unused GID %d", (int)ret);
 			return ret;
+		}
 
 		tst_brk_(file, lineno, TBROK|TERRNO, "Group ID lookup failed");
 		return (gid_t)-1;
diff --git a/testcases/kernel/syscalls/creat/creat08.c b/testcases/kernel/syscalls/creat/creat08.c
index 4392f198a..91581dbf8 100644
--- a/testcases/kernel/syscalls/creat/creat08.c
+++ b/testcases/kernel/syscalls/creat/creat08.c
@@ -41,6 +41,8 @@ static void setup(void)
 	orig_uid = getuid();
 	nobody_uid = ltpuser->pw_uid;
 	nobody_gid = ltpuser->pw_gid;
+	tst_res(TINFO, "User nobody: uid = %d, gid = %d", (int)nobody_uid,
+		(int)nobody_gid);
 	free_gid = tst_get_free_gid(nobody_gid);
 	tmpdir = tst_get_tmpdir();
 }
diff --git a/testcases/kernel/syscalls/creat/creat09.c b/testcases/kernel/syscalls/creat/creat09.c
index 1de16d636..53ab202c1 100644
--- a/testcases/kernel/syscalls/creat/creat09.c
+++ b/testcases/kernel/syscalls/creat/creat09.c
@@ -41,6 +41,8 @@ static void setup(void)
 	struct stat buf;
 	struct passwd *ltpuser = SAFE_GETPWNAM("nobody");
 
+	tst_res(TINFO, "User nobody: uid = %d, gid = %d", (int)ltpuser->pw_uid,
+		(int)ltpuser->pw_gid);
 	free_gid = tst_get_free_gid(ltpuser->pw_gid);
 
 	/* Create directories and set permissions */
diff --git a/testcases/kernel/syscalls/open/open10.c b/testcases/kernel/syscalls/open/open10.c
index e3804c74f..d2d3729d2 100644
--- a/testcases/kernel/syscalls/open/open10.c
+++ b/testcases/kernel/syscalls/open/open10.c
@@ -39,6 +39,8 @@ static void setup(void)
 	orig_uid = getuid();
 	nobody_uid = ltpuser->pw_uid;
 	nobody_gid = ltpuser->pw_gid;
+	tst_res(TINFO, "User nobody: uid = %d, gid = %d", (int)nobody_uid,
+		(int)nobody_gid);
 	free_gid = tst_get_free_gid(nobody_gid);
 	tmpdir = tst_get_tmpdir();
 }
-- 
2.32.0


             reply	other threads:[~2021-08-30 13:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30 13:17 Martin Doucha [this message]
2021-08-30 13:17 ` [LTP] [PATCH 2/2] tst_get_free_gid(): Skip GID 0 Martin Doucha
2021-08-30 13:47   ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210830131730.31935-1-mdoucha@suse.cz \
    --to=mdoucha@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.