Skip to content

Commit ca98f2c

Browse files
yusukesCommit Bot
authored and
Commit Bot
committed
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/+/2348197 Reviewed-by: Yury Khmel <khmel@chromium.org> Commit-Queue: Yusuke Sato <yusukes@chromium.org> Cr-Commit-Position: refs/heads/master@{#796729}
1 parent 4b7b326 commit ca98f2c

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

components/arc/session/arc_property_util.cc

+9-2
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ bool IsComment(const std::string& line) {
164164
bool ExpandPropertyContents(const std::string& content,
165165
brillo::CrosConfigInterface* config,
166166
std::string* expanded_content,
167+
bool filter_non_ro_props,
167168
bool add_native_bridge_64bit_support,
168169
bool append_dalvik_isa,
169170
const std::string& partition_name) {
@@ -173,8 +174,12 @@ bool ExpandPropertyContents(const std::string& content,
173174

174175
std::string new_properties;
175176
for (std::string line : lines) {
176-
// Chrome only expands ro. properties at runtime.
177-
if (!base::StartsWith(line, "ro.", base::CompareCase::SENSITIVE)) {
177+
// Since Chrome only expands ro. properties at runtime, skip processing
178+
// non-ro lines here for R+. For P, we cannot do that because the
179+
// expanded property files will directly replace the original ones via
180+
// bind mounts.
181+
if (filter_non_ro_props &&
182+
!base::StartsWith(line, "ro.", base::CompareCase::SENSITIVE)) {
178183
if (!IsComment(line) && line.find('{') != std::string::npos) {
179184
// The non-ro property has substitution(s).
180185
LOG(ERROR) << "Found substitution(s) in a non-ro property: " << line;
@@ -294,6 +299,7 @@ bool ExpandPropertyFile(const base::FilePath& input,
294299
return false;
295300
}
296301
if (!ExpandPropertyContents(content, config, &expanded,
302+
/*filter_non_ro_props=*/append,
297303
add_native_bridge_64bit_support,
298304
append_dalvik_isa, partition_name))
299305
return false;
@@ -356,6 +362,7 @@ bool ExpandPropertyContentsForTesting(const std::string& content,
356362
brillo::CrosConfigInterface* config,
357363
std::string* expanded_content) {
358364
return ExpandPropertyContents(content, config, expanded_content,
365+
/*filter_non_ro_props=*/true,
359366
/*add_native_bridge_64bit_support=*/false,
360367
false, std::string());
361368
}

components/arc/session/arc_property_util_unittest.cc

+21-17
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,18 @@ TEST_F(ArcPropertyUtilTest, ExpandPropertyFiles) {
330330
std::string content;
331331
EXPECT_TRUE(
332332
base::ReadFileToString(dest_dir.Append("default.prop"), &content));
333-
EXPECT_EQ(std::string(kDefaultProp), content);
333+
EXPECT_EQ(std::string(kDefaultProp) + "\n", content);
334334
EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content));
335-
EXPECT_EQ(std::string(kBuildProp), content);
335+
EXPECT_EQ(std::string(kBuildProp) + "\n", content);
336336
EXPECT_TRUE(
337337
base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content));
338-
EXPECT_EQ(std::string(kVendorBuildProp), content);
338+
EXPECT_EQ(std::string(kVendorBuildProp) + "\n", content);
339339

340340
// Expand it again, verify the previous result is cleared.
341341
EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, false));
342342
EXPECT_TRUE(
343343
base::ReadFileToString(dest_dir.Append("default.prop"), &content));
344-
EXPECT_EQ(std::string(kDefaultProp), content);
344+
EXPECT_EQ(std::string(kDefaultProp) + "\n", content);
345345

346346
// If default.prop does not exist in the source path, it should still process
347347
// the other files, while also ensuring that default.prop is removed from the
@@ -351,10 +351,10 @@ TEST_F(ArcPropertyUtilTest, ExpandPropertyFiles) {
351351
EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, false));
352352

353353
EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content));
354-
EXPECT_EQ(std::string(kBuildProp), content);
354+
EXPECT_EQ(std::string(kBuildProp) + "\n", content);
355355
EXPECT_TRUE(
356356
base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content));
357-
EXPECT_EQ(std::string(kVendorBuildProp), content);
357+
EXPECT_EQ(std::string(kVendorBuildProp) + "\n", content);
358358

