Bug 557225 - Fix TryServer failures. r=cjones r=josh

This commit is contained in:
Benoit Girard 2010-07-20 00:17:45 -04:00
parent d5759eca95
commit 5d68779104
2 changed files with 51 additions and 5 deletions

View File

@ -49,15 +49,43 @@ bool LaunchApp(const std::vector<std::string>& argv,
SetAllFDsToCloseOnExec();
#if defined(CHROMIUM_MOZILLA_BUILD)
for (environment_map::const_iterator it = env_vars_to_set.begin();
it != env_vars_to_set.end(); ++it) {
if (setenv(it->first.c_str(), it->second.c_str(), 1/*overwrite*/))
exit(127);
// Copy _NSGetEnviron() to a new char array and add the variables
// in env_vars_to_set.
// Existing variables are overwritten by env_vars_to_set.
int pos = 0;
environment_map combined_env_vars = env_vars_to_set;
while((*_NSGetEnviron())[pos] != NULL) {
std::string varString = (*_NSGetEnviron())[pos];
std::string varName = varString.substr(0, varString.find_first_of('='));
std::string varValue = varString.substr(varString.find_first_of('=') + 1);
if (combined_env_vars.find(varName) == combined_env_vars.end()) {
combined_env_vars[varName] = varValue;
}
pos++;
}
int varsLen = combined_env_vars.size() + 1;
char** vars = new char*[varsLen];
int i = 0;
for (environment_map::const_iterator it = combined_env_vars.begin();
it != combined_env_vars.end(); ++it) {
std::string entry(it->first);
entry += "=";
entry += it->second;
vars[i] = strdup(entry.c_str());
i++;
}
vars[i] = NULL;
#endif
posix_spawn_file_actions_t file_actions;
if (posix_spawn_file_actions_init(&file_actions) != 0) {
#if defined(CHROMIUM_MOZILLA_BUILD)
for(int j = 0; j < varsLen; j++) {
free(vars[j]);
}
delete[] vars;
#endif
return false;
}
@ -77,18 +105,36 @@ bool LaunchApp(const std::vector<std::string>& argv,
if (posix_spawn_file_actions_adddup2(&file_actions, src_fd, dest_fd) != 0)
{
posix_spawn_file_actions_destroy(&file_actions);
#if defined(CHROMIUM_MOZILLA_BUILD)
for(int j = 0; j < varsLen; j++) {
free(vars[j]);
}
delete[] vars;
#endif
return false;
}
}
}
int pid = 0;
int spawn_succeeded = (posix_spawnp(&pid,
argv_copy[0],
&file_actions,
NULL,
argv_copy,
#if defined(CHROMIUM_MOZILLA_BUILD)
vars) == 0);
#else
*_NSGetEnviron()) == 0);
#endif
#if defined(CHROMIUM_MOZILLA_BUILD)
for(int j = 0; j < varsLen; j++) {
free(vars[j]);
}
delete[] vars;
#endif
posix_spawn_file_actions_destroy(&file_actions);

View File

@ -160,7 +160,7 @@ class XPCShellTests(object):
elif sys.platform in ('os2emx', 'os2knix'):
os.environ["BEGINLIBPATH"] = self.xrePath + ";" + self.env["BEGINLIBPATH"]
os.environ["LIBPATHSTRICT"] = "T"
elif sys.platform == 'osx':
elif sys.platform == 'osx' or sys.platform == "darwin":
self.env["DYLD_LIBRARY_PATH"] = self.xrePath
else: # unix or linux?
self.env["LD_LIBRARY_PATH"] = self.xrePath