Skip to content

Commit e53a318

Browse files
committed
Use ASSERT_* instead of EXPECT_* to abort test early
Test: th Change-Id: Ifdd0221a4201029df9e4495c077cdc527ed74037
1 parent 866d470 commit e53a318

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

common/subprocess_unittest.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,20 @@ TEST_F(SubprocessTest, InactiveInstancesDontChangeTheSingleton) {
144144
}
145145

146146
TEST_F(SubprocessTest, SimpleTest) {
147-
EXPECT_TRUE(subprocess_.Exec({kBinPath "/false"},
147+
ASSERT_TRUE(subprocess_.Exec({kBinPath "/false"},
148148
base::Bind(&ExpectedResults, 1, "")));
149149
loop_.Run();
150150
}
151151

152152
TEST_F(SubprocessTest, EchoTest) {
153-
EXPECT_TRUE(subprocess_.Exec(
153+
ASSERT_TRUE(subprocess_.Exec(
154154
{kBinPath "/sh", "-c", "echo this is stdout; echo this is stderr >&2"},
155155
base::Bind(&ExpectedResults, 0, "this is stdout\nthis is stderr\n")));
156156
loop_.Run();
157157
}
158158

159159
TEST_F(SubprocessTest, StderrNotIncludedInOutputTest) {
160-
EXPECT_TRUE(subprocess_.ExecFlags(
160+
ASSERT_TRUE(subprocess_.ExecFlags(
161161
{kBinPath "/sh", "-c", "echo on stdout; echo on stderr >&2"},
162162
0,
163163
{},
@@ -172,13 +172,13 @@ TEST_F(SubprocessTest, PipeRedirectFdTest) {
172172
0,
173173
{3},
174174
base::Bind(&ExpectedDataOnPipe, &subprocess_, &pid, 3, "on pipe\n", 0));
175-
EXPECT_NE(0, pid);
175+
ASSERT_NE(0, pid);
176176

177177
// Wrong file descriptor values should return -1.
178-
EXPECT_EQ(-1, subprocess_.GetPipeFd(pid, 123));
178+
ASSERT_EQ(-1, subprocess_.GetPipeFd(pid, 123));
179179
loop_.Run();
180180
// Calling GetPipeFd() after the callback runs is invalid.
181-
EXPECT_EQ(-1, subprocess_.GetPipeFd(pid, 3));
181+
ASSERT_EQ(-1, subprocess_.GetPipeFd(pid, 3));
182182
}
183183

184184
// Test that a pipe file descriptor open in the parent is not open in the child.
@@ -191,20 +191,20 @@ TEST_F(SubprocessTest, PipeClosedWhenNotRedirectedTest) {
191191
test_utils::GetBuildArtifactsPath("test_subprocess"),
192192
"fstat",
193193
std::to_string(pipe.writer)};
194-
EXPECT_TRUE(subprocess_.ExecFlags(
194+
ASSERT_TRUE(subprocess_.ExecFlags(
195195
cmd, 0, {}, base::Bind(&ExpectedResults, EBADF, "")));
196196
loop_.Run();
197197
}
198198

199199
TEST_F(SubprocessTest, EnvVarsAreFiltered) {
200-
EXPECT_TRUE(
200+
ASSERT_TRUE(
201201
subprocess_.Exec({kUsrBinPath "/env"}, base::Bind(&ExpectedEnvVars)));
202202
loop_.Run();
203203
}
204204

205205
TEST_F(SubprocessTest, SynchronousTrueSearchsOnPath) {
206206
int rc = -1;
207-
EXPECT_TRUE(Subprocess::SynchronousExecFlags(
207+
ASSERT_TRUE(Subprocess::SynchronousExecFlags(
208208
{"true"}, Subprocess::kSearchPath, &rc, nullptr, nullptr));
209209
EXPECT_EQ(0, rc);
210210
}
@@ -238,7 +238,7 @@ TEST_F(SubprocessTest, CancelTest) {
238238
base::ScopedTempDir tempdir;
239239
ASSERT_TRUE(tempdir.CreateUniqueTempDir());
240240
string fifo_path = tempdir.GetPath().Append("fifo").value();
241-
EXPECT_EQ(0, mkfifo(fifo_path.c_str(), 0666));
241+
ASSERT_EQ(0, mkfifo(fifo_path.c_str(), 0666));
242242

243243
// Start a process, make sure it is running and try to cancel it. We write
244244
// two bytes to the fifo, the first one marks that the program is running and
@@ -263,10 +263,10 @@ TEST_F(SubprocessTest, CancelTest) {
263263
fifo_path.c_str(),
264264
fifo_path.c_str())};
265265
uint32_t tag = Subprocess::Get().Exec(cmd, base::Bind(&CallbackBad));
266-
EXPECT_NE(0U, tag);
266+
ASSERT_NE(0U, tag);
267267

268268
int fifo_fd = HANDLE_EINTR(open(fifo_path.c_str(), O_RDONLY));
269-
EXPECT_GE(fifo_fd, 0);
269+
ASSERT_GE(fifo_fd, 0);
270270

271271
watcher_ = base::FileDescriptorWatcher::WatchReadable(
272272
fifo_fd,

0 commit comments

Comments
 (0)