Commit ca98f2c8 authored by Yusuke Sato's avatar Yusuke Sato Committed by Commit Bot

arc: Fix P builds

crrev.com/796583 broke post-submit ARC tests on P boards.

BUG=1114931
TEST=tast run DUT_EVE arc.Boot

Change-Id: Id2bed1c14707763023ee145f6bc8931ecf5b847b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348197Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796729}
parent 4b7b3265
...@@ -164,6 +164,7 @@ bool IsComment(const std::string& line) { ...@@ -164,6 +164,7 @@ bool IsComment(const std::string& line) {
bool ExpandPropertyContents(const std::string& content, bool ExpandPropertyContents(const std::string& content,
brillo::CrosConfigInterface* config, brillo::CrosConfigInterface* config,
std::string* expanded_content, std::string* expanded_content,
bool filter_non_ro_props,
bool add_native_bridge_64bit_support, bool add_native_bridge_64bit_support,
bool append_dalvik_isa, bool append_dalvik_isa,
const std::string& partition_name) { const std::string& partition_name) {
...@@ -173,8 +174,12 @@ bool ExpandPropertyContents(const std::string& content, ...@@ -173,8 +174,12 @@ bool ExpandPropertyContents(const std::string& content,
std::string new_properties; std::string new_properties;
for (std::string line : lines) { for (std::string line : lines) {
// Chrome only expands ro. properties at runtime. // Since Chrome only expands ro. properties at runtime, skip processing
if (!base::StartsWith(line, "ro.", base::CompareCase::SENSITIVE)) { // non-ro lines here for R+. For P, we cannot do that because the
// expanded property files will directly replace the original ones via
// bind mounts.
if (filter_non_ro_props &&
!base::StartsWith(line, "ro.", base::CompareCase::SENSITIVE)) {
if (!IsComment(line) && line.find('{') != std::string::npos) { if (!IsComment(line) && line.find('{') != std::string::npos) {
// The non-ro property has substitution(s). // The non-ro property has substitution(s).
LOG(ERROR) << "Found substitution(s) in a non-ro property: " << line; LOG(ERROR) << "Found substitution(s) in a non-ro property: " << line;
...@@ -294,6 +299,7 @@ bool ExpandPropertyFile(const base::FilePath& input, ...@@ -294,6 +299,7 @@ bool ExpandPropertyFile(const base::FilePath& input,
return false; return false;
} }
if (!ExpandPropertyContents(content, config, &expanded, if (!ExpandPropertyContents(content, config, &expanded,
/*filter_non_ro_props=*/append,
add_native_bridge_64bit_support, add_native_bridge_64bit_support,
append_dalvik_isa, partition_name)) append_dalvik_isa, partition_name))
return false; return false;
...@@ -356,6 +362,7 @@ bool ExpandPropertyContentsForTesting(const std::string& content, ...@@ -356,6 +362,7 @@ bool ExpandPropertyContentsForTesting(const std::string& content,
brillo::CrosConfigInterface* config, brillo::CrosConfigInterface* config,
std::string* expanded_content) { std::string* expanded_content) {
return ExpandPropertyContents(content, config, expanded_content, return ExpandPropertyContents(content, config, expanded_content,
/*filter_non_ro_props=*/true,
/*add_native_bridge_64bit_support=*/false, /*add_native_bridge_64bit_support=*/false,
false, std::string()); false, std::string());
} }
......
...@@ -330,18 +330,18 @@ TEST_F(ArcPropertyUtilTest, ExpandPropertyFiles) { ...@@ -330,18 +330,18 @@ TEST_F(ArcPropertyUtilTest, ExpandPropertyFiles) {
std::string content; std::string content;
EXPECT_TRUE( EXPECT_TRUE(
base::ReadFileToString(dest_dir.Append("default.prop"), &content)); base::ReadFileToString(dest_dir.Append("default.prop"), &content));
EXPECT_EQ(std::string(kDefaultProp), content); EXPECT_EQ(std::string(kDefaultProp) + "\n", content);
EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content)); EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content));
EXPECT_EQ(std::string(kBuildProp), content); EXPECT_EQ(std::string(kBuildProp) + "\n", content);
EXPECT_TRUE( EXPECT_TRUE(
base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content)); base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content));
EXPECT_EQ(std::string(kVendorBuildProp), content); EXPECT_EQ(std::string(kVendorBuildProp) + "\n", content);
// Expand it again, verify the previous result is cleared. // Expand it again, verify the previous result is cleared.
EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, false)); EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, false));
EXPECT_TRUE( EXPECT_TRUE(
base::ReadFileToString(dest_dir.Append("default.prop"), &content)); base::ReadFileToString(dest_dir.Append("default.prop"), &content));
EXPECT_EQ(std::string(kDefaultProp), content); EXPECT_EQ(std::string(kDefaultProp) + "\n", content);
// If default.prop does not exist in the source path, it should still process // If default.prop does not exist in the source path, it should still process
// the other files, while also ensuring that default.prop is removed from the // the other files, while also ensuring that default.prop is removed from the
...@@ -351,10 +351,10 @@ TEST_F(ArcPropertyUtilTest, ExpandPropertyFiles) { ...@@ -351,10 +351,10 @@ TEST_F(ArcPropertyUtilTest, ExpandPropertyFiles) {
EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, false)); EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, false));
EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content)); EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content));
EXPECT_EQ(std::string(kBuildProp), content); EXPECT_EQ(std::string(kBuildProp) + "\n", content);
EXPECT_TRUE( EXPECT_TRUE(
base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content)); base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content));
EXPECT_EQ(std::string(kVendorBuildProp), content); EXPECT_EQ(std::string(kVendorBuildProp) + "\n", content);
// Finally, test the case where source is valid but the dest is not. // Finally, test the case where source is valid but the dest is not.
EXPECT_FALSE(ExpandPropertyFiles(source_dir, base::FilePath("/nonexistent"), EXPECT_FALSE(ExpandPropertyFiles(source_dir, base::FilePath("/nonexistent"),
...@@ -496,33 +496,36 @@ TEST_F(ArcPropertyUtilTest, TestNativeBridge64Support) { ...@@ -496,33 +496,36 @@ TEST_F(ArcPropertyUtilTest, TestNativeBridge64Support) {
EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, false)); EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, false));
EXPECT_TRUE( EXPECT_TRUE(
base::ReadFileToString(dest_dir.Append("default.prop"), &content)); base::ReadFileToString(dest_dir.Append("default.prop"), &content));
EXPECT_EQ(std::string(kDefaultProp), content); EXPECT_EQ(std::string(kDefaultProp) + "\n", content);
EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content)); EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content));
EXPECT_EQ(std::string(kBuildProp), content); EXPECT_EQ(std::string(kBuildProp) + "\n", content);
EXPECT_TRUE( EXPECT_TRUE(
base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content)); base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content));
EXPECT_EQ(std::string(kVendorBuildProp), content); EXPECT_EQ(std::string(kVendorBuildProp) + "\n", content);
// Expand with experiment on, verify properties are added / modified in // Expand with experiment on, verify properties are added / modified in
// build.prop but not other files. // build.prop but not other files.
EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, true)); EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, true));
EXPECT_TRUE( EXPECT_TRUE(
base::ReadFileToString(dest_dir.Append("default.prop"), &content)); base::ReadFileToString(dest_dir.Append("default.prop"), &content));
EXPECT_EQ(std::string(kDefaultProp), content); EXPECT_EQ(std::string(kDefaultProp) + "\n", content);
EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content)); EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content));
constexpr const char kBuildPropModified[] = constexpr const char kBuildPropModifiedFirst[] =
"ro.baz=boo\n" "ro.baz=boo\n"
"ro.product.cpu.abilist=x86_64,x86,arm64-v8a,armeabi-v7a,armeabi\n" "ro.product.cpu.abilist=x86_64,x86,arm64-v8a,armeabi-v7a,armeabi\n"
"ro.product.cpu.abilist64=x86_64,arm64-v8a\n" "ro.product.cpu.abilist64=x86_64,arm64-v8a\n";
constexpr const char kBuildPropModifiedSecond[] =
"ro.dalvik.vm.isa.arm64=x86_64\n"; "ro.dalvik.vm.isa.arm64=x86_64\n";
EXPECT_EQ(std::string(kBuildPropModified), content); EXPECT_EQ(base::StringPrintf("%s\n%s", kBuildPropModifiedFirst,
kBuildPropModifiedSecond),
content);
EXPECT_TRUE( EXPECT_TRUE(
base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content)); base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content));
constexpr const char kVendorBuildPropModified[] = constexpr const char kVendorBuildPropModified[] =
"ro.a=b\n" "ro.a=b\n"
"ro.vendor.product.cpu.abilist=x86_64,x86,arm64-v8a,armeabi-v7a,armeabi\n" "ro.vendor.product.cpu.abilist=x86_64,x86,arm64-v8a,armeabi-v7a,armeabi\n"
"ro.vendor.product.cpu.abilist64=x86_64,arm64-v8a\n"; "ro.vendor.product.cpu.abilist64=x86_64,arm64-v8a\n";
EXPECT_EQ(std::string(kVendorBuildPropModified), content); EXPECT_EQ(std::string(kVendorBuildPropModified) + "\n", content);
// Expand to a single file with experiment on, verify properties are added / // Expand to a single file with experiment on, verify properties are added /
// modified as expected. // modified as expected.
...@@ -534,9 +537,10 @@ TEST_F(ArcPropertyUtilTest, TestNativeBridge64Support) { ...@@ -534,9 +537,10 @@ TEST_F(ArcPropertyUtilTest, TestNativeBridge64Support) {
// Verify the contents. // Verify the contents.
EXPECT_TRUE(base::ReadFileToString(dest_prop_file, &content)); EXPECT_TRUE(base::ReadFileToString(dest_prop_file, &content));
EXPECT_EQ(base::StringPrintf("%s%s%s", kDefaultProp, kBuildPropModified, EXPECT_EQ(
kVendorBuildPropModified), base::StringPrintf("%s%s%s%s", kDefaultProp, kBuildPropModifiedFirst,
content); kBuildPropModifiedSecond, kVendorBuildPropModified),
content);
// Verify that unexpected property values generate an error. // Verify that unexpected property values generate an error.
constexpr const char kBuildPropUnexpected[] = constexpr const char kBuildPropUnexpected[] =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment