[LTP] [PATCH 2/2] chdir01.c: Minor cleanup

Petr Vorel pvorel@suse.cz
Mon Dec 13 14:23:39 CET 2021


1) print tested item (readability)
2) define TESTUSER (DRY)

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/syscalls/chdir/chdir01.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/chdir/chdir01.c b/testcases/kernel/syscalls/chdir/chdir01.c
index 5819998484..228f6daf44 100644
--- a/testcases/kernel/syscalls/chdir/chdir01.c
+++ b/testcases/kernel/syscalls/chdir/chdir01.c
@@ -25,6 +25,7 @@
 #define BLOCKED_NAME "keep_out"
 #define LINK_NAME1 "symloop"
 #define LINK_NAME2 "symloop2"
+#define TESTUSER  "nobody"
 
 static char *workdir;
 static int skip_symlinks, blocked_perm;
@@ -78,7 +79,7 @@ static void setup(void)
 	SAFE_CLOSE(fd);
 
 	if (!ltpuser)
-		ltpuser = SAFE_GETPWNAM("nobody");
+		ltpuser = SAFE_GETPWNAM(TESTUSER);
 }
 
 static void check_result(const char *user, const char *name, int retval,
@@ -106,6 +107,8 @@ static void run(unsigned int n)
 {
 	struct test_case *tc = testcase_list + n;
 
+	tst_res(TINFO, "Testing '%s'", tc->name);
+
 	if (tc->root_err == ELOOP && skip_symlinks) {
 		tst_res(TCONF, "Skipping symlink loop test, not supported");
 		return;
@@ -135,7 +138,7 @@ static void run(unsigned int n)
 	SAFE_SETEUID(ltpuser->pw_uid);
 	TEST(chdir(tc->name));
 	SAFE_SETEUID(0);
-	check_result("nobody", tc->name, tc->nobody_ret, tc->nobody_err);
+	check_result(TESTUSER, tc->name, tc->nobody_ret, tc->nobody_err);
 }
 
 static void cleanup(void)
-- 
2.34.1



More information about the ltp mailing list