359359
// Finally, test the case where source is valid but the dest is not.
360360
EXPECT_FALSE(ExpandPropertyFiles(source_dir, base::FilePath("/nonexistent"),
@@ -496,33 +496,36 @@ TEST_F(ArcPropertyUtilTest, TestNativeBridge64Support) {
496496
EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, false));
497497
EXPECT_TRUE(
498498
base::ReadFileToString(dest_dir.Append("default.prop"), &content));
499-
EXPECT_EQ(std::string(kDefaultProp), content);
499+
EXPECT_EQ(std::string(kDefaultProp) + "\n", content);
500500
EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content));
501-
EXPECT_EQ(std::string(kBuildProp), content);
501+
EXPECT_EQ(std::string(kBuildProp) + "\n", content);
502502
EXPECT_TRUE(
503503
base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content));
504-
EXPECT_EQ(std::string(kVendorBuildProp), content);
504+
EXPECT_EQ(std::string(kVendorBuildProp) + "\n", content);
505505

506506
// Expand with experiment on, verify properties are added / modified in
507507
// build.prop but not other files.
508508
EXPECT_TRUE(ExpandPropertyFiles(source_dir, dest_dir, false, true));
509509
EXPECT_TRUE(
510510
base::ReadFileToString(dest_dir.Append("default.prop"), &content));
511-
EXPECT_EQ(std::string(kDefaultProp), content);
511+
EXPECT_EQ(std::string(kDefaultProp) + "\n", content);
512512
EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content));
513-
constexpr const char kBuildPropModified[] =
513+
constexpr const char kBuildPropModifiedFirst[] =
514514
"ro.baz=boo\n"
515515
"ro.product.cpu.abilist=x86_64,x86,arm64-v8a,armeabi-v7a,armeabi\n"
516-
"ro.product.cpu.abilist64=x86_64,arm64-v8a\n"
516+
"ro.product.cpu.abilist64=x86_64,arm64-v8a\n";
517+
constexpr const char kBuildPropModifiedSecond[] =
517518
"ro.dalvik.vm.isa.arm64=x86_64\n";
518-
EXPECT_EQ(std::string(kBuildPropModified), content);
519+
EXPECT_EQ(base::StringPrintf("%s\n%s", kBuildPropModifiedFirst,
520+
kBuildPropModifiedSecond),
521+
content);
519522
EXPECT_TRUE(
520523
base::ReadFileToString(dest_dir.Append("vendor_build.prop"), &content));
521524
constexpr const char kVendorBuildPropModified[] =
522525
"ro.a=b\n"
523526
"ro.vendor.product.cpu.abilist=x86_64,x86,arm64-v8a,armeabi-v7a,armeabi\n"
524527
"ro.vendor.product.cpu.abilist64=x86_64,arm64-v8a\n";
525-
EXPECT_EQ(std::string(kVendorBuildPropModified), content);
528+
EXPECT_EQ(std::string(kVendorBuildPropModified) + "\n", content);
526529

527530
// Expand to a single file with experiment on, verify properties are added /
528531
// modified as expected.
@@ -534,9 +537,10 @@ TEST_F(ArcPropertyUtilTest, TestNativeBridge64Support) {
534537

535538
// Verify the contents.
536539
EXPECT_TRUE(base::ReadFileToString(dest_prop_file, &content));
537-
EXPECT_EQ(base::StringPrintf("%s%s%s", kDefaultProp, kBuildPropModified,
538-
kVendorBuildPropModified),
539-
content);
540+
EXPECT_EQ(
541+
base::StringPrintf("%s%s%s%s", kDefaultProp, kBuildPropModifiedFirst,
542+
kBuildPropModifiedSecond, kVendorBuildPropModified),
543+
content);
540544

541545
// Verify that unexpected property values generate an error.
542546
constexpr const char kBuildPropUnexpected[] =

0 commit comments

Comments
 (0)