linux-test-project / ltp

Linux Test Project (mailing list: https://lists.linux.it/listinfo/ltp)
https://linux-test-project.readthedocs.io/
GNU General Public License v2.0
2.27k stars 1k forks source link

refactor fcntl29 with new API #1131

Closed ilmanzo closed 4 months ago

ilmanzo commented 4 months ago

Keeps same test logic, only use newer API with the goal of more clean and concise code.

pevik commented 4 months ago

@ilmanzo Please add your Signed-off-by: tag (https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin), update (with git push -f) and I'll merge.

@Avinesh Thx for a review. Please after changes add your ack (accept the changes or add your RBT as comment).

pevik commented 4 months ago

@Avinesh @ilmanzo FYI final changes before merge (use valid SPDX, also TPASS/TFAIL should mention FD_CLOEXEC therefore add it to docs). @Avinesh Feel free to further correct my english.


diff --git testcases/kernel/syscalls/fcntl/fcntl29.c testcases/kernel/syscalls/fcntl/fcntl29.c
index 3491df062..24d3983ed 100644
--- testcases/kernel/syscalls/fcntl/fcntl29.c
+++ testcases/kernel/syscalls/fcntl/fcntl29.c
@@ -1,5 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0
-
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2014 Fujitsu Ltd.
  * Author: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
@@ -8,11 +7,11 @@

 /*\
  * [Description]
- * Basic test for fcntl(2) using F_DUPFD_CLOEXEC argument.
+ *
+ * Basic test for fcntl(2) using F_DUPFD_CLOEXEC and getting FD_CLOEXEC.
  */

 #include "lapi/fcntl.h"
-
 #include <tst_test.h>

 static int fd;
@@ -35,9 +34,9 @@ static void run(void)

        TST_EXP_POSITIVE(fcntl(dup_fd, F_GETFD), "fcntl test F_GETFD");
        if (TST_RET & FD_CLOEXEC)
-               tst_res(TPASS, "fcntl() set F_DUPFD_CLOEXEC");
+               tst_res(TPASS, "fcntl() set FD_CLOEXEC");
        else
-               tst_res(TFAIL, "fcntl() did not set F_DUPFD_CLOEXEC");
+               tst_res(TFAIL, "fcntl() did not set FD_CLOEXEC");

        SAFE_CLOSE(dup_fd);
 }
Avinesh commented 4 months ago

@pevik, @ilmanzo , looks good. Feel free to add Reviewed-by: Avinesh Kumar <akumar@suse.de> while merging.