MCPcopy Create free account
hub / github.com/Kitware/VTK / RunTestCase

Function RunTestCase

Parallel/MPI/Testing/Cxx/TestPExecutableRunner.cxx:15–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13{
14
15bool RunTestCase(vtkMPIController* controller, const std::string& command,
16 std::optional<int> commandProcessId, const std::vector<std::string>& expectedResults)
17{
18 if (expectedResults.size() != (size_t)controller->GetNumberOfProcesses())
19 {
20 vtkLogF(ERROR,
21 "ExpectedResults vector should have %i elements, but its number of elements is %i",
22 controller->GetNumberOfProcesses(), (int)expectedResults.size());
23 return false;
24 }
25
26 int localProcessId = controller->GetLocalProcessId();
27
28 vtkNew<vtkPExecutableRunner> executableRunner;
29 executableRunner->SetExecutionProcessId(commandProcessId.value_or(-1));
30 executableRunner->SetCommand(command.c_str());
31 executableRunner->Execute();
32
33 int returnValue = executableRunner->GetReturnValue();
34 if (returnValue > 0)
35 {
36 vtkLogF(ERROR, "Error when executing command: %s.", executableRunner->GetStdErr());
37 return false;
38 }
39
40 std::string commandResult = executableRunner->GetStdOut();
41 const std::string& expectedResult = expectedResults[static_cast<size_t>(localProcessId)];
42 // Verify that the command result is the expected one
43 if (commandResult != expectedResult)
44 {
45 vtkLogF(ERROR, "Expected %s command result but got %s.",
46 expectedResult.empty() ? "[empty]" : expectedResult.c_str(), commandResult.c_str());
47 return false;
48 }
49
50 return true;
51}
52
53}
54

Callers 1

TestPExecutableRunnerFunction · 0.85

Calls 7

GetNumberOfProcessesMethod · 0.80
GetReturnValueMethod · 0.80
sizeMethod · 0.45
GetLocalProcessIdMethod · 0.45
c_strMethod · 0.45
ExecuteMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected