// done from the same process for the granted range. The lock
// attempt must fail to pass our check.
- bool was_locked(false);
-
pipe(fds);
if (fork() == 0) {
// Parent reads from pipe
close(fds[1]);
- // Read status and set flag
+ // Read status
read(fds[0], &locked, sizeof(locked));
- if (locked == 1) {
- was_locked = true;
- } else {
- was_locked = false;
- }
-
close(fds[0]);
+
+ EXPECT_EQ(1, locked);
}
- EXPECT_TRUE(was_locked);
EXPECT_TRUE(locker.unlock());
}
int fds[2];
- bool was_not_locked(true);
-
pipe(fds);
if (fork() == 0) {
// Parent reads from pipe
close(fds[1]);
- // Read status and set flag
+ // Read status
read(fds[0], &locked, sizeof(locked));
- if (locked == 0) {
- was_not_locked = true;
- } else {
- was_not_locked = false;
- }
-
close(fds[0]);
+
+ EXPECT_EQ(0, locked);
}
- EXPECT_TRUE(was_not_locked);
EXPECT_TRUE(locker.unlock());
}