Fix GetDexCanonicalLocation test for relative paths.
If the reference file is created with a relative path the test will
fail.
(cherry picked from commit 61281dc0aaa22730fd4fee268cac40776b193042)
Change-Id: Ie82b9d381bd884111dfc91cc235b46ad9f3225be
diff --git a/runtime/dex_file_test.cc b/runtime/dex_file_test.cc
index fa13290..330d045 100644
--- a/runtime/dex_file_test.cc
+++ b/runtime/dex_file_test.cc
@@ -355,9 +355,10 @@
TEST_F(DexFileTest, GetDexCanonicalLocation) {
ScratchFile file;
- std::string dex_location = file.GetFilename();
+ char* dex_location_real = realpath(file.GetFilename().c_str(), nullptr);
+ std::string dex_location(dex_location_real);
- ASSERT_EQ(file.GetFilename(), DexFile::GetDexCanonicalLocation(dex_location.c_str()));
+ ASSERT_EQ(dex_location, DexFile::GetDexCanonicalLocation(dex_location.c_str()));
std::string multidex_location = DexFile::GetMultiDexClassesDexName(1, dex_location.c_str());
ASSERT_EQ(multidex_location, DexFile::GetDexCanonicalLocation(multidex_location.c_str()));
@@ -370,6 +371,8 @@
ASSERT_EQ(multidex_location, DexFile::GetDexCanonicalLocation(multidex_location_sym.c_str()));
ASSERT_EQ(0, unlink(dex_location_sym.c_str()));
+
+ free(dex_location_real);
}
} // namespace art