Skip to contentSkip to conversation

syscalls/fcntl: Replace TINFO with TPASS or TFAIL

PATCH New zhaogongyi 1 participant 1 message May 6, 2021

lore
Share & tools
lore

zhaogongyi

author
#0 lore raw

PATCH 4/4 syscalls/fcntl: Replace TINFO with TPASS or TFAIL

Hi Cyril,

I am very sorry for my fault, I will check the patch format before send out in the future, thanks for your review!

I have resubmit the patch and corrected the error.

Thanks so much!

Best Regards,
Gongyi

Quoted 131 lines

Hi!

Quoted 7 lines

1)remove redundant variable
2)remove redundant log
3)replace TINFO with TPASS or TFAIL

For those:
testcases/kernel/syscalls/fcntl/fcntl16.c
testcases/kernel/syscalls/fcntl/fcntl18.c

First of all it looks like the patch got corrupted, possibly by your email client, there is a missing space somewhere in the middle of the patch which prevents it from being applied.

testcases/kernel/syscalls/fcntl/fcntl16.c int run_test(int file_flag, int file_mode, int start,

Quoted 23 lines
---
 testcases/kernel/syscalls/fcntl/fcntl16.c | 70
+++++++----------------  testcases/kernel/syscalls/fcntl/fcntl18.c |
40 ++-----------
 2 files changed, 27 insertions(+), 83 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl16.c +2 -1
index a77a81298..04d86202c 100644
@@ -441,7 +441,7 @@ void setup(void)
 	sigaction(SIGALRM, &sact, NULL);
 }
 
-int run_test(int file_flag, int file_mode, int start, int end)
+static void run_test(int file_flag, int file_mode, int start, int
+end)
 {
 	int child_count;
 	int child;
@@ -468,7 +468,7 @@ int run_test(int file_flag, int file_mode, int start,

int end)

testcases/kernel/syscalls/fcntl/fcntl16.c int run_test(int file_flag, int file_mode, int start, · line 474

Quoted 8 lines
testcases/kernel/syscalls/fcntl/fcntl16.c +1 -1
 				 errno);
 			close(fd);
 			unlink(tmpname);
-			return 1;
+			goto err;
 		}
 
 		/* Initialize second parent lock structure */ @@ -482,7 +482,7

@@

testcases/kernel/syscalls/fcntl/fcntl16.c int run_test(int file_flag, int file_mode, int start,

Quoted 10 lines

int run_test(int file_flag, int file_mode, int start, int end)

testcases/kernel/syscalls/fcntl/fcntl16.c +1 -1
 					 test + 1, errno);
 				close(fd);
 				unlink(tmpname);
-				return 1;
+				goto err;
 			}
 		}
@@ -502,7 +502,7 @@ int run_test(int file_flag, int file_mode, int start,

int end)

testcases/kernel/syscalls/fcntl/fcntl16.c int run_test(int file_flag, int file_mode, int start,

Quoted 9 lines
testcases/kernel/syscalls/fcntl/fcntl16.c +1 -1
 					if (self_exec(argv0, "ddddd", i, parent,
 						      test, thislock, fd) < 0) {
 						perror("self_exec failed");
-						return 1;
+						goto err;
 					}
 #else
 					dochild(i);
@@ -510,7 +510,7 @@ int run_test(int file_flag, int file_mode, int start,

int end)

testcases/kernel/syscalls/fcntl/fcntl16.c int run_test(int file_flag, int file_mode, int start,

Quoted 9 lines
testcases/kernel/syscalls/fcntl/fcntl16.c +1 -1
 				}
 				if (child < 0) {
 					perror("Fork failed");
-					return 1;
+					goto err;
 				}
 				child_count++;
 				child_pid[i] = child;
@@ -553,7 +553,7 @@ int run_test(int file_flag, int file_mode, int start,

int end)

testcases/kernel/syscalls/fcntl/fcntl16.c int run_test(int file_flag, int file_mode, int start, · line 559

Quoted 8 lines
testcases/kernel/syscalls/fcntl/fcntl16.c +1 -1
 				 test + 1, errno);
 			close(fd);
 			unlink(tmpname);
-			return 1;
+			goto err;
 		}
 
 		/* Initialize fourth parent lock structure */ @@ -567,7 +567,7

@@

testcases/kernel/syscalls/fcntl/fcntl16.c int run_test(int file_flag, int file_mode, int

Quoted 10 lines

int run_test(int file_flag, int file_mode, int start, int end)

testcases/kernel/syscalls/fcntl/fcntl16.c +1 -1
 					 test + 1, errno);
 				close(fd);
 				unlink(tmpname);
-				return 1;
+				goto err;
 			}
 		}
@@ -640,12 +640,16 @@ int run_test(int file_flag, int file_mode, int

start, int end)

Quoted 8 lines
testcases/kernel/syscalls/fcntl/fcntl16.c +1 -4
 		close(fd);
 	}
 	unlink(tmpname);
-	if (fail) {
-		return 1;
-	} else {
-		return 0;
+

testcases/kernel/syscalls/fcntl/fcntl16.c int run_test(int file_flag, int file_mode, int · line 652

Quoted 10 lines
testcases/kernel/syscalls/fcntl/fcntl16.c +8 -1
+	if (!fail) {
+		tst_resm(TPASS, "locking test successed");
+		return;
 	}
-	return 0;
+err:
+	if (file_mode & S_ISGID && !NO_NFS)
+		tst_resm(TCONF, "NFS does not support mandatory locking");
+	else
+		tst_resm(TFAIL, "locking test failed");

This does not help at all, we print TFAIL messages before we do goto err, so this would be still a failed test.

Looking at the code we should rather skip the test in the main instead as it was done in the original code as:

	if (NO_NFS)
		run_test(...);
	else
		tst_resm(TCONF, "Skipping mandatory locking on NFS");

--
Cyril Hrubis
[email protected]