| 77 | } |
| 78 | |
| 79 | int TestProcess(int argc, char* argv[]) |
| 80 | { |
| 81 | // This is here to avoid false leak messages from vtkDebugLeaks when |
| 82 | // using mpich. It appears that the root process which spawns all the |
| 83 | // main processes waits in MPI_Init() and calls exit() when |
| 84 | // the others are done, causing apparent memory leaks for any objects |
| 85 | // created before MPI_Init(). |
| 86 | MPI_Init(&argc, &argv); |
| 87 | |
| 88 | // Note that this will create a vtkMPIController if MPI |
| 89 | // is configured, vtkThreadedController otherwise. |
| 90 | vtkMPIController* c = vtkMPIController::New(); |
| 91 | c->Initialize(&argc, &argv, 1); |
| 92 | |
| 93 | int retVal = 1; |
| 94 | |
| 95 | vtkMultiProcessController::SetGlobalController(c); |
| 96 | |
| 97 | int numProcs = c->GetNumberOfProcesses(); |
| 98 | int me = c->GetLocalProcessId(); |
| 99 | |
| 100 | if (numProcs != 2) |
| 101 | { |
| 102 | if (me == 0) |
| 103 | { |
| 104 | std::cout << "DistributedData test requires 2 processes" << std::endl; |
| 105 | } |
| 106 | c->Delete(); |
| 107 | return retVal; |
| 108 | } |
| 109 | |
| 110 | if (!c->IsA("vtkMPIController")) |
| 111 | { |
| 112 | if (me == 0) |
| 113 | { |
| 114 | std::cout << "TestProcess test requires MPI" << std::endl; |
| 115 | } |
| 116 | c->Delete(); |
| 117 | return retVal; |
| 118 | } |
| 119 | |
| 120 | MyProcess* p = MyProcess::New(); |
| 121 | p->SetArgs(argc, argv); |
| 122 | |
| 123 | c->SetSingleProcessObject(p); |
| 124 | c->SingleMethodExecute(); |
| 125 | |
| 126 | retVal = p->GetReturnValue(); |
| 127 | |
| 128 | p->Delete(); |
| 129 | c->Finalize(); |
| 130 | c->Delete(); |
| 131 | |
| 132 | return retVal; |
| 133 | } |
nothing calls this directly
no test coverage detected