* [PATCH] selftest/tmpfs: Use harness framework in tmpfs
@ 2024-04-26 21:33 Shengyu Li
0 siblings, 0 replies; only message in thread
From: Shengyu Li @ 2024-04-26 21:33 UTC (permalink / raw)
To: shuah; +Cc: linux-kernel, linux-kselftest, Shengyu Li
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@gmail.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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-26 21:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-26 21:33 [PATCH] selftest/tmpfs: Use harness framework in tmpfs Shengyu Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®