Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/syscalls/linux/epoll.cc
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ TEST(EpollTest, DoubleEpollOneShot) {

// Make request.
{
absl::MutexLock lock(&m);
absl::MutexLock lock(m);
ASSERT_EQ(WriteFd(sockets[1], msg1, sizeof(msg1)), sizeof(msg1));
}

Expand All @@ -425,7 +425,7 @@ TEST(EpollTest, DoubleEpollOneShot) {

// Read response.
{
absl::MutexLock lock(&m);
absl::MutexLock lock(m);
ASSERT_THAT(ReadFd(sockets[1], &tmp, sizeof(tmp)),
SyscallSucceedsWithValue(sizeof(tmp)));
}
Expand Down
6 changes: 3 additions & 3 deletions test/syscalls/linux/exec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1231,17 +1231,17 @@ void ExecWithThread() {
bool started = false;

ScopedThread t([&] {
mu.Lock();
mu.lock();
started = true;
mu.Unlock();
mu.unlock();

while (true) {
pause();
}
});

mu.LockWhen(absl::Condition(&started));
mu.Unlock();
mu.unlock();

const ExecveArray argv = {"/proc/self/exe", kExit42};
const ExecveArray envv;
Expand Down
18 changes: 9 additions & 9 deletions test/syscalls/linux/inotify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2322,7 +2322,7 @@ TEST(InotifyTest, InotifyAndTargetDestructionDoNotDeadlock) {
for (auto& afd : fds) {
int new_fd;
ASSERT_THAT(new_fd = inotify_init1(IN_NONBLOCK), SyscallSucceeds());
absl::MutexLock l(&afd.mu);
absl::MutexLock l(afd.mu);
ASSERT_THAT(close(afd.fd), SyscallSucceeds());
afd.fd = new_fd;
for (auto& p : paths) {
Expand Down Expand Up @@ -2429,7 +2429,7 @@ TEST(InotifyTest, NotifyNoDeadlock) {
InotifyAddWatch(ifd.get(), dir, IN_ALL_EVENTS));
int file_wd;
{
absl::ReaderMutexLock l(&mu);
absl::ReaderMutexLock l(mu);
file_wd = ASSERT_NO_ERRNO_AND_VALUE(
InotifyAddWatch(ifd.get(), file, IN_ALL_EVENTS));
}
Expand All @@ -2439,7 +2439,7 @@ TEST(InotifyTest, NotifyNoDeadlock) {
dir_wd = ASSERT_NO_ERRNO_AND_VALUE(
InotifyAddWatch(ifd.get(), dir, IN_ALL_EVENTS));
{
absl::ReaderMutexLock l(&mu);
absl::ReaderMutexLock l(mu);
file_wd = ASSERT_NO_ERRNO_AND_VALUE(
InotifyAddWatch(ifd.get(), file, IN_ALL_EVENTS));
}
Expand All @@ -2451,7 +2451,7 @@ TEST(InotifyTest, NotifyNoDeadlock) {
ScopedThread stats([&] {
int fd, dir_fd;
{
absl::ReaderMutexLock l(&mu);
absl::ReaderMutexLock l(mu);
ASSERT_THAT(fd = open(file.c_str(), O_RDONLY), SyscallSucceeds());
}
ASSERT_THAT(dir_fd = open(dir.c_str(), O_RDONLY | O_DIRECTORY),
Expand All @@ -2460,7 +2460,7 @@ TEST(InotifyTest, NotifyNoDeadlock) {

for (auto start = absl::Now(); absl::Now() - start < runtime;) {
{
absl::ReaderMutexLock l(&mu);
absl::ReaderMutexLock l(mu);
EXPECT_THAT(utimes(file.c_str(), times), SyscallSucceeds());
}
EXPECT_THAT(futimes(fd, times), SyscallSucceeds());
Expand All @@ -2476,15 +2476,15 @@ TEST(InotifyTest, NotifyNoDeadlock) {
if (!IsRunningOnGvisor()) {
int fd;
{
absl::ReaderMutexLock l(&mu);
absl::ReaderMutexLock l(mu);
ASSERT_THAT(fd = open(file.c_str(), O_RDONLY), SyscallSucceeds());
}

const char* name = "user.test";
int val = 123;
for (auto start = absl::Now(); absl::Now() - start < runtime;) {
{
absl::ReaderMutexLock l(&mu);
absl::ReaderMutexLock l(mu);
ASSERT_THAT(
setxattr(file.c_str(), name, &val, sizeof(val), /*flags=*/0),
SyscallSucceeds());
Expand All @@ -2503,7 +2503,7 @@ TEST(InotifyTest, NotifyNoDeadlock) {
ScopedThread read_write([&] {
int fd;
{
absl::ReaderMutexLock l(&mu);
absl::ReaderMutexLock l(mu);
ASSERT_THAT(fd = open(file.c_str(), O_RDWR), SyscallSucceeds());
}
for (auto start = absl::Now(); absl::Now() - start < runtime;) {
Expand All @@ -2522,7 +2522,7 @@ TEST(InotifyTest, NotifyNoDeadlock) {
for (auto start = absl::Now(); absl::Now() - start < runtime;) {
const std::string new_path = NewTempAbsPathInDir(dir);
{
absl::WriterMutexLock l(&mu);
absl::WriterMutexLock l(mu);
ASSERT_THAT(rename(file.c_str(), new_path.c_str()), SyscallSucceeds());
file = new_path;
}
Expand Down
12 changes: 6 additions & 6 deletions test/syscalls/linux/keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ TEST(KeysTest, ChildThreadInheritsSessionKeyringCreatedAfterChildIsBorn) {
bool child_ready = false;
bool parent_keyring_created = false;
ScopedThread child([&] {
absl::MutexLock child_ml(&mu);
absl::MutexLock child_ml(mu);
child_ready = true;
std::cerr << "Child is spawned and waiting for parent." << std::endl;
mu.Await(absl::Condition(&parent_keyring_created));
Expand All @@ -342,7 +342,7 @@ TEST(KeysTest, ChildThreadInheritsSessionKeyringCreatedAfterChildIsBorn) {
<< std::endl;
});
[&] {
absl::MutexLock parent_ml(&mu);
absl::MutexLock parent_ml(mu);
mu.Await(absl::Condition(&child_ready));
int64_t session_keyring_id =
ASSERT_NO_ERRNO_AND_VALUE(keyctl(KEYCTL_JOIN_SESSION_KEYRING));
Expand Down Expand Up @@ -419,7 +419,7 @@ TEST(KeysTest, ExistingNamedSessionKeyringIsNew) {
absl::Mutex mu;
bool first_child_created_keyring = false;
ScopedThread first_child([&] {
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
ASSERT_NO_ERRNO(
keyctl(KEYCTL_JOIN_SESSION_KEYRING, (uint64_t)(kKeyringName.data())));
first_child_key =
Expand All @@ -429,7 +429,7 @@ TEST(KeysTest, ExistingNamedSessionKeyringIsNew) {
first_child_created_keyring = true;
});
ScopedThread([&] {
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
second_child_initial_key =
ASSERT_NO_ERRNO_AND_VALUE(DescribeKey(KEY_SPEC_SESSION_KEYRING));
std::cerr << "Session child's initial session keyring: "
Expand Down Expand Up @@ -713,7 +713,7 @@ TEST(KeysTest, SearchableKeyringIsSharedAcrossThreads) {
// flipped.

ScopedThread first_child([&] {
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
first_child_ready = true;
mu.Await(absl::Condition(&second_child_ready));
ASSERT_NO_ERRNO(
Expand Down Expand Up @@ -746,7 +746,7 @@ TEST(KeysTest, SearchableKeyringIsSharedAcrossThreads) {
first_child_modified_keyring = true;
});
ScopedThread second_child([&] {
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
second_child_ready = true;
mu.Await(absl::Condition(&first_child_ready));
mu.Await(absl::Condition(&first_child_created_keyring));
Expand Down
6 changes: 3 additions & 3 deletions test/syscalls/linux/kill.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,16 @@ TEST(KillTest, CannotKillTid) {
bool finished = false;
absl::Mutex mu;
ScopedThread t([&] {
mu.Lock();
mu.lock();
tid = gettid();
tid_available = true;
mu.Await(absl::Condition(&finished));
mu.Unlock();
mu.unlock();
});
mu.LockWhen(absl::Condition(&tid_available));
EXPECT_THAT(kill(tid, 0), SyscallSucceeds());
finished = true;
mu.Unlock();
mu.unlock();
}

TEST(KillTest, SetPgid) {
Expand Down
8 changes: 4 additions & 4 deletions test/syscalls/linux/pause.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ TEST(PauseTest, OnlyReturnsWhenSignalHandled) {
std::atomic<int> sent_signal{0};
std::atomic<int> waking_signal{0};
ScopedThread t([&] {
mu.Lock();
mu.lock();
child_tid = gettid();
child_tid_available = true;
mu.Unlock();
mu.unlock();
EXPECT_THAT(pause(), SyscallFailsWithErrno(EINTR));
waking_signal.store(sent_signal.load());
});
mu.Lock();
mu.lock();
mu.Await(absl::Condition(&child_tid_available));
mu.Unlock();
mu.unlock();

// Wait a bit to let the child enter pause().
absl::SleepFor(absl::Seconds(3));
Expand Down
6 changes: 3 additions & 3 deletions test/syscalls/linux/proc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2406,22 +2406,22 @@ class BlockingChild {
~BlockingChild() { Join(); }

pid_t Tid() const {
absl::MutexLock ml(&mu_);
absl::MutexLock ml(mu_);
mu_.Await(absl::Condition(&tid_ready_));
return tid_;
}

void Join() {
{
absl::MutexLock ml(&mu_);
absl::MutexLock ml(mu_);
stop_ = true;
}
thread_.Join();
}

private:
void Start() {
absl::MutexLock ml(&mu_);
absl::MutexLock ml(mu_);
tid_ = syscall(__NR_gettid);
tid_ready_ = true;
mu_.Await(absl::Condition(&stop_));
Expand Down
8 changes: 4 additions & 4 deletions test/syscalls/linux/semaphore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ TEST(SemaphoreTest, SemOpRandom) {
for (size_t i = 0; i < 500; ++i) {
int16_t val;
{
absl::MutexLock l(&mutex);
absl::MutexLock l(mutex);
if (done) {
return;
}
Expand All @@ -397,7 +397,7 @@ TEST(SemaphoreTest, SemOpRandom) {
zero = std::make_unique<ScopedThread>([&sem, &mutex, &done] {
for (size_t i = 0; i < 500; ++i) {
{
absl::MutexLock l(&mutex);
absl::MutexLock l(mutex);
if (done) {
return;
}
Expand All @@ -417,7 +417,7 @@ TEST(SemaphoreTest, SemOpRandom) {
for (size_t i = 0; i < 500; ++i) {
int16_t val;
{
absl::MutexLock l(&mutex);
absl::MutexLock l(mutex);
val = (rand_r(&seed) % 10 + 1); // Rand between 1 and 10.
count += val;
}
Expand All @@ -437,7 +437,7 @@ TEST(SemaphoreTest, SemOpRandom) {
// Now there could be waiters blocked (remember operations are random).
// Notify waiters that we're done and signal semaphore just the right amount.
{
absl::MutexLock l(&mutex);
absl::MutexLock l(mutex);
done = true;
struct sembuf buf = {};
buf.sem_op = -count;
Expand Down
10 changes: 5 additions & 5 deletions test/syscalls/linux/signalfd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ TEST_P(SignalfdTest, Blocking) {
ScopedThread t([&] {
// Copy the tid and notify the caller.
{
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
tid = gettid();
has_tid = true;
}
Expand All @@ -136,7 +136,7 @@ TEST_P(SignalfdTest, Blocking) {
});

// Wait until blocked.
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
mu.Await(absl::Condition(&has_tid));

// Deliver the signal to either the waiting thread, or
Expand Down Expand Up @@ -176,7 +176,7 @@ TEST_P(SignalfdTest, ThreadGroup) {
EXPECT_EQ(rbuf.ssi_signo, signo);

// Wait for the other thread.
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
first = true;
mu.Await(absl::Condition(&second));
});
Expand All @@ -186,7 +186,7 @@ TEST_P(SignalfdTest, ThreadGroup) {

// Wait for the first thread to process.
{
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
mu.Await(absl::Condition(&first));
}

Expand All @@ -201,7 +201,7 @@ TEST_P(SignalfdTest, ThreadGroup) {

// Mark the test as done.
{
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
second = true;
}

Expand Down
8 changes: 4 additions & 4 deletions test/syscalls/linux/unshare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ TEST(UnshareTest, ThreadFlagFailsIfMultithreaded) {
absl::Mutex mu;
bool finished = false;
ScopedThread t([&] {
mu.Lock();
mu.lock();
mu.Await(absl::Condition(&finished));
mu.Unlock();
mu.unlock();
});
ASSERT_THAT(unshare(CLONE_THREAD), SyscallFailsWithErrno(EINVAL));
mu.Lock();
mu.lock();
finished = true;
mu.Unlock();
mu.unlock();
}

} // namespace
Expand Down
8 changes: 4 additions & 4 deletions test/syscalls/linux/wait.cc
Original file line number Diff line number Diff line change
Expand Up @@ -447,15 +447,15 @@ TEST_P(WaitSpecificChildTest, SiblingChildren) {
bool stop = false;

ScopedThread t([&] {
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
EXPECT_THAT(child = ForkAndExit(0, 0), SyscallSucceeds());
ready = true;
mu.Await(absl::Condition(&stop));
});

// N.B. This must be declared after ScopedThread, so it is destructed first,
// thus waking the thread.
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
mu.Await(absl::Condition(&ready));

EXPECT_NO_ERRNO(WaitFor(child, 0));
Expand Down Expand Up @@ -483,7 +483,7 @@ TEST_P(WaitSpecificChildTest, SiblingChildrenWNOTHREAD) {
bool stop = false;

ScopedThread t([&] {
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
EXPECT_THAT(child = ForkAndExit(0, 0), SyscallSucceeds());
ready = true;
mu.Await(absl::Condition(&stop));
Expand All @@ -494,7 +494,7 @@ TEST_P(WaitSpecificChildTest, SiblingChildrenWNOTHREAD) {

// N.B. This must be declared after ScopedThread, so it is destructed first,
// thus waking the thread.
absl::MutexLock ml(&mu);
absl::MutexLock ml(mu);
mu.Await(absl::Condition(&ready));

// This thread can't wait on child.
Expand Down