Merge "Move ExecTestHelper to using a regex." am: b4d9304628
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1843499 Change-Id: I1c1f6cb3fe3930de9593cf531d49ca99681b59b6
This commit is contained in:
commit
617c4b5876
2 changed files with 9 additions and 5 deletions
|
@ -133,7 +133,8 @@ TEST(dl, exec_linker_load_file) {
|
|||
"helper_func called\n";
|
||||
ExecTestHelper eth;
|
||||
eth.SetArgs({ path_to_linker, helper.c_str(), nullptr });
|
||||
eth.Run([&]() { execve(path_to_linker, eth.GetArgs(), eth.GetEnv()); }, 0, expected_output.c_str());
|
||||
eth.Run([&]() { execve(path_to_linker, eth.GetArgs(), eth.GetEnv()); }, 0, nullptr);
|
||||
ASSERT_EQ(expected_output, eth.GetOutput());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -149,7 +150,8 @@ TEST(dl, exec_linker_load_from_zip) {
|
|||
"helper_func called\n";
|
||||
ExecTestHelper eth;
|
||||
eth.SetArgs({ path_to_linker, helper.c_str(), nullptr });
|
||||
eth.Run([&]() { execve(path_to_linker, eth.GetArgs(), eth.GetEnv()); }, 0, expected_output.c_str());
|
||||
eth.Run([&]() { execve(path_to_linker, eth.GetArgs(), eth.GetEnv()); }, 0, nullptr);
|
||||
ASSERT_EQ(expected_output, eth.GetOutput());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ class ExecTestHelper {
|
|||
}
|
||||
|
||||
void Run(const std::function<void()>& child_fn, int expected_exit_status,
|
||||
const char* expected_output) {
|
||||
const char* expected_output_regex) {
|
||||
int fds[2];
|
||||
ASSERT_NE(pipe(fds), -1);
|
||||
|
||||
|
@ -258,8 +258,10 @@ class ExecTestHelper {
|
|||
|
||||
std::string error_msg("Test output:\n" + output_);
|
||||
AssertChildExited(pid, expected_exit_status, &error_msg);
|
||||
if (expected_output != nullptr) {
|
||||
ASSERT_EQ(expected_output, output_);
|
||||
if (expected_output_regex != nullptr) {
|
||||
if (!std::regex_search(output_, std::regex(expected_output_regex))) {
|
||||
FAIL() << "regex " << expected_output_regex << " didn't match " << output_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue