// Helper class that removes an environment variable whilst in scope. class ScopedUnsetEnvironmentVariable { public: explicit ScopedUnsetEnvironmentVariable(constchar* variable)
: variable_{variable}, old_value_{GetOldValue(variable)} {
unsetenv(variable);
}
~ScopedUnsetEnvironmentVariable() { if (old_value_.has_value()) { static constexpr int kReplace = 1; // tidy-issue: replace argument has libc dependent name.
setenv(variable_, old_value_.value().c_str(), kReplace);
} else {
unsetenv(variable_);
}
}
private: static std::optional<std::string> GetOldValue(constchar* variable) { constchar* value = getenv(variable); return value != nullptr ? std::optional<std::string>{value} : std::nullopt;
}
// Temporarily drops all root capabilities when the test is run as root. This is a noop otherwise.
android::base::ScopeGuard<std::function<void()>> ScopedUnroot();
// Temporarily drops all permissions on a file/directory.
android::base::ScopeGuard<std::function<void()>> ScopedInaccessible(const std::string& path);
// Set up ANDROID_BUILD_TOP, ANDROID_HOST_OUT, ANDROID_ROOT, ANDROID_I18N_ROOT, // ANDROID_ART_ROOT, and ANDROID_TZDATA_ROOT environment variables using sensible defaults // if not already set. staticvoid SetUpAndroidRootEnvVars();
// Set up the ANDROID_DATA environment variable, creating the directory if required. // Note: setting up ANDROID_DATA may create a temporary directory. If this is used in a // non-derived class, be sure to also call the corresponding tear-down below. staticvoid SetUpAndroidDataDir(std::string& android_data);
// Get the names of the libcore modules. virtual std::vector<std::string> GetLibCoreModuleNames() const;
// Gets the paths of the libcore dex files for given modules.
std::vector<std::string> GetLibCoreDexFileNames(const std::vector<std::string>& modules) const { return art::testing::GetLibCoreDexFileNames(modules);
}
// Gets the paths of the libcore dex files.
std::vector<std::string> GetLibCoreDexFileNames() const { return GetLibCoreDexFileNames(GetLibCoreModuleNames());
}
// Gets the on-host or on-device locations of the libcore dex files for given modules.
std::vector<std::string> GetLibCoreDexLocations(const std::vector<std::string>& modules) const { return art::testing::GetLibCoreDexLocations(modules);
}
// Gets the on-host or on-device locations of the libcore dex files.
std::vector<std::string> GetLibCoreDexLocations() const { return GetLibCoreDexLocations(GetLibCoreModuleNames());
}
// Creates the class path string for the given dex files (the list of dex file locations // separated by ':').
std::string CreateClassPath(const std::vector<std::unique_ptr<const DexFile>>& dex_files); // Same as CreateClassPath but add the dex file checksum after each location. The separator // is '*'.
std::string CreateClassPathWithChecksums( const std::vector<std::unique_ptr<const DexFile>>& dex_files);
using CommonArtTest = CommonArtTestBase<::testing::Test>;
template <typename Param> using CommonArtTestWithParam = CommonArtTestBase<::testing::TestWithParam<Param>>;
// Returns a list of PIDs of the processes whose process name (the first commandline argument) fully // matches the given name.
std::vector<pid_t> GetPidByName(const std::string& process_name);
#define TEST_DISABLED_FOR_TARGET() \ if (art::kIsTargetBuild) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR TARGET"; \
}
#define TEST_DISABLED_FOR_HOST() \ if (!art::kIsTargetBuild) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR HOST"; \
}
#define TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS() \ if (!art::kHostStaticBuildEnabled) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR NON-STATIC HOST BUILDS"; \
}
#define TEST_DISABLED_FOR_DEBUG_BUILD() \ if (art::kIsDebugBuild) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR DEBUG BUILD"; \
}
#define TEST_DISABLED_FOR_MEMORY_TOOL() \ if (art::kRunningOnMemoryTool) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR MEMORY TOOL"; \
}
#define TEST_DISABLED_FOR_HEAP_POISONING() \ if (art::kPoisonHeapReferences) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR HEAP POISONING"; \
}
} // namespace art
#define TEST_DISABLED_FOR_MEMORY_TOOL_WITH_HEAP_POISONING() \ if (art::kRunningOnMemoryTool && art::kPoisonHeapReferences) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR MEMORY TOOL WITH HEAP POISONING"; \
}
#define TEST_DISABLED_FOR_USER_BUILD() \ if (std::string build_type = android::base::GetProperty("ro.build.type", ""); \
art::kIsTargetBuild && build_type != "userdebug" && build_type != "eng") { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR USER BUILD"; \
}
#endif// ART_LIBARTBASE_BASE_COMMON_ART_TEST_H_
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-29)
¤
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.