class TestToolProcess

Defined at line 32 of file ../../src/lib/zxdump/test-tool-process.h

This manages a command-line tool process to be run in a sandbox (on Fuchsia)

or from the build directory (on other hosts) with specified input and output

files and fully captured stdin/stdout/stderr.

Public Methods

void TestToolProcess (const TestToolProcess & )

Defined at line 83 of file ../../src/lib/zxdump/test-tool-process.h

void TestToolProcess (TestToolProcess && )

Defined at line 84 of file ../../src/lib/zxdump/test-tool-process.h

void TestToolProcess ()

Defined at line 335 of file ../../src/lib/zxdump/test-tool-process.cc

void ~TestToolProcess ()

Defined at line 350 of file ../../src/lib/zxdump/test-tool-process.cc

void Init ()

This creates a new isolated tmp directory.

Defined at line 337 of file ../../src/lib/zxdump/test-tool-process.cc

void Init (std::string_view tmp_path)

This uses an existing tmp directory shared with another TestToolProcess.

Defined at line 348 of file ../../src/lib/zxdump/test-tool-process.cc

File & MakeFile (std::string_view name, std::string_view suffix)

Return a file name that can be passed to the tool via its Start arguments.

The file name will include the given name string for debugging purposes,

but will be unique among all MakeFileName calls on this TestToolProcess.

It will always end with the precise suffix given, if any. Whether these

are input files the test code writes for the tool to read, or output files

the tool writes and the test code checks afterwards, they will be cleaned

up when the TestToolProcess object is destroyed.

Defined at line 436 of file ../../src/lib/zxdump/test-tool-process.cc

std::string FilePathForRunner (const File & file)

Return the name to access the file in this test program.

Defined at line 99 of file ../../src/lib/zxdump/test-tool-process.cc

std::string FilePathForTool (const File & file)

Return the name to access the file in the child tool program.

Defined at line 83 of file ../../src/lib/zxdump/test-tool-process.cc

fbl::unique_fd & tool_stdin ()

These give separate pipe ends to write to the tool's stdin or read from

its stdout or stderr. After Start, these can be reset to close the pipe

so the tool under test sees EOF or EPIPE. Before Start, these can be set

to redirect the tool to use another fd; then Start will not make a pipe.

Defined at line 122 of file ../../src/lib/zxdump/test-tool-process.h

fbl::unique_fd & tool_stdout ()

Defined at line 123 of file ../../src/lib/zxdump/test-tool-process.h

fbl::unique_fd & tool_stderr ()

Defined at line 124 of file ../../src/lib/zxdump/test-tool-process.h

const std::string & tmp_path ()

Defined at line 139 of file ../../src/lib/zxdump/test-tool-process.h

void set_job (zx::unowned_job job)

Defined at line 142 of file ../../src/lib/zxdump/test-tool-process.h

void set_resource (zx::unowned_resource resource)

Defined at line 144 of file ../../src/lib/zxdump/test-tool-process.h

void Start (const std::string & tool, const std::vector<std::string> & args)

Start the tool running. This throws gtest assertions for problems. The

tool name is "gcore" or the like, and is found in the appropriate place.

Defined at line 285 of file ../../src/lib/zxdump/test-tool-process.cc

void Finish (int & exit_status)

Wait for the tool to finish and yield what it passed to exit(). This uses

a negative synthetic exit code if the tool process crashed and throws

gtest assertions for unexpected problems aside from the process dying.

Defined at line 317 of file ../../src/lib/zxdump/test-tool-process.cc

void SendStdin (std::string contents)

This spawns a worker thread to feed the contents into the tool's stdin.

It resets tool_stdin() and moves ownership of the pipe end to the worker.

Defined at line 395 of file ../../src/lib/zxdump/test-tool-process.cc

void CollectStdout ()

These spawn worker threads that take ownership of the tool_stdin() or

tool_stdout() pipe and collect everything written into memory until Finish

returns. Then collected_stdout() and collected_stderr() return them.

Defined at line 402 of file ../../src/lib/zxdump/test-tool-process.cc

void CollectStderr ()

Defined at line 408 of file ../../src/lib/zxdump/test-tool-process.cc

std::string collected_stdout ()

Defined at line 414 of file ../../src/lib/zxdump/test-tool-process.cc

std::string collected_stderr ()

Defined at line 425 of file ../../src/lib/zxdump/test-tool-process.cc

Records