forked from OSchip/llvm-project
Provide more information when process launch can't change directory to the
path passed with -w Test this functionality. llvm-svn: 160130
This commit is contained in:
parent
fdce33a495
commit
0c251adf75
|
@ -1532,7 +1532,16 @@ LaunchProcessPosixSpawn (const char *exe_path, ProcessLaunchInfo &launch_info, :
|
|||
if (working_dir)
|
||||
{
|
||||
// No more thread specific current working directory
|
||||
__pthread_chdir (working_dir);
|
||||
if (__pthread_chdir (working_dir) < 0) {
|
||||
if (errno == ENOENT) {
|
||||
error.SetErrorStringWithFormat("No such file or directory: %s", working_dir);
|
||||
} else if (errno == ENOTDIR) {
|
||||
error.SetErrorStringWithFormat("Path doesn't name a directory: %s", working_dir);
|
||||
} else {
|
||||
error.SetErrorStringWithFormat("An unknown error occurred when changing directory for process execution.");
|
||||
}
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
const size_t num_file_actions = launch_info.GetNumFileActions ();
|
||||
|
|
|
@ -48,7 +48,7 @@ class ProcessLaunchTestCase(TestBase):
|
|||
pass
|
||||
|
||||
launch_command = "process launch -i " + in_file + " -o " + out_file + " -e " + err_file
|
||||
|
||||
|
||||
self.expect (launch_command,
|
||||
patterns = [ "Process .* launched: .*a.out" ])
|
||||
|
||||
|
@ -69,7 +69,7 @@ class ProcessLaunchTestCase(TestBase):
|
|||
success = False
|
||||
err_msg = err_msg + " ERROR: stdout file does not contain correct output.\n"
|
||||
out_f.close();
|
||||
|
||||
|
||||
# Try to delete the 'stdout' file
|
||||
try:
|
||||
os.remove (out_file)
|
||||
|
@ -139,6 +139,15 @@ class ProcessLaunchTestCase(TestBase):
|
|||
except OSError:
|
||||
pass
|
||||
|
||||
# Check that we get an error when we have a nonexisting path
|
||||
launch_command = "process launch -w %s -o %s -e %s" % (my_working_dir_path + 'z',
|
||||
out_file_path,
|
||||
err_file_path)
|
||||
|
||||
self.expect(launch_command, error=True,
|
||||
startstr = "error: No such file or directory: %sz" % my_working_dir_path)
|
||||
|
||||
# Really launch the process
|
||||
launch_command = "process launch -w %s -o %s -e %s" % (my_working_dir_path,
|
||||
out_file_path,
|
||||
err_file_path)
|
||||
|
@ -164,7 +173,7 @@ class ProcessLaunchTestCase(TestBase):
|
|||
success = False
|
||||
err_msg = err_msg + "The current working directory was not set correctly.\n"
|
||||
out_f.close();
|
||||
|
||||
|
||||
# Try to delete the 'stdout' and 'stderr' files
|
||||
try:
|
||||
os.remove(out_file_path)
|
||||
|
|
Loading…
Reference in New Issue