Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/fs/ffs make sure that 0 length files get their extattr...



details:   https://anonhg.NetBSD.org/src/rev/36501d6e6c81
branches:  trunk
changeset: 971067:36501d6e6c81
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Apr 12 23:52:20 2020 +0000

description:
make sure that 0 length files get their extattrs cleaned up on deletion
(there was an optimization to not call truncate if size == 0).

diffstat:

 tests/fs/ffs/t_extattr.c |  88 ++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 71 insertions(+), 17 deletions(-)

diffs (139 lines):

diff -r b0ceff4e6b77 -r 36501d6e6c81 tests/fs/ffs/t_extattr.c
--- a/tests/fs/ffs/t_extattr.c  Sun Apr 12 22:06:17 2020 +0000
+++ b/tests/fs/ffs/t_extattr.c  Sun Apr 12 23:52:20 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_extattr.c,v 1.1 2020/04/10 22:58:47 christos Exp $   */
+/*     $NetBSD: t_extattr.c,v 1.2 2020/04/12 23:52:20 christos Exp $   */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_extattr.c,v 1.1 2020/04/10 22:58:47 christos Exp $");
+__RCSID("$NetBSD: t_extattr.c,v 1.2 2020/04/12 23:52:20 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/mount.h>
@@ -51,14 +51,6 @@
 
 #include "h_macros.h"
 
-ATF_TC_WITH_CLEANUP(extattr);
-ATF_TC_HEAD(extattr, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "test extended attribute support in "
-           "ffsv2");
-       atf_tc_set_md_var(tc, "timeout", "5");
-}
-
 #define IMGNAME "extattr.img"
 
 #define G "/garage"
@@ -90,12 +82,9 @@
 const char *newfs = "newfs -O 2 -F -s 10000 " IMGNAME;
 #define FAKEBLK "/dev/formula1"
 
-ATF_TC_BODY(extattr, tc)
-{
+static void
+start(void) {
        struct ufs_args args;
-       ssize_t nr;
-       int fd;
-       char buf[512];
 
        if (system(newfs) == -1)
                atf_tc_fail_errno("newfs failed");
@@ -113,6 +102,33 @@
        /* create extattr */
        if (rump_sys_chdir(G) == 1)
                atf_tc_fail_errno("chdir");
+}
+
+static void
+finish(void) {
+       if (rump_sys_chdir("/") == 1)
+               atf_tc_fail_errno("chdir");
+       if (rump_sys_unmount(G, 0) == -1)
+               atf_tc_fail_errno("unmount failed");
+}
+
+
+ATF_TC_WITH_CLEANUP(extattr_simple);
+ATF_TC_HEAD(extattr_simple, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "test extended attribute creation"
+           " and removal ffsv2");
+       atf_tc_set_md_var(tc, "timeout", "5");
+}
+
+ATF_TC_BODY(extattr_simple, tc)
+{
+       ssize_t nr;
+       int fd;
+       char buf[512];
+
+       start();
+
        if ((fd = rump_sys_open(M, O_RDWR | O_CREAT, 0600)) == -1)
                atf_tc_fail_errno("open");
        if (rump_sys_write(fd, "hi mom\n", 7) != 7)
@@ -161,9 +177,46 @@
                atf_tc_fail_errno("close");
        if (rump_sys_unlink(M) == -1)
                atf_tc_fail_errno("unlink");
+
+       finish();
+}
+
+ATF_TC_CLEANUP(extattr_simple, tc)
+{
+
+       unlink(IMGNAME);
+}
+
+ATF_TC_WITH_CLEANUP(extattr_create_unlink);
+ATF_TC_HEAD(extattr_create_unlink, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "test extended attribute creation"
+           " and unlinking file with ACLs");
+       atf_tc_set_md_var(tc, "timeout", "5");
 }
 
-ATF_TC_CLEANUP(extattr, tc)
+ATF_TC_BODY(extattr_create_unlink, tc)
+{
+       int fd;
+
+       start();
+       if ((fd = rump_sys_open(M, O_RDWR | O_CREAT, 0600)) == -1)
+               atf_tc_fail_errno("open");
+
+       if (rump_sys_close(fd) == -1)
+               atf_tc_fail_errno("close");
+
+       /* create extattr */
+       if (rump_sys_extattr_set_file(M, EXTATTR_NAMESPACE_USER, T, S, 9) == -1)
+               atf_tc_fail_errno("extattr_set_file");
+
+       if (rump_sys_unlink(M) == -1)
+               atf_tc_fail_errno("unlink");
+       finish();
+
+}
+
+ATF_TC_CLEANUP(extattr_create_unlink, tc)
 {
 
        unlink(IMGNAME);
@@ -171,6 +224,7 @@
 
 ATF_TP_ADD_TCS(tp)
 {
-       ATF_TP_ADD_TC(tp, extattr);
+       ATF_TP_ADD_TC(tp, extattr_simple);
+       ATF_TP_ADD_TC(tp, extattr_create_unlink);
        return atf_no_error();
 }



Home | Main Index | Thread Index | Old Index