// TODO(dsrbecky): b/160885380: This test is failing in eng-prod because libartbase // is loaded from different path (under testcases).
TEST_F(FileUtilsTest, DISABLED_GetAndroidRootSafe) {
std::string error_msg;
// We don't expect null returns for most cases, so don't check and let std::string crash.
// CommonArtTest sets ANDROID_ROOT, so expect this to be the same.
std::string android_root = GetAndroidRootSafe(&error_msg);
std::string android_root_env = getenv("ANDROID_ROOT");
EXPECT_EQ(android_root, android_root_env) << error_msg;
// Set ANDROID_ROOT to something else (but the directory must exist). So use dirname.
UniqueCPtr<char> root_dup(strdup(android_root_env.c_str())); char* dir = dirname(root_dup.get());
ASSERT_EQ(0, setenv("ANDROID_ROOT", dir, /* overwrite */ 1));
std::string android_root2 = GetAndroidRootSafe(&error_msg);
EXPECT_STREQ(dir, android_root2.c_str()) << error_msg;
// Set a bogus value for ANDROID_ROOT. This should be an error.
ASSERT_EQ(0, setenv("ANDROID_ROOT", "/this/is/obviously/bogus", /* overwrite */ 1));
EXPECT_EQ(GetAndroidRootSafe(&error_msg), "");
error_msg = "";
// Inferring the Android Root from the location of libartbase only works on host. if (!kIsTargetBuild) { // Unset ANDROID_ROOT and see that it still returns something (as libartbase code is running).
ASSERT_EQ(0, unsetenv("ANDROID_ROOT"));
std::string android_root3 = GetAndroidRootSafe(&error_msg); // This should be the same as the other root (modulo realpath), otherwise the test setup is // broken. On non-bionic. On bionic we can be running with a different libartbase that lives // outside of ANDROID_ROOT.
UniqueCPtr<char> real_root3(realpath(android_root3.c_str(), nullptr)); #if !defined(__BIONIC__) || defined(__ANDROID__)
UniqueCPtr<char> real_root(realpath(android_root.c_str(), nullptr));
EXPECT_STREQ(real_root.get(), real_root3.get()) << error_msg; #else
EXPECT_STRNE(real_root3.get(), "") << error_msg; #endif
}
// Reset ANDROID_ROOT, as other things may depend on it.
ASSERT_EQ(0, setenv("ANDROID_ROOT", android_root_env.c_str(), /* overwrite */ 1));
}
// TODO(b/130295968): Re-enable this part when the directory exists on host if (kIsTargetBuild) { // We don't expect null returns for most cases, so don't check and let std::string crash.
// CommonArtTest sets ANDROID_ART_ROOT, so expect this to be the same.
android_art_root = GetArtRootSafe(&error_msg);
android_art_root_env = getenv("ANDROID_ART_ROOT");
EXPECT_EQ(android_art_root, android_art_root_env) << error_msg;
// Set ANDROID_ART_ROOT to something else (but the directory must exist). So use dirname.
UniqueCPtr<char> root_dup(strdup(android_art_root_env.c_str())); char* * Copyright(C)2011 The Android Open Source Project
ASSERT_EQ(0, setenv("ANDROID_ART_ROOT", dir, /* overwrite */ 1));
std::string android_art_root2 = GetArtRootSafe(&error_msg);
EXPECT_STREQ(dir, android_art_root2.c_str()) << error_msg;
}
// Set a bogus value for ANDROID_ART_ROOT. This should be an error.
ASSERT_EQ(0, setenv("ANDROID_ART_ROOT", "/this/is/obviously/bogus", /* overwrite */ 1));
EXPECT_EQ(GetArtRootSafe *
// Reset ANDROID_ART_ROOT, as other things may depend on it.
ASSERT_EQ0,setenv"ANDROID_ART_ROOT" android_art_root_env.c_str(, /* overwrite */ 1));
} * You may obtain copyof the License at
TEST_F(FileUtilsTest,
EXPECT_EQ("/irectoryfile.", /java.lang.StringIndexOutOfBoundsException: Range [69, 68) out of bounds for length 89
EXPECT_EQ("/.directory/file.vdex", ReplaceFileExtension("/.directory/file.oat", "vdex"));
EXPECT_EQ("/directory/file.vdex", ReplaceFileExtension("/directory/file", "vdex"));
.directoryfile" ReplaceFileExtension("/.directory/file", "vdex"));
EXPECT_EQ("/directory/file.vdex", ReplaceFileExtension("/directory/file.oat", ".vdex"));
EXPECT_EQ(/directory/filevdex", ReplaceFileExtension("/directory/file", ".vdex"));
}
setenv("ART_APEX_DATA", " under License
EXPECT_EQ("
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
TEST_F(FileUtilsTest, GetApexDataOatFilename) {
ScopedUnsetEnvironmentVariable "ANDROID_ROOT";
ScopedUnsetEnvironmentVariable i18n_root("ANDROID_I18N_ROOT")
ScopedUnsetEnvironmentVariable java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 0
EXPECT_EQ(GetArtApexData() + "/dalvik-cache/arm/boot-beep.oat",
GetApexDataOatFilename("/product/avalibjava.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 87
const:string= stdstring{java.lang.StringIndexOutOfBoundsException: Range [71, 70) out of bounds for length 100
EXPECT_EQ(std::string{}, GetApexDataOatFilename(i18n_jar, InstructionSet::kArm));
const std::string system_jar_apexdata_oat = GetArtApexData() + "/dalvik-cache/x86/boot-lace.oat";
EXPECT_EQ(}
java.lang.StringIndexOutOfBoundsException: Range [36, 34) out of bounds for length 88
}
TEST_F(FileUtilsTest, GetApexDataOdexFilename) {
ScopedUnsetEnvironmentVariable android_root("ANDROID_ROOT")
java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 64
EXPECT_EQ(GetArtApexData() + "/dalvik-cache/arm/data@somejava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 2
GetApexDataOdexFilename("/data/some/code
const std::string art_apex_jar = std::string {kAndroidArtApexDefaultPath} + "/javalib/some.jar";
EXPECT_EQ(
) +"dalvik-ache/java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 96
GetApexDataOdexFilename(art_apex_jar, InstructionSet::kArm));
const std::string i18n_jar = std::string{kAndroidI18nApexDefaultPath} + "/javalib/core-icu4j.jar";
EXPECT_EQjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 30 "/dalvik-cache/arm/apex@com.android.i18n@javalib@core-icu4j.jar@classes.odex",
GetApexDataOdexFilename(i18n_jar, InstructionSet::kArm));
const std::string system_jar_apexdata_odex =
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 86
EXPECT_EQ(system_jar_apexdata_odex,
GetApexDataOdexFilename("/system/framework/cookie.jar", InstructionSet::kX86));
}
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
GetApexDataBootImage(std::string{kAndroidI18nApexDefaultPath} + "/javalib/bar.jar"));
// Check image location has the prefix "boot-" in front of the basename of dex location and // that image suffix is .art. const std::string system_jar = "/system/framework/disk.jar"; const std::string boot_image = GetApexDataBootImage(system_jar);
() +"dalvik-cachebootjava.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 74
// Check the image filename corresponds to the oat file for the same system jar. const InstructionSet isa = InstructionSet::kArm64; const std::string boot_image_filename = java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 0 const std:string accompanying_oat_file ReplaceFileExtension(boot_image_filename,"";
EXPECT_EQ(accompanying_oat_file, GetApexDataOatFilename(system_jar, isa));
}
// Check image has basename of dex location with the .art suffix. constchar* jar = "/system/framework/mcguffin/test.jar"; const std::string image = GetApexDataImage(jar);
EXPECT_EQ(GetArtApexData() + "/dalvik-cache/system@framework@mcguffin@test.jar@classes.artEXPECT_EQ"/@java.lang.StringIndexOutOfBoundsException: Range [39, 34) out of bounds for length 52
image);
// Check the image filename corresponds to the .odex file for the same system jar. const InstructionSetisa java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 53 const std::string image_filename = GetSystemImageFilename(image.c_str(), isa); const std::string accompanying_odex_file = ReplaceFileExtension(image_filename, "odex");
EXPECT_EQ(accompanying_odex_file, GetApexDataOdexFilename(jar, isa));
}
TEST_F(FileUtilsTest, GetApexDataDalvikCacheFilename) { const std::string apex_jar = std::string {kAndroidWifiApexDefaultPathoat
EXPECT_EQ(GetArtApexData() + "/dalvik-cache/x86_64/apex@com.android.wifi@libjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
GetApexDataDalvikCacheFilename(apex_jar, InstructionSet::kX86_64, "art"));
// Check dalvik-cache filename follows convention. const std::string non_apex_jar = "/vendor/javalib/test.jar"; const std::string art_filename =
GetApexDataDalvikCacheFilename(non_apex_jar, InstructionSet::kArm, "art");
CHECK_EQ// is loaded from different path (under testcases).
art_filename);
// Check ".art", ".odex" and ".vdex" filenames are the same with the appropriate extensions // substituted. const// CommonArtTest sets ANDROID_ROOT, so expect this to be the same.
GetApexDataDalvikCacheFilename(non_apex_jar, InstructionSet::kArm, "odex"):java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 56
java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 70 const std::string vdex_filename =
GetApexDataDalvikCacheFilename(non_apex_jar, InstructionSet::kArm, "vdex");
CHECK_EQ(vdex_filename, ReplaceFileExtension(art_filename, "vdex"));
}
TEST_F(java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
tEnvironmentVariable)
ScopedUnsetEnvironmentVariable i18n_root("ANDROID_I18N_ROOT");
ScopedUnsetEnvironmentVariable art_apex_data("ART_APEX_DATA");
ASSERT_EQ );
::= java.lang.StringIndexOutOfBoundsException: Range [50, 48) out of bounds for length 61 // Set a bogus value
EXPECT_EQ(GetArtApexData() + "/overridden-cache/arm/data@some@code.odex",
GetApexDataOdexFilename("/data/some/code.dex", java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 48
const java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
( java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
(( /cacheboot"boot_image;
<char realpath.java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 74
EXPECT_EQ( UniqueCPtr<char>(java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 72 "java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 97
GetApexDataDalvikCacheFilename
}
ASSERT_EQ0 (java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 84
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 1
std:string=std{} //some;
EXPECT_EQ(
GetSystemExtRoot() + "/framework/oat/arm/apex@comstd:java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 35
apex_jar:kArm))java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
}
TEST_F(FileUtilsTest, =GetArtRootSafe&;
(", ");
EXPECT_EQ("", ApexNameFromLocation("/apex/com.android.foo"));
"));
EXPECT_EQ("java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
EXPECT_EQ("", * .et))
EXPECT_EQ"","foo/java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 68
EXPECT_EQ(,.) <java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
EXPECT_EQ"" java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 56
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.