crashpad::test::TestPaths Class Reference

Functions to obtain paths from within tests. More...

`#include "test/test_paths.h"`

## Public Types

enum | FileType
| The type of file requested of BuildArtifact(). More...
enum | Architecture
| The architecture of the file requested of BuildArtifact(). More...

## Public Member Functions

| DISALLOW_IMPLICIT_CONSTRUCTORS (TestPaths)

## Static Public Member Functions

static base::FilePath | Executable ()
| Returns the pathname of the currently-running test executable. More...
static base::FilePath | ExpectedExecutableBasename (const base::FilePath::StringType &name)
| Returns the expected basename of the currently-running test executable. More...
static base::FilePath | TestDataRoot ()
| Returns the pathname of the test data root. More...
static base::FilePath | BuildArtifact (const base::FilePath::StringType &module, const base::FilePath::StringType &artifact, FileType file_type, Architecture architecture=Architecture::kDefault)
| Returns the pathname of a build artifact. More...
static bool | Has32BitBuildArtifacts ()

## Detailed Description

Functions to obtain paths from within tests.

## Member Enumeration Documentation

## Architecture

enum crashpad::test::TestPaths::Architecture

strong

The architecture of the file requested of BuildArtifact().

Enumerator
kDefault | The default architecture is requested. This is usually the same architecture as the running process.
k32Bit | The 32-bit variant is requested. On Windows, when running 64-bit code, the 32-bit variant can be requested. Before doing so, Has32BitBuildArtifacts() must be called and must return `true`. Otherwise, execution will be aborted.

## FileType

enum crashpad::test::TestPaths::FileType

strong

The type of file requested of BuildArtifact().

This is used to establish the file extension used by the returned path.

Enumerator
kNone | No file extension is requested.
kExecutable | `.exe` will be used on Windows, and no file extension will be used on other platforms.
kLoadableModule | `.dll` will be used on Windows, and `.so` will be used on other platforms.
kCertificate | `.pem` used for all platforms.

## Member Function Documentation

## BuildArtifact()

base::FilePath crashpad::test::TestPaths::BuildArtifact | ( | const base::FilePath::StringType & | module,
|  | const base::FilePath::StringType & | artifact,
|  | FileType | file_type,
|  | Architecture | architecture = `Architecture::kDefault`
| ) |  |

static

Returns the pathname of a build artifact.

Parameters

  [in] | module | The name of the Crashpad module associated with the artifact, such as `"util"` or `"snapshot"`. module must correspond to the module of the calling code, or execution will be aborted.
  [in] | artifact | The name of the specific artifact.
  [in] | file_type | The artifact’s type, used to establish the returned path’s extension.
  [in] | architecture | The artifact’s architecture.

Returns
  The computed pathname to the build artifact.

For example, the following snippet will return a path to `crashpad_snapshot_test_module.so` or `crashpad_snapshot_test_module.dll` (depending on platform) in the same directory as the currently running executable:

base::FilePath path = TestPaths::BuildArtifact(
FILE_PATH_LITERAL("snapshot"),
FILE_PATH_LITERAL("module"),
TestPaths::FileType::kLoadableModule);

## Executable()

base::FilePath crashpad::test::TestPaths::Executable | ( |  | ) |

static

Returns the pathname of the currently-running test executable.

On failure, aborts execution.

## ExpectedExecutableBasename()

base::FilePath crashpad::test::TestPaths::ExpectedExecutableBasename | ( | const base::FilePath::StringType & | name | ) |

static

Returns the expected basename of the currently-running test executable.

In Crashpad’s standalone build, this returns name, with the system’s extension for executables (`.exe`) appended if appropriate.

When building in Chromium, name is ignored, and the name of the monolithic test executable (`crashpad_tests`) is returned, with the system’s extension for executables appended if appropriate.

Only use this function to determine test expectations.

Do not use this function to obtain the name of the currently running test executable, use Executable() instead. Do not use this function to locate other build artifacts, use BuildArtifact() instead.

## Has32BitBuildArtifacts()

static bool crashpad::test::TestPaths::Has32BitBuildArtifacts | ( |  | ) |

static

Returns
  `true` if 32-bit build artifacts are available.

Tests that require the use of 32-bit build output should call this function to determine whether that output is available. This function is only provided to aid 64-bit test code in locating 32-bit output. Only if this function indicates that 32-bit output is available, 64-bit test code may call BuildArtifact() with Architecture::k32Bit to obtain a path to the 32-bit output.

32-bit test code may assume the existence of 32-bit build output, which can be found its own directory, and located by calling BuildArtifact() with Architecture::kDefault.

## TestDataRoot()

base::FilePath crashpad::test::TestPaths::TestDataRoot | ( |  | ) |

static

Returns the pathname of the test data root.

If the `CRASHPAD_TEST_DATA_ROOT` environment variable is set, its value will be returned. Otherwise, this function will attempt to locate the test data root relative to the executable path. If this fails, it will fall back to returning the current working directory.

At present, the test data root is normally the root of the Crashpad source tree, although this may not be the case indefinitely. This function may only be used to locate test data, not for arbitrary access to source files.

The documentation for this class was generated from the following files:

- test/test_paths.h
- test/test_paths.cc