diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2025-03-05 18:46:38 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-05 18:46:38 +0700 |
commit | e1c9c842cb43a9a264ba442fb6c87d95ebc6d8e2 (patch) | |
tree | 2e9dfaf7f83f135c1b674c4bff044c061925bed9 /llvm/unittests/Support | |
parent | 53c157939e5ac9acc8e1f8853325a021bc925501 (diff) | |
download | llvm-e1c9c842cb43a9a264ba442fb6c87d95ebc6d8e2.zip llvm-e1c9c842cb43a9a264ba442fb6c87d95ebc6d8e2.tar.gz llvm-e1c9c842cb43a9a264ba442fb6c87d95ebc6d8e2.tar.bz2 |
Support: Fix program error test failures when using fork (#129252)
Diffstat (limited to 'llvm/unittests/Support')
-rw-r--r-- | llvm/unittests/Support/ProgramTest.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/llvm/unittests/Support/ProgramTest.cpp b/llvm/unittests/Support/ProgramTest.cpp index 47d2e26..693b53b 100644 --- a/llvm/unittests/Support/ProgramTest.cpp +++ b/llvm/unittests/Support/ProgramTest.cpp @@ -422,10 +422,13 @@ TEST(ProgramTest, TestExecuteNegative) { bool ExecutionFailed; int RetCode = ExecuteAndWait(Executable, argv, std::nullopt, {}, 0, 0, &Error, &ExecutionFailed); + EXPECT_LT(RetCode, 0) << "On error ExecuteAndWait should return 0 or " "positive value indicating the result code"; - EXPECT_TRUE(ExecutionFailed); EXPECT_FALSE(Error.empty()); + + // Note ExecutionFailed may or may not be false. When using fork, the error + // is produced on the wait for the child, not the execution point. } { @@ -433,10 +436,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()); + } } } |