| 258 | } |
| 259 | |
| 260 | void SC::ProcessTest::processChainPipeDual() |
| 261 | { |
| 262 | //! [processChainPipeDualSnippet] |
| 263 | // Chain two processes and read the last stdout into a String (using a pipe) |
| 264 | ProcessChain chain; |
| 265 | |
| 266 | String output(StringEncoding::Ascii); |
| 267 | Process p1, p2; |
| 268 | |
| 269 | StringView expectedOutput; |
| 270 | switch (HostPlatform) |
| 271 | { |
| 272 | case Platform::Windows: { |
| 273 | expectedOutput = "WHERE [/R dir] [/Q] [/F] [/T] pattern...\r\n"; |
| 274 | SC_TEST_EXPECT(chain.pipe(p1, {"where", "/?"})); |
| 275 | SC_TEST_EXPECT(chain.pipe(p2, {"findstr", "dir]"})); |
| 276 | } |
| 277 | break; |
| 278 | default: { // Posix |
| 279 | expectedOutput = "sbin\n"; |
| 280 | SC_TEST_EXPECT(chain.pipe(p1, {"ls", "/"})); |
| 281 | SC_TEST_EXPECT(chain.pipe(p2, {"grep", "sbin"})); |
| 282 | } |
| 283 | break; |
| 284 | } |
| 285 | PipeOptions pipeOptions; |
| 286 | pipeOptions.writeInheritable = true; // This is correct but not strictly necessary... |
| 287 | PipeDescriptor outputPipe; |
| 288 | SC_TEST_EXPECT(outputPipe.createPipe(pipeOptions)); |
| 289 | SC_TEST_EXPECT(chain.launch(outputPipe)); |
| 290 | SC_TEST_EXPECT(outputPipe.readPipe.readUntilEOF(output)); |
| 291 | SC_TEST_EXPECT(chain.waitForExitSync()); |
| 292 | SC_TEST_EXPECT(StringView(output.view()).startsWith(expectedOutput)); |
| 293 | //! [processChainPipeDualSnippet] |
| 294 | } |
| 295 | |
| 296 | // This section is not executed as a test, but explicitly executed in a child process by some tests below |
| 297 | void SC::ProcessTest::processEnvironmentPrint() |
nothing calls this directly
no test coverage detected