Source-Changes-HG archive

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

[src/trunk]: src/tests/fs/vfs Test that read fails with EFAULT even if O_SYNC...



details:   https://anonhg.NetBSD.org/src/rev/b6d14d6409a6
branches:  trunk
changeset: 807105:b6d14d6409a6
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Mar 28 16:17:25 2015 +0000

description:
Test that read fails with EFAULT even if O_SYNC|O_RSYNC are set.

diffstat:

 tests/fs/vfs/t_io.c |  28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diffs (56 lines):

diff -r 010e30f8200b -r b6d14d6409a6 tests/fs/vfs/t_io.c
--- a/tests/fs/vfs/t_io.c       Sat Mar 28 16:13:56 2015 +0000
+++ b/tests/fs/vfs/t_io.c       Sat Mar 28 16:17:25 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_io.c,v 1.12 2013/08/04 11:02:02 pooka Exp $  */
+/*     $NetBSD: t_io.c,v 1.13 2015/03/28 16:17:25 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -222,6 +222,30 @@
        FSTEST_EXIT();
 }
 
+static void
+read_fault(const atf_tc_t *tc, const char *mp)
+{
+       char ch = 123;
+       int fd;
+
+       FSTEST_ENTER();
+       RL(fd = rump_sys_open("file", O_CREAT | O_RDWR, 0777));
+       ATF_REQUIRE_EQ(rump_sys_write(fd, &ch, 1), 1);
+       RL(rump_sys_close(fd));
+       RL(fd = rump_sys_open("file", O_RDONLY | O_SYNC | O_RSYNC));
+       if (FSTYPE_EXT2FS(tc) ||
+           FSTYPE_FFS(tc) ||
+           FSTYPE_FFSLOG(tc) ||
+           FSTYPE_LFS(tc) ||
+           FSTYPE_MSDOS(tc) ||
+           FSTYPE_P2K_FFS(tc) ||
+           FSTYPE_SYSVBFS(tc))
+               atf_tc_expect_fail("bad sync atime update code path");
+       ATF_REQUIRE_ERRNO(EFAULT, rump_sys_read(fd, NULL, 1) == -1);
+       RL(rump_sys_close(fd));
+       FSTEST_EXIT();
+}
+
 ATF_TC_FSAPPLY(holywrite, "create a sparse file and fill hole");
 ATF_TC_FSAPPLY(extendfile, "check that extending a file works");
 ATF_TC_FSAPPLY(extendfile_append, "check that extending a file works "
@@ -232,6 +256,7 @@
 ATF_TC_FSAPPLY(shrinkfile, "shrink file");
 ATF_TC_FSAPPLY(read_after_unlink, "contents can be read off disk after unlink");
 ATF_TC_FSAPPLY(wrrd_after_unlink, "file can be written and read after unlink");
+ATF_TC_FSAPPLY(read_fault, "read at bad address must return EFAULT");
 
 ATF_TP_ADD_TCS(tp)
 {
@@ -245,6 +270,7 @@
        ATF_TP_FSAPPLY(shrinkfile);
        ATF_TP_FSAPPLY(read_after_unlink);
        ATF_TP_FSAPPLY(wrrd_after_unlink);
+       ATF_TP_FSAPPLY(read_fault);
 
        return atf_no_error();
 }



Home | Main Index | Thread Index | Old Index