Fix patchoat_test for heap poisoning
The test was disabled for heap poisoning; keep it disabled.
The TEST_DISABLED_FOR_HEAP_POISONING macro is in fact just
a conditional return, and I didn't account for it properly.
Bug: 109677607
Test: test-art-host-gtest-patchoat_test ART_HEAP_POISONING=true
Change-Id: I40266d0a06102e4d8bc52357b884b0e7d9fd2630
diff --git a/patchoat/patchoat_test.cc b/patchoat/patchoat_test.cc
index 934936d..08bf31c 100644
--- a/patchoat/patchoat_test.cc
+++ b/patchoat/patchoat_test.cc
@@ -445,19 +445,15 @@
#endif
}
+// These tests check that a boot image relocated using patchoat can be unrelocated
+// using the .rel file created by patchoat.
+//
+// The tests don't work when heap poisoning is enabled because some of the
+// references are negated. b/72117833 is tracking the effort to have patchoat
+// and its tests support heap poisoning.
class PatchoatVerificationTest : public PatchoatTest {
protected:
- virtual void SetUp() {
- PatchoatTest::SetUp();
-
- // This test checks that a boot image relocated using patchoat can be unrelocated using the .rel
- // file created by patchoat.
-
- // This test doesn't work when heap poisoning is enabled because some of the
- // references are negated. b/72117833 is tracking the effort to have patchoat
- // and its tests support heap poisoning.
- TEST_DISABLED_FOR_HEAP_POISONING();
-
+ void CreateRelocatedBootImage() {
// Compile boot image into a random directory using dex2oat
ScratchFile dex2oat_orig_scratch;
dex2oat_orig_scratch.Unlink();
@@ -534,12 +530,14 @@
}
virtual void TearDown() {
- ClearDirectory(dex2oat_orig_dir_.c_str(), /*recursive*/ true);
- ClearDirectory(relocated_dir_.c_str(), /*recursive*/ true);
-
- rmdir(dex2oat_orig_dir_.c_str());
- rmdir(relocated_dir_.c_str());
-
+ if (!dex2oat_orig_dir_.empty()) {
+ ClearDirectory(dex2oat_orig_dir_.c_str(), /*recursive*/ true);
+ rmdir(dex2oat_orig_dir_.c_str());
+ }
+ if (!relocated_dir_.empty()) {
+ ClearDirectory(relocated_dir_.c_str(), /*recursive*/ true);
+ rmdir(relocated_dir_.c_str());
+ }
PatchoatTest::TearDown();
}
@@ -550,6 +548,9 @@
// Assert that verification works with the .rel files.
TEST_F(PatchoatVerificationTest, Sucessful) {
+ TEST_DISABLED_FOR_HEAP_POISONING();
+ CreateRelocatedBootImage();
+
std::string error_msg;
if (!VerifyBootImage(
dex2oat_orig_dir_ + "/boot.art",
@@ -562,6 +563,9 @@
// Corrupt the image file and check that the verification fails gracefully.
TEST_F(PatchoatVerificationTest, CorruptedImage) {
+ TEST_DISABLED_FOR_HEAP_POISONING();
+ CreateRelocatedBootImage();
+
std::string error_msg;
std::string relocated_image_filename;
if (!GetDalvikCacheFilename((dex2oat_orig_dir_ + "/boot.art").c_str(),
@@ -584,6 +588,9 @@
// Corrupt the relocation file and check that the verification fails gracefully.
TEST_F(PatchoatVerificationTest, CorruptedRelFile) {
+ TEST_DISABLED_FOR_HEAP_POISONING();
+ CreateRelocatedBootImage();
+
std::string error_msg;
std::string art_filename = dex2oat_orig_dir_ + "/boot.art";
std::string rel_filename = dex2oat_orig_dir_ + "/boot.art.rel";