Rename ProcResult stdout and stderr fields
stdout and stderr are macros in musl, which causes build failures when they are used as field names. Rename the fields to stdout_str and stderr_str. Test: builds Change-Id: I04770d2d6e82ca8393308ab12a304838a80f0ae5
This commit is contained in:
@@ -96,7 +96,7 @@ TEST_F(Idmap2BinaryTests, Create) {
|
|||||||
"--idmap-path", GetIdmapPath()});
|
"--idmap-path", GetIdmapPath()});
|
||||||
// clang-format on
|
// clang-format on
|
||||||
ASSERT_THAT(result, NotNull());
|
ASSERT_THAT(result, NotNull());
|
||||||
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
|
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr_str;
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
ASSERT_EQ(stat(GetIdmapPath().c_str(), &st), 0);
|
ASSERT_EQ(stat(GetIdmapPath().c_str(), &st), 0);
|
||||||
@@ -123,7 +123,7 @@ TEST_F(Idmap2BinaryTests, Dump) {
|
|||||||
"--idmap-path", GetIdmapPath()});
|
"--idmap-path", GetIdmapPath()});
|
||||||
// clang-format on
|
// clang-format on
|
||||||
ASSERT_THAT(result, NotNull());
|
ASSERT_THAT(result, NotNull());
|
||||||
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
|
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr_str;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
result = ExecuteBinary({"idmap2",
|
result = ExecuteBinary({"idmap2",
|
||||||
@@ -131,24 +131,24 @@ TEST_F(Idmap2BinaryTests, Dump) {
|
|||||||
"--idmap-path", GetIdmapPath()});
|
"--idmap-path", GetIdmapPath()});
|
||||||
// clang-format on
|
// clang-format on
|
||||||
ASSERT_THAT(result, NotNull());
|
ASSERT_THAT(result, NotNull());
|
||||||
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
|
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr_str;
|
||||||
|
|
||||||
ASSERT_NE(result->stdout.find(StringPrintf("0x%08x -> 0x%08x", R::target::integer::int1,
|
ASSERT_NE(result->stdout_str.find(StringPrintf("0x%08x -> 0x%08x", R::target::integer::int1,
|
||||||
R::overlay::integer::int1)),
|
R::overlay::integer::int1)),
|
||||||
std::string::npos)
|
std::string::npos)
|
||||||
<< result->stdout;
|
<< result->stdout_str;
|
||||||
ASSERT_NE(result->stdout.find(StringPrintf("0x%08x -> 0x%08x", R::target::string::str1,
|
ASSERT_NE(result->stdout_str.find(StringPrintf("0x%08x -> 0x%08x", R::target::string::str1,
|
||||||
R::overlay::string::str1)),
|
R::overlay::string::str1)),
|
||||||
std::string::npos)
|
std::string::npos)
|
||||||
<< result->stdout;
|
<< result->stdout_str;
|
||||||
ASSERT_NE(result->stdout.find(StringPrintf("0x%08x -> 0x%08x", R::target::string::str3,
|
ASSERT_NE(result->stdout_str.find(StringPrintf("0x%08x -> 0x%08x", R::target::string::str3,
|
||||||
R::overlay::string::str3)),
|
R::overlay::string::str3)),
|
||||||
std::string::npos)
|
std::string::npos)
|
||||||
<< result->stdout;
|
<< result->stdout_str;
|
||||||
ASSERT_NE(result->stdout.find(StringPrintf("0x%08x -> 0x%08x", R::target::string::str4,
|
ASSERT_NE(result->stdout_str.find(StringPrintf("0x%08x -> 0x%08x", R::target::string::str4,
|
||||||
R::overlay::string::str4)),
|
R::overlay::string::str4)),
|
||||||
std::string::npos)
|
std::string::npos)
|
||||||
<< result->stdout;
|
<< result->stdout_str;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
result = ExecuteBinary({"idmap2",
|
result = ExecuteBinary({"idmap2",
|
||||||
@@ -157,8 +157,8 @@ TEST_F(Idmap2BinaryTests, Dump) {
|
|||||||
"--idmap-path", GetIdmapPath()});
|
"--idmap-path", GetIdmapPath()});
|
||||||
// clang-format on
|
// clang-format on
|
||||||
ASSERT_THAT(result, NotNull());
|
ASSERT_THAT(result, NotNull());
|
||||||
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
|
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr_str;
|
||||||
ASSERT_NE(result->stdout.find("00000000: 504d4449 magic"), std::string::npos);
|
ASSERT_NE(result->stdout_str.find("00000000: 504d4449 magic"), std::string::npos);
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
result = ExecuteBinary({"idmap2",
|
result = ExecuteBinary({"idmap2",
|
||||||
@@ -184,7 +184,7 @@ TEST_F(Idmap2BinaryTests, Lookup) {
|
|||||||
"--idmap-path", GetIdmapPath()});
|
"--idmap-path", GetIdmapPath()});
|
||||||
// clang-format on
|
// clang-format on
|
||||||
ASSERT_THAT(result, NotNull());
|
ASSERT_THAT(result, NotNull());
|
||||||
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
|
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr_str;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
result = ExecuteBinary({"idmap2",
|
result = ExecuteBinary({"idmap2",
|
||||||
@@ -194,9 +194,9 @@ TEST_F(Idmap2BinaryTests, Lookup) {
|
|||||||
"--resid", StringPrintf("0x%08x", R::target::string::str1)});
|
"--resid", StringPrintf("0x%08x", R::target::string::str1)});
|
||||||
// clang-format on
|
// clang-format on
|
||||||
ASSERT_THAT(result, NotNull());
|
ASSERT_THAT(result, NotNull());
|
||||||
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
|
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr_str;
|
||||||
ASSERT_NE(result->stdout.find("overlay-1"), std::string::npos);
|
ASSERT_NE(result->stdout_str.find("overlay-1"), std::string::npos);
|
||||||
ASSERT_EQ(result->stdout.find("overlay-1-sv"), std::string::npos);
|
ASSERT_EQ(result->stdout_str.find("overlay-1-sv"), std::string::npos);
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
result = ExecuteBinary({"idmap2",
|
result = ExecuteBinary({"idmap2",
|
||||||
@@ -206,9 +206,9 @@ TEST_F(Idmap2BinaryTests, Lookup) {
|
|||||||
"--resid", "test.target:string/str1"});
|
"--resid", "test.target:string/str1"});
|
||||||
// clang-format on
|
// clang-format on
|
||||||
ASSERT_THAT(result, NotNull());
|
ASSERT_THAT(result, NotNull());
|
||||||
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
|
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr_str;
|
||||||
ASSERT_NE(result->stdout.find("overlay-1"), std::string::npos);
|
ASSERT_NE(result->stdout_str.find("overlay-1"), std::string::npos);
|
||||||
ASSERT_EQ(result->stdout.find("overlay-1-sv"), std::string::npos);
|
ASSERT_EQ(result->stdout_str.find("overlay-1-sv"), std::string::npos);
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
result = ExecuteBinary({"idmap2",
|
result = ExecuteBinary({"idmap2",
|
||||||
@@ -218,8 +218,8 @@ TEST_F(Idmap2BinaryTests, Lookup) {
|
|||||||
"--resid", "test.target:string/str1"});
|
"--resid", "test.target:string/str1"});
|
||||||
// clang-format on
|
// clang-format on
|
||||||
ASSERT_THAT(result, NotNull());
|
ASSERT_THAT(result, NotNull());
|
||||||
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
|
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr_str;
|
||||||
ASSERT_NE(result->stdout.find("overlay-1-sv"), std::string::npos);
|
ASSERT_NE(result->stdout_str.find("overlay-1-sv"), std::string::npos);
|
||||||
|
|
||||||
unlink(GetIdmapPath().c_str());
|
unlink(GetIdmapPath().c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,13 +73,13 @@ static jobjectArray createIdmap(JNIEnv* env, jclass /*clazz*/, jstring targetPat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result->status != 0) {
|
if (result->status != 0) {
|
||||||
LOG(ERROR) << "idmap2: " << result->stderr;
|
LOG(ERROR) << "idmap2: " << result->stderr_str;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the paths of the idmaps created or updated during the idmap invocation.
|
// Return the paths of the idmaps created or updated during the idmap invocation.
|
||||||
std::vector<std::string> idmap_paths;
|
std::vector<std::string> idmap_paths;
|
||||||
std::istringstream input(result->stdout);
|
std::istringstream input(result->stdout_str);
|
||||||
std::string path;
|
std::string path;
|
||||||
while (std::getline(input, path)) {
|
while (std::getline(input, path)) {
|
||||||
idmap_paths.push_back(path);
|
idmap_paths.push_back(path);
|
||||||
|
|||||||
@@ -114,10 +114,10 @@ std::unique_ptr<ProcResult> ExecuteBinary(const std::vector<std::string>& argv)
|
|||||||
std::unique_ptr<ProcResult> result(new ProcResult());
|
std::unique_ptr<ProcResult> result(new ProcResult());
|
||||||
result->status = status;
|
result->status = status;
|
||||||
const auto out = ReadFile(stdout[0]);
|
const auto out = ReadFile(stdout[0]);
|
||||||
result->stdout = out ? *out : "";
|
result->stdout_str = out ? *out : "";
|
||||||
close(stdout[0]);
|
close(stdout[0]);
|
||||||
const auto err = ReadFile(stderr[0]);
|
const auto err = ReadFile(stderr[0]);
|
||||||
result->stderr = err ? *err : "";
|
result->stderr_str = err ? *err : "";
|
||||||
close(stderr[0]);
|
close(stderr[0]);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ namespace util {
|
|||||||
|
|
||||||
struct ProcResult {
|
struct ProcResult {
|
||||||
int status;
|
int status;
|
||||||
std::string stdout;
|
std::string stdout_str;
|
||||||
std::string stderr;
|
std::string stderr_str;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fork, exec and wait for an external process. Return nullptr if the process could not be launched,
|
// Fork, exec and wait for an external process. Return nullptr if the process could not be launched,
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ TEST(PosixUtilsTest, AbsolutePathToBinary) {
|
|||||||
const auto result = ExecuteBinary({"/bin/date", "--help"});
|
const auto result = ExecuteBinary({"/bin/date", "--help"});
|
||||||
ASSERT_THAT(result, NotNull());
|
ASSERT_THAT(result, NotNull());
|
||||||
ASSERT_EQ(result->status, 0);
|
ASSERT_EQ(result->status, 0);
|
||||||
ASSERT_EQ(result->stdout.find("usage: date "), 0);
|
ASSERT_EQ(result->stdout_str.find("usage: date "), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PosixUtilsTest, RelativePathToBinary) {
|
TEST(PosixUtilsTest, RelativePathToBinary) {
|
||||||
const auto result = ExecuteBinary({"date", "--help"});
|
const auto result = ExecuteBinary({"date", "--help"});
|
||||||
ASSERT_THAT(result, NotNull());
|
ASSERT_THAT(result, NotNull());
|
||||||
ASSERT_EQ(result->status, 0);
|
ASSERT_EQ(result->status, 0);
|
||||||
ASSERT_EQ(result->stdout.find("usage: date "), 0);
|
ASSERT_EQ(result->stdout_str.find("usage: date "), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PosixUtilsTest, BadParameters) {
|
TEST(PosixUtilsTest, BadParameters) {
|
||||||
|
|||||||
Reference in New Issue
Block a user