Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 Sep 2019 14:06:14 -0000
From:      Enji Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r345904 - in projects/fuse2-googletest-engine: contrib/googletest/googletest/test sys/fs/fuse tests/sys/fs/fusefs
Message-ID:  <201904050337.x353bHmX058112@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Fri Apr  5 03:37:16 2019
New Revision: 345904
URL: https://svnweb.freebsd.org/changeset/base/345904

Log:
  MFprojects/fuse2@r345903

Added:
  projects/fuse2-googletest-engine/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc
     - copied unchanged from r345903, projects/fuse2/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc
Modified:
  projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.c
  projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.h
  projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c
  projects/fuse2-googletest-engine/sys/fs/fuse/fuse_node.c
  projects/fuse2-googletest-engine/sys/fs/fuse/fuse_vnops.c
  projects/fuse2-googletest-engine/tests/sys/fs/fusefs/read.cc
Directory Properties:
  projects/fuse2-googletest-engine/   (props changed)

Copied: projects/fuse2-googletest-engine/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc (from r345903, projects/fuse2/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/fuse2-googletest-engine/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc	Fri Apr  5 03:37:16 2019	(r345904, copy of r345903, projects/fuse2/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc)
@@ -0,0 +1,60 @@
+// Copyright 2019, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// This test verifies that skipping in the environment results in the
+// testcases being skipped.
+//
+// This is a reproduction case for
+// https://github.com/google/googletest/issues/2189 .
+
+#include <iostream>
+#include <gtest/gtest.h>
+
+class SetupEnvironment : public testing::Environment {
+public:
+  void SetUp() override {
+    GTEST_SKIP() << "Skipping the entire environment";
+  }
+};
+
+TEST(Test, AlwaysPasses) {
+  EXPECT_EQ(true, true);
+}
+
+TEST(Test, AlwaysFails) {
+  EXPECT_EQ(true, false);
+}
+
+int main(int argc, char **argv) {
+  testing::InitGoogleTest(&argc, argv);
+
+  testing::AddGlobalTestEnvironment(new SetupEnvironment());
+
+  return (RUN_ALL_TESTS());
+}

Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.c
==============================================================================
--- projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.c	Fri Apr  5 03:35:40 2019	(r345903)
+++ projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.c	Fri Apr  5 03:37:16 2019	(r345904)
@@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$");
 #include "fuse.h"
 #include "fuse_file.h"
 #include "fuse_internal.h"
+#include "fuse_io.h"
 #include "fuse_ipc.h"
 #include "fuse_node.h"
 
@@ -188,9 +189,7 @@ fuse_filehandle_open(struct vnode *vp, int a_mode,
 	}
 	foo = fdi.answ;
 
-	fuse_filehandle_init(vp, fufh_type, fufhp, td->td_proc->p_pid, cred,
-		foo);
-
+	fuse_filehandle_init(vp, fufh_type, fufhp, td, cred, foo);
 	fuse_vnode_open(vp, foo->open_flags, td);
 
 out:
@@ -322,7 +321,7 @@ fuse_filehandle_getrw(struct vnode *vp, int fflag,
 
 void
 fuse_filehandle_init(struct vnode *vp, fufh_type_t fufh_type,
-    struct fuse_filehandle **fufhp, pid_t pid, struct ucred *cred,
+    struct fuse_filehandle **fufhp, struct thread *td, struct ucred *cred,
     struct fuse_open_out *foo)
 {
 	struct fuse_vnode_data *fvdat = VTOFUD(vp);
@@ -335,7 +334,7 @@ fuse_filehandle_init(struct vnode *vp, fufh_type_t fuf
 	fufh->fufh_type = fufh_type;
 	fufh->gid = cred->cr_rgid;
 	fufh->uid = cred->cr_uid;
-	fufh->pid = pid;
+	fufh->pid = td->td_proc->p_pid;
 	fufh->fuse_open_flags = foo->open_flags;
 	if (!FUFH_IS_VALID(fufh)) {
 		panic("FUSE: init: invalid filehandle id (type=%d)", fufh_type);
@@ -345,4 +344,15 @@ fuse_filehandle_init(struct vnode *vp, fufh_type_t fuf
 		*fufhp = fufh;
 
 	atomic_add_acq_int(&fuse_fh_count, 1);
+
+	if (foo->open_flags & FOPEN_DIRECT_IO) {
+		ASSERT_VOP_ELOCKED(vp, __func__);
+		VTOFUD(vp)->flag |= FN_DIRECTIO;
+		fuse_io_invalbuf(vp, td);
+	} else {
+		if ((foo->open_flags & FOPEN_KEEP_CACHE) == 0)
+			fuse_io_invalbuf(vp, td);
+	        VTOFUD(vp)->flag &= ~FN_DIRECTIO;
+	}
+
 }

Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.h
==============================================================================
--- projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.h	Fri Apr  5 03:35:40 2019	(r345903)
+++ projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.h	Fri Apr  5 03:37:16 2019	(r345904)
@@ -158,7 +158,7 @@ int fuse_filehandle_getrw(struct vnode *vp, int fflag,
 			  pid_t pid);
 
 void fuse_filehandle_init(struct vnode *vp, fufh_type_t fufh_type,
-		          struct fuse_filehandle **fufhp, pid_t pid,
+		          struct fuse_filehandle **fufhp, struct thread *td,
 			  struct ucred *cred, struct fuse_open_out *foo);
 int fuse_filehandle_open(struct vnode *vp, int mode,
                          struct fuse_filehandle **fufhp, struct thread *td,

Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c
==============================================================================
--- projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c	Fri Apr  5 03:35:40 2019	(r345903)
+++ projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c	Fri Apr  5 03:37:16 2019	(r345904)
@@ -182,6 +182,11 @@ fiov_adjust(struct fuse_iov *fiov, size_t size)
 		}
 		fiov->allocated_size = FU_AT_LEAST(size);
 		fiov->credit = fuse_iov_credit;
+		/* Clear data buffer after reallocation */
+		bzero(fiov->base, size);
+	} else if (size > fiov->len) {
+		/* Clear newly extended portion of data buffer */
+		bzero((char*)fiov->base + fiov->len, size - fiov->len);
 	}
 	fiov->len = size;
 }
@@ -198,7 +203,6 @@ void
 fiov_refresh(struct fuse_iov *fiov)
 {
 	fiov_adjust(fiov, 0);
-	bzero(fiov->base, fiov->len);
 }
 
 static int
@@ -744,6 +748,8 @@ fdisp_refresh_pid(struct fuse_dispatcher *fdip, enum f
     struct mount *mp, uint64_t nid, pid_t pid, struct ucred *cred)
 {
 	MPASS(fdip->tick);
+	MPASS2(sizeof(fdip->finh) + fdip->iosize <= fdip->tick->tk_ms_fiov.len,
+		"Must use fdisp_make_pid to increase the size of the fiov");
 	fticket_reset(fdip->tick);
 
 	FUSE_DIMALLOC(&fdip->tick->tk_ms_fiov, fdip->finh,
@@ -766,6 +772,7 @@ fdisp_make_pid(struct fuse_dispatcher *fdip, enum fuse
 		fdip->tick = fuse_ticket_fetch(data);
 	}
 
+	/* FUSE_DIMALLOC will bzero the fiovs when it enlarges them */
 	FUSE_DIMALLOC(&fdip->tick->tk_ms_fiov, fdip->finh,
 	    fdip->indata, fdip->iosize);
 

Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_node.c
==============================================================================
--- projects/fuse2-googletest-engine/sys/fs/fuse/fuse_node.c	Fri Apr  5 03:35:40 2019	(r345903)
+++ projects/fuse2-googletest-engine/sys/fs/fuse/fuse_node.c	Fri Apr  5 03:37:16 2019	(r345904)
@@ -329,16 +329,6 @@ fuse_vnode_open(struct vnode *vp, int32_t fuse_open_fl
 	 *
 	 * XXXIP: Handle fd based DIRECT_IO
 	 */
-	if (fuse_open_flags & FOPEN_DIRECT_IO) {
-		ASSERT_VOP_ELOCKED(vp, __func__);
-		VTOFUD(vp)->flag |= FN_DIRECTIO;
-		fuse_io_invalbuf(vp, td);
-	} else {
-		if ((fuse_open_flags & FOPEN_KEEP_CACHE) == 0)
-			fuse_io_invalbuf(vp, td);
-	        VTOFUD(vp)->flag &= ~FN_DIRECTIO;
-	}
-
 	if (vnode_vtype(vp) == VREG) {
 		/* XXXIP prevent getattr, by using cached node size */
 		vnode_create_vobject(vp, 0, td);

Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_vnops.c
==============================================================================
--- projects/fuse2-googletest-engine/sys/fs/fuse/fuse_vnops.c	Fri Apr  5 03:35:40 2019	(r345903)
+++ projects/fuse2-googletest-engine/sys/fs/fuse/fuse_vnops.c	Fri Apr  5 03:37:16 2019	(r345904)
@@ -479,8 +479,7 @@ fuse_vnop_create(struct vop_create_args *ap)
 	}
 	ASSERT_VOP_ELOCKED(*vpp, "fuse_vnop_create");
 
-	fuse_filehandle_init(*vpp, FUFH_RDWR, NULL, td->td_proc->p_pid, cred,
-		foo);
+	fuse_filehandle_init(*vpp, FUFH_RDWR, NULL, td, cred, foo);
 	fuse_vnode_open(*vpp, foo->open_flags, td);
 	cache_purge_negative(dvp);
 

Modified: projects/fuse2-googletest-engine/tests/sys/fs/fusefs/read.cc
==============================================================================
--- projects/fuse2-googletest-engine/tests/sys/fs/fusefs/read.cc	Fri Apr  5 03:35:40 2019	(r345903)
+++ projects/fuse2-googletest-engine/tests/sys/fs/fusefs/read.cc	Fri Apr  5 03:37:16 2019	(r345904)
@@ -398,8 +398,7 @@ TEST_F(Read, eio)
  * With the keep_cache option, the kernel may keep its read cache across
  * multiple open(2)s.
  */
-/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236560 */
-TEST_F(Read, DISABLED_keep_cache)
+TEST_F(Read, keep_cache)
 {
 	const char FULLPATH[] = "mountpoint/some_file.txt";
 	const char RELPATH[] = "some_file.txt";
@@ -410,7 +409,7 @@ TEST_F(Read, DISABLED_keep_cache)
 	char buf[bufsize];
 
 	FuseTest::expect_lookup(RELPATH, ino, S_IFREG | 0644, bufsize, 2);
-	expect_open(ino, FOPEN_KEEP_CACHE, 1);
+	expect_open(ino, FOPEN_KEEP_CACHE, 2);
 	expect_getattr(ino, bufsize);
 	expect_read(ino, 0, bufsize, bufsize, CONTENTS);
 
@@ -418,7 +417,7 @@ TEST_F(Read, DISABLED_keep_cache)
 	ASSERT_LE(0, fd0) << strerror(errno);
 	ASSERT_EQ(bufsize, read(fd0, buf, bufsize)) << strerror(errno);
 
-	fd1 = open(FULLPATH, O_RDONLY);
+	fd1 = open(FULLPATH, O_RDWR);
 	ASSERT_LE(0, fd1) << strerror(errno);
 
 	/*
@@ -445,7 +444,7 @@ TEST_F(Read, keep_cache_disabled)
 	char buf[bufsize];
 
 	FuseTest::expect_lookup(RELPATH, ino, S_IFREG | 0644, bufsize, 2);
-	expect_open(ino, FOPEN_KEEP_CACHE, 1);
+	expect_open(ino, 0, 2);
 	expect_getattr(ino, bufsize);
 	expect_read(ino, 0, bufsize, bufsize, CONTENTS);
 
@@ -453,7 +452,7 @@ TEST_F(Read, keep_cache_disabled)
 	ASSERT_LE(0, fd0) << strerror(errno);
 	ASSERT_EQ(bufsize, read(fd0, buf, bufsize)) << strerror(errno);
 
-	fd1 = open(FULLPATH, O_RDONLY);
+	fd1 = open(FULLPATH, O_RDWR);
 	ASSERT_LE(0, fd1) << strerror(errno);
 
 	/*





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904050337.x353bHmX058112>