lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240426213303.12583-1-shengyu.li.evgeny@gmail.com>
Date: Sat, 27 Apr 2024 05:33:03 +0800
From: Shengyu Li <shengyu.li.evgeny@...il.com>
To: shuah@...nel.org
Cc: linux-kernel@...r.kernel.org,
	linux-kselftest@...r.kernel.org,
	Shengyu Li <shengyu.li.evgeny@...il.com>
Subject: [PATCH] selftest/tmpfs: Use harness framework in tmpfs

Notice that there are a lot of Patch commits to enhance 
the consistency of output from our legacy tests, 
we plan to refactor them using kselftest_harness.h automatically by tools. 
This will help standardize the TAP output format, 
ensuring clarity and traceability of test results.
This is the version of tmpfs after auto-refactoring.

Signed-off-by: Shengyu Li <shengyu.li.evgeny@...il.com>
---
 .../selftests/tmpfs/bug-link-o-tmpfile.c      | 54 +++++++++----------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/tools/testing/selftests/tmpfs/bug-link-o-tmpfile.c b/tools/testing/selftests/tmpfs/bug-link-o-tmpfile.c
index b5c3ddb90942..8a9a29bff287 100644
--- a/tools/testing/selftests/tmpfs/bug-link-o-tmpfile.c
+++ b/tools/testing/selftests/tmpfs/bug-link-o-tmpfile.c
@@ -23,45 +23,45 @@
 #include <sys/mount.h>
 #include <unistd.h>
 
-int main(void)
-{
-	int fd;
+#include "../kselftest_harness.h"
 
-	if (unshare(CLONE_NEWNS) == -1) {
+TEST(tmpfs_inodes_and_linking)
+{
+	ASSERT_NE(unshare(CLONE_NEWNS), -1)
+	{
 		if (errno == ENOSYS || errno == EPERM) {
-			fprintf(stderr, "error: unshare, errno %d\n", errno);
-			return 4;
+			SKIP(return, "error: unshare, errno %d\n", errno);
 		}
-		fprintf(stderr, "error: unshare, errno %d\n", errno);
-		return 1;
+		TH_LOG("error: unshare, errno %d\n", errno);
 	}
-	if (mount(NULL, "/", NULL, MS_PRIVATE|MS_REC, NULL) == -1) {
-		fprintf(stderr, "error: mount '/', errno %d\n", errno);
-		return 1;
+
+	ASSERT_NE(mount(NULL, "/", NULL, MS_PRIVATE | MS_REC, NULL), -1)
+	{
+		TH_LOG("error: mount '/', errno %d\n", errno);
 	}
 
 	/* Our heroes: 1 root inode, 1 O_TMPFILE inode, 1 permanent inode. */
-	if (mount(NULL, "/tmp", "tmpfs", 0, "nr_inodes=3") == -1) {
-		fprintf(stderr, "error: mount tmpfs, errno %d\n", errno);
-		return 1;
+	ASSERT_NE(mount(NULL, "/tmp", "tmpfs", 0, "nr_inodes=3"), -1)
+	{
+		TH_LOG("error: mount tmpfs, errno %d\n", errno);
 	}
 
-	fd = openat(AT_FDCWD, "/tmp", O_WRONLY|O_TMPFILE, 0600);
-	if (fd == -1) {
-		fprintf(stderr, "error: open 1, errno %d\n", errno);
-		return 1;
+	int fd = openat(AT_FDCWD, "/tmp", O_WRONLY | O_TMPFILE, 0600);
+
+	ASSERT_NE(fd, -1)
+	{
+		TH_LOG("error: open 1, errno %d\n", errno);
 	}
-	if (linkat(fd, "", AT_FDCWD, "/tmp/1", AT_EMPTY_PATH) == -1) {
-		fprintf(stderr, "error: linkat, errno %d\n", errno);
-		return 1;
+
+	ASSERT_NE(linkat(fd, "", AT_FDCWD, "/tmp/1", AT_EMPTY_PATH), -1)
+	{
+		TH_LOG("error: linkat, errno %d\n", errno);
 	}
 	close(fd);
 
-	fd = openat(AT_FDCWD, "/tmp", O_WRONLY|O_TMPFILE, 0600);
-	if (fd == -1) {
-		fprintf(stderr, "error: open 2, errno %d\n", errno);
-		return 1;
+	ASSERT_NE(openat(AT_FDCWD, "/tmp", O_WRONLY | O_TMPFILE, 0600), -1)
+	{
+		TH_LOG("error: open 2, errno %d\n", errno);
 	}
-
-	return 0;
 }
+TEST_HARNESS_MAIN
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