From f0d9a15015387d6237589882c0ec4b9a947253b9 Mon Sep 17 00:00:00 2001 From: asomers Date: Fri, 10 May 2019 18:18:41 +0000 Subject: [PATCH] fusefs: fix intermittency in the interrupt tests * In the fatal_signal test, wait for the daemon to receive FUSE_INTERRUPT before exiting. * Explicitly disable restarting syscalls after SIGUSR2. This fixes intermittency in the priority test. I don't know why, but sometimes that test's mkdir would be restarted, and sometimes it would return EINTR. ERESTART should be the default. * Remove a useless copy/pasted sleep in the priority test. Sponsored by: The FreeBSD Foundation --- tests/sys/fs/fusefs/interrupt.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/sys/fs/fusefs/interrupt.cc b/tests/sys/fs/fusefs/interrupt.cc index c1287a95761..63124afce96 100644 --- a/tests/sys/fs/fusefs/interrupt.cc +++ b/tests/sys/fs/fusefs/interrupt.cc @@ -163,6 +163,7 @@ void SetUp() { mprot, mflags, -1, 0); ASSERT_NE(MAP_FAILED, blocked_semaphore) << strerror(errno); ASSERT_EQ(0, sem_init(blocked_semaphore, 1, 0)) << strerror(errno); + ASSERT_EQ(0, siginterrupt(SIGUSR2, 1)); FuseTest::SetUp(); } @@ -357,7 +358,9 @@ TEST_F(Interrupt, fatal_signal) int status; pthread_t self; uint64_t mkdir_unique; + sem_t sem; + ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno); self = pthread_self(); EXPECT_LOOKUP(1, RELDIRPATH0).WillOnce(Invoke(ReturnErrno(ENOENT))); @@ -369,6 +372,7 @@ TEST_F(Interrupt, fatal_signal) }, Eq(true)), _) ).WillOnce(Invoke([&](auto in __unused, auto &out __unused) { + sem_post(&sem); /* Don't respond. The process should exit anyway */ })); @@ -398,6 +402,9 @@ TEST_F(Interrupt, fatal_signal) return 1; }); ASSERT_EQ(SIGUSR2, WTERMSIG(status)); + + EXPECT_EQ(0, sem_wait(&sem)) << strerror(errno); + sem_destroy(&sem); } /* @@ -715,9 +722,6 @@ TEST_F(Interrupt, priority) setup_interruptor(th0, true); ASSERT_EQ(0, mkdir(FULLDIRPATH1, MODE)) << strerror(errno); - /* Wait awhile to make sure the signal generates no FUSE_INTERRUPT */ - nap(); - pthread_join(th0, NULL); sem_destroy(&sem1); sem_destroy(&sem0); -- 2.45.0