From owner-svn-src-all@freebsd.org Mon May 18 18:36:33 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8DAB92DA5BF; Mon, 18 May 2020 18:36:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49Qnm13GFbz49Yk; Mon, 18 May 2020 18:36:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6B33325F6F; Mon, 18 May 2020 18:36:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04IIaXJU005072; Mon, 18 May 2020 18:36:33 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04IIaWCJ005070; Mon, 18 May 2020 18:36:32 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <202005181836.04IIaWCJ005070@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 18 May 2020 18:36:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361223 - head/tests/sys/fs/fusefs X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: head/tests/sys/fs/fusefs X-SVN-Commit-Revision: 361223 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2020 18:36:33 -0000 Author: asomers Date: Mon May 18 18:36:32 2020 New Revision: 361223 URL: https://svnweb.freebsd.org/changeset/base/361223 Log: fusefs: fix intermittency in some ENOENT tests When a FUSE operation other than LOOKUP returns ENOENT, the kernel will reclaim that vnode, resuling in a FUSE_FORGET being sent a short while later. Many of the ENOENT tests weren't expecting those FUSE_FORGET operations. They usually passed by luck since FUSE_FORGET is often delayed. This commit adds appropriate expectations. MFC after: 2 weeks Modified: head/tests/sys/fs/fusefs/getattr.cc head/tests/sys/fs/fusefs/open.cc head/tests/sys/fs/fusefs/opendir.cc Modified: head/tests/sys/fs/fusefs/getattr.cc ============================================================================== --- head/tests/sys/fs/fusefs/getattr.cc Mon May 18 18:32:58 2020 (r361222) +++ head/tests/sys/fs/fusefs/getattr.cc Mon May 18 18:36:32 2020 (r361223) @@ -32,6 +32,8 @@ extern "C" { #include + +#include } #include "mockfs.hh" @@ -172,7 +174,10 @@ TEST_F(Getattr, enoent) const char RELPATH[] = "some_file.txt"; struct stat sb; const uint64_t ino = 42; + sem_t sem; + ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno); + expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1, 0, 0); EXPECT_CALL(*m_mock, process( ResultOf([](auto in) { @@ -181,8 +186,15 @@ TEST_F(Getattr, enoent) }, Eq(true)), _) ).WillOnce(Invoke(ReturnErrno(ENOENT))); + // Since FUSE_GETATTR returns ENOENT, the kernel will reclaim the vnode + // and send a FUSE_FORGET + expect_forget(ino, 1, &sem); + EXPECT_NE(0, stat(FULLPATH, &sb)); EXPECT_EQ(ENOENT, errno); + + sem_wait(&sem); + sem_destroy(&sem); } TEST_F(Getattr, ok) Modified: head/tests/sys/fs/fusefs/open.cc ============================================================================== --- head/tests/sys/fs/fusefs/open.cc Mon May 18 18:32:58 2020 (r361222) +++ head/tests/sys/fs/fusefs/open.cc Mon May 18 18:36:32 2020 (r361223) @@ -32,7 +32,9 @@ extern "C" { #include + #include +#include } #include "mockfs.hh" @@ -105,7 +107,10 @@ TEST_F(Open, enoent) const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; uint64_t ino = 42; + sem_t sem; + ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno); + expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1); EXPECT_CALL(*m_mock, process( ResultOf([=](auto in) { @@ -114,8 +119,15 @@ TEST_F(Open, enoent) }, Eq(true)), _) ).WillOnce(Invoke(ReturnErrno(ENOENT))); + // Since FUSE_OPEN returns ENOENT, the kernel will reclaim the vnode + // and send a FUSE_FORGET + expect_forget(ino, 1, &sem); + ASSERT_EQ(-1, open(FULLPATH, O_RDONLY)); EXPECT_EQ(ENOENT, errno); + + sem_wait(&sem); + sem_destroy(&sem); } /* Modified: head/tests/sys/fs/fusefs/opendir.cc ============================================================================== --- head/tests/sys/fs/fusefs/opendir.cc Mon May 18 18:32:58 2020 (r361222) +++ head/tests/sys/fs/fusefs/opendir.cc Mon May 18 18:36:32 2020 (r361223) @@ -32,7 +32,9 @@ extern "C" { #include + #include +#include } #include "mockfs.hh" @@ -82,12 +84,21 @@ TEST_F(Opendir, enoent) const char FULLPATH[] = "mountpoint/some_dir"; const char RELPATH[] = "some_dir"; uint64_t ino = 42; + sem_t sem; + ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno); + expect_lookup(RELPATH, ino); expect_opendir(ino, O_RDONLY, ReturnErrno(ENOENT)); + // Since FUSE_OPENDIR returns ENOENT, the kernel will reclaim the vnode + // and send a FUSE_FORGET + expect_forget(ino, 1, &sem); ASSERT_EQ(-1, open(FULLPATH, O_DIRECTORY)); EXPECT_EQ(ENOENT, errno); + + sem_wait(&sem); + sem_destroy(&sem); } /*