Bug 1318091 - Support env override of gtest minidump location; r=Ehsan

Desktop gtest creates minidumps in the current working directory. That is
problematic on Android, since the test app's cwd may not be writable, or
may not be readable by the test harness. This patch allows the test harness
to specify an alternate minidump path with environment variable
MOZ_GTEST_MINIDUMPS_PATH.

Differential Revision: https://phabricator.services.mozilla.com/D26833

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Geoff Brown 2019-04-11 01:25:02 +00:00
Родитель 6a3953940b
Коммит a6180a6479
1 изменённых файлов: 18 добавлений и 9 удалений

Просмотреть файл

@ -121,16 +121,25 @@ int RunGTestFunc(int* argc, char** argv) {
// C++ unittests
crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1");
if (crashreporter) {
std::cerr << "Setting up crash reporting" << std::endl;
nsCOMPtr<nsIProperties> dirsvc =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
nsCOMPtr<nsIFile> cwd;
nsresult rv = dirsvc->Get(NS_OS_CURRENT_WORKING_DIR, NS_GET_IID(nsIFile),
getter_AddRefs(cwd));
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
printf_stderr("Setting up crash reporting\n");
char* path = PR_GetEnv("MOZ_GTEST_MINIDUMPS_PATH");
nsCOMPtr<nsIFile> file;
if (path) {
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), true,
getter_AddRefs(file));
if (NS_FAILED(rv)) {
printf_stderr("Ignoring invalid MOZ_GTEST_MINIDUMPS_PATH\n");
}
}
if (!file) {
nsCOMPtr<nsIProperties> dirsvc =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
nsresult rv = dirsvc->Get(NS_OS_CURRENT_WORKING_DIR, NS_GET_IID(nsIFile),
getter_AddRefs(file));
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
}
crashreporter->SetEnabled(true);
crashreporter->SetMinidumpPath(cwd);
crashreporter->SetMinidumpPath(file);
}
}