-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Support: Fix program error test failures when using fork #129252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support: Fix program error test failures when using fork #129252
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-llvm-support Author: Matt Arsenault (arsenm) ChangesThe actual exec error will not be immediate in the parent when I hacked up the exit value ExecutionFailed value in ExecuteAndWait, Fixes #129208 Full diff: https://github.com/llvm/llvm-project/pull/129252.diff 2 Files Affected:
diff --git a/llvm/lib/Support/Program.cpp b/llvm/lib/Support/Program.cpp
index 181f68cfbb8c3..c8208e4be3175 100644
--- a/llvm/lib/Support/Program.cpp
+++ b/llvm/lib/Support/Program.cpp
@@ -45,6 +45,10 @@ int sys::ExecuteAndWait(StringRef Program, ArrayRef<StringRef> Args,
ProcessInfo Result = Wait(
PI, SecondsToWait == 0 ? std::nullopt : std::optional(SecondsToWait),
ErrMsg, ProcStat);
+
+ if (ExecutionFailed && Result.ReturnCode < 0)
+ *ExecutionFailed = true;
+
return Result.ReturnCode;
}
diff --git a/llvm/unittests/Support/ProgramTest.cpp b/llvm/unittests/Support/ProgramTest.cpp
index 47d2e269afe94..ccb154f7fab1a 100644
--- a/llvm/unittests/Support/ProgramTest.cpp
+++ b/llvm/unittests/Support/ProgramTest.cpp
@@ -433,10 +433,19 @@ TEST(ProgramTest, TestExecuteNegative) {
bool ExecutionFailed;
ProcessInfo PI = ExecuteNoWait(Executable, argv, std::nullopt, {}, 0,
&Error, &ExecutionFailed);
- EXPECT_EQ(PI.Pid, ProcessInfo::InvalidPid)
- << "On error ExecuteNoWait should return an invalid ProcessInfo";
- EXPECT_TRUE(ExecutionFailed);
- EXPECT_FALSE(Error.empty());
+
+ if (ExecutionFailed) {
+ EXPECT_EQ(PI.Pid, ProcessInfo::InvalidPid)
+ << "On error ExecuteNoWait should return an invalid ProcessInfo";
+ EXPECT_FALSE(Error.empty());
+ } else {
+ std::string WaitErrMsg;
+ EXPECT_NE(PI.Pid, ProcessInfo::InvalidPid);
+ ProcessInfo WaitPI = Wait(PI, std::nullopt, &WaitErrMsg);
+ EXPECT_EQ(WaitPI.Pid, PI.Pid);
+ EXPECT_LT(WaitPI.ReturnCode, 0);
+ EXPECT_FALSE(WaitErrMsg.empty());
+ }
}
}
|
47533d0
to
bc18c29
Compare
I also feel that the current behavior is better. When we have |
7b31093
to
acaac0b
Compare
The actual exec error will not be immediate in the parent when using the fork path. The error will manifest on the wait. The ExecuteNoWait test was also expecting the immediate wait. I hacked up the exit value ExecutionFailed value in ExecuteAndWait, although arguably the previous behavior was correct. I'm not sure what the point of the argument is, it's redundant with the return code. Fixes #129208
acaac0b
to
30daa7a
Compare
Hi @arsenm, are you planning to merge the fix soon, or would it be better to disable the test in our local testing for now? |
The actual exec error will not be immediate in the parent when
using the fork path. The error will manifest on the wait. The
ExecuteNoWait test was also expecting the immediate wait.
Remove the check in the AndWait test check for ExecutionFailed.
The execution did succeed in some sense.
Fixes #129208