Overload stream insertion for DawnTestParam
Passing "--gtest_list_tests" as an argument to the gtest binary lists the tests in the binary. However, when the test suite is parameterized (like in the case of dawn_end2end_tests), the output will list the string name of the parameter along with the test name. Since there is no stream insertion overload for DawnTestParam, we get this output: ./dawn_end2end_tests --gtest_list_tests BasicTests. BufferSetSubData/OpenGL # GetParam() = 56-byte object <03-00 00-00 19... BufferSetSubData/Vulkan # GetParam() = 56-byte object <04-00 00-00 19... ... This CL adds an implementation to display the string name of the param instead. BUG=chromium:993457 TEST=run ./dawn_end2end_test --gtest_list_tests Change-Id: Ifae65a9eaf96448341e6ed1894f116f1af1154b7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10240 Commit-Queue: Brian Ho <hob@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
b097b3100b
commit
e25a3aede0
|
@ -93,6 +93,17 @@ DawnTestParam ForceWorkarounds(const DawnTestParam& originParam,
|
|||
return newTestParam;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const DawnTestParam& param) {
|
||||
os << ParamName(param.backendType);
|
||||
for (const char* forceEnabledWorkaround : param.forceEnabledWorkarounds) {
|
||||
os << "__e_" << forceEnabledWorkaround;
|
||||
}
|
||||
for (const char* forceDisabledWorkaround : param.forceDisabledWorkarounds) {
|
||||
os << "__d_" << forceDisabledWorkaround;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
// Implementation of DawnTestEnvironment
|
||||
|
||||
void InitDawnEnd2EndTestEnvironment(int argc, char** argv) {
|
||||
|
@ -710,17 +721,6 @@ namespace detail {
|
|||
return backends;
|
||||
}
|
||||
|
||||
std::string GetParamName(const testing::TestParamInfo<DawnTestParam>& info) {
|
||||
std::ostringstream ostream;
|
||||
ostream << ParamName(info.param.backendType);
|
||||
|
||||
for (const char* forceEnabledWorkaround : info.param.forceEnabledWorkarounds) {
|
||||
ostream << "_" << forceEnabledWorkaround;
|
||||
}
|
||||
|
||||
return ostream.str();
|
||||
}
|
||||
|
||||
// Helper classes to set expectations
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -83,6 +83,8 @@ struct DawnTestParam {
|
|||
std::vector<const char*> forceDisabledWorkarounds;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const DawnTestParam& param);
|
||||
|
||||
// Shorthands for backend types used in the DAWN_INSTANTIATE_TEST
|
||||
extern const DawnTestParam D3D12Backend;
|
||||
extern const DawnTestParam MetalBackend;
|
||||
|
@ -269,7 +271,7 @@ class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
|
|||
, testName, \
|
||||
testing::ValuesIn(::detail::FilterBackends( \
|
||||
testName##params, sizeof(testName##params) / sizeof(firstParam))), \
|
||||
::detail::GetParamName)
|
||||
testing::PrintToStringParamName())
|
||||
|
||||
// Skip a test when the given condition is satisfied.
|
||||
#define DAWN_SKIP_TEST_IF(condition) \
|
||||
|
@ -282,7 +284,6 @@ namespace detail {
|
|||
// Helper functions used for DAWN_INSTANTIATE_TEST
|
||||
bool IsBackendAvailable(dawn_native::BackendType type);
|
||||
std::vector<DawnTestParam> FilterBackends(const DawnTestParam* params, size_t numParams);
|
||||
std::string GetParamName(const testing::TestParamInfo<DawnTestParam>& info);
|
||||
|
||||
// All classes used to implement the deferred expectations should inherit from this.
|
||||
class Expectation {
|
||||
|
|
Loading…
Reference in New Issue