Commit 97f0affb by Jamie Madill Committed by Commit Bot

Add command line option to filter by test config.

This allows us to run angle_end2end_tests with a single config without using gtest_filter. It will also allow us to run each test config in a separate process. Bug: angleproject:3393 Change-Id: I09aaf9cfe55a117b0af8d79ecfd129f3d0f1d7c8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1591427 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 051b0896
...@@ -10,8 +10,8 @@ void ANGLEProcessTestArgs(int *argc, char *argv[]); ...@@ -10,8 +10,8 @@ void ANGLEProcessTestArgs(int *argc, char *argv[]);
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
testing::InitGoogleTest(&argc, argv);
ANGLEProcessTestArgs(&argc, argv); ANGLEProcessTestArgs(&argc, argv);
testing::InitGoogleTest(&argc, argv);
int rt = RUN_ALL_TESTS(); int rt = RUN_ALL_TESTS();
return rt; return rt;
} }
...@@ -292,6 +292,8 @@ TestPlatformContext gPlatformContext; ...@@ -292,6 +292,8 @@ TestPlatformContext gPlatformContext;
// After a fixed number of iterations we reset the test window. This works around some driver bugs. // After a fixed number of iterations we reset the test window. This works around some driver bugs.
constexpr uint32_t kWindowReuseLimit = 50; constexpr uint32_t kWindowReuseLimit = 50;
constexpr char kUseConfig[] = "--use-config=";
} // anonymous namespace } // anonymous namespace
// static // static
...@@ -1277,6 +1279,14 @@ angle::Library *ANGLETestEnvironment::GetWGLLibrary() ...@@ -1277,6 +1279,14 @@ angle::Library *ANGLETestEnvironment::GetWGLLibrary()
void ANGLEProcessTestArgs(int *argc, char *argv[]) void ANGLEProcessTestArgs(int *argc, char *argv[])
{ {
testing::AddGlobalTestEnvironment(new ANGLETestEnvironment()); testing::AddGlobalTestEnvironment(new ANGLETestEnvironment());
for (int argIndex = 1; argIndex < *argc; argIndex++)
{
if (strncmp(argv[argIndex], kUseConfig, strlen(kUseConfig)) == 0)
{
angle::gSelectedConfig = std::string(argv[argIndex] + strlen(kUseConfig));
}
}
} }
EGLTest::EGLTest() = default; EGLTest::EGLTest() = default;
......
...@@ -69,6 +69,8 @@ bool IsNativeConfigSupported(const PlatformParameters &param, OSWindow *osWindow ...@@ -69,6 +69,8 @@ bool IsNativeConfigSupported(const PlatformParameters &param, OSWindow *osWindow
} }
} // namespace } // namespace
std::string gSelectedConfig;
SystemInfo *GetTestSystemInfo() SystemInfo *GetTestSystemInfo()
{ {
static SystemInfo *sSystemInfo = nullptr; static SystemInfo *sSystemInfo = nullptr;
...@@ -412,11 +414,22 @@ bool IsPlatformAvailable(const PlatformParameters &param) ...@@ -412,11 +414,22 @@ bool IsPlatformAvailable(const PlatformParameters &param)
{ {
return iter->second; return iter->second;
} }
bool result = false;
if (!gSelectedConfig.empty())
{
std::stringstream strstr;
strstr << param;
if (strstr.str() == gSelectedConfig)
{
result = true;
}
}
else else
{ {
const SystemInfo *systemInfo = GetTestSystemInfo(); const SystemInfo *systemInfo = GetTestSystemInfo();
bool result = false;
if (systemInfo) if (systemInfo)
{ {
result = IsConfigWhitelisted(*systemInfo, param); result = IsConfigWhitelisted(*systemInfo, param);
...@@ -425,18 +438,18 @@ bool IsPlatformAvailable(const PlatformParameters &param) ...@@ -425,18 +438,18 @@ bool IsPlatformAvailable(const PlatformParameters &param)
{ {
result = IsConfigSupported(param); result = IsConfigSupported(param);
} }
}
paramAvailabilityCache[param] = result; paramAvailabilityCache[param] = result;
if (!result)
{
std::cout << "Skipping tests using configuration " << param
<< " because it is not available." << std::endl;
}
// Uncomment this to print available platforms. if (!result)
// std::cout << "Platform: " << param << " (" << paramAvailabilityCache.size() << ")\n"; {
return result; std::cout << "Skipping tests using configuration " << param
<< " because it is not available." << std::endl;
} }
// Uncomment this to print available platforms.
// std::cout << "Platform: " << param << " (" << paramAvailabilityCache.size() << ")\n";
return result;
} }
} // namespace angle } // namespace angle
...@@ -121,6 +121,9 @@ bool IsConfigSupported(const PlatformParameters &param); ...@@ -121,6 +121,9 @@ bool IsConfigSupported(const PlatformParameters &param);
// Returns shared test system information. Can be used globally in the tests. // Returns shared test system information. Can be used globally in the tests.
SystemInfo *GetTestSystemInfo(); SystemInfo *GetTestSystemInfo();
// Active config (e.g. ES2_Vulkan).
extern std::string gSelectedConfig;
} // namespace angle } // namespace angle
#endif // ANGLE_TEST_INSTANTIATE_H_ #endif // ANGLE_TEST_INSTANTIATE_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment