0

Used use-gl=any instead of forcing osmesa for gpu browser tests.

This was committed as part of r105914, which was later reverted due to mysterious tsan failures. I am splitting the original patch into smaller chunks to figure out the failure.
Review URL: http://codereview.chromium.org/8347007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106113 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
alokp@chromium.org
2011-10-18 20:22:24 +00:00
parent 7f39bae056
commit 689992c89d
3 changed files with 24 additions and 72 deletions

@ -33,40 +33,16 @@ class GPUBrowserTest : public InProcessBrowserTest {
virtual void SetUpCommandLine(CommandLine* command_line) { virtual void SetUpCommandLine(CommandLine* command_line) {
InProcessBrowserTest::SetUpCommandLine(command_line); InProcessBrowserTest::SetUpCommandLine(command_line);
EXPECT_TRUE(test_launcher_utils::OverrideGLImplementation( // GPU tests require gpu acceleration.
command_line, // We do not care which GL backend is used.
gfx::kGLImplementationOSMesaName)); command_line->AppendSwitchASCII(switches::kUseGL, "any");
command_line->AppendSwitch(switches::kDisablePopupBlocking); command_line->AppendSwitch(switches::kDisablePopupBlocking);
#if defined(OS_MACOSX)
// Accelerated compositing does not work with OSMesa. AcceleratedSurface
// assumes GL contexts are native.
command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
#endif
} }
FilePath gpu_test_dir_; FilePath gpu_test_dir_;
}; };
#if defined(TOOLKIT_VIEWS)
// Flaky on Windows (dbg): http://crbug.com/72608
// For ChromeOS: http://crbug.com/76217
#define MAYBE_BrowserTestCanLaunchWithOSMesa DISABLED_BrowserTestCanLaunchWithOSMesa
#else
#define MAYBE_BrowserTestCanLaunchWithOSMesa BrowserTestCanLaunchWithOSMesa
#endif
IN_PROC_BROWSER_TEST_F(GPUBrowserTest, MAYBE_BrowserTestCanLaunchWithOSMesa) {
// Check the webgl test reports success and that the renderer was OSMesa.
ui_test_utils::NavigateToURL(
browser(),
net::FilePathToFileURL(gpu_test_dir_.AppendASCII("webgl.html")));
EXPECT_EQ(ASCIIToUTF16("SUCCESS: WebKit WebGL"),
browser()->GetSelectedTabContents()->GetTitle());
}
// Test is flaky and timing out. See crbug.com/99883 // Test is flaky and timing out. See crbug.com/99883
IN_PROC_BROWSER_TEST_F(GPUBrowserTest, IN_PROC_BROWSER_TEST_F(GPUBrowserTest,
DISABLED_CanOpenPopupAndRenderWithWebGLCanvas) { DISABLED_CanOpenPopupAndRenderWithWebGLCanvas) {

@ -35,17 +35,9 @@ class GPUCrashTest : public InProcessBrowserTest {
EnableDOMAutomation(); EnableDOMAutomation();
InProcessBrowserTest::SetUpCommandLine(command_line); InProcessBrowserTest::SetUpCommandLine(command_line);
// OverrideGLImplementation and kDisableAcceleratedCompositing for // GPU tests require gpu acceleration.
// OS_MACOSX are Taken verbatim from gpu_pixel_browsertest.cc and // We do not care which GL backend is used.
// gpu_browsertest.cc. command_line->AppendSwitchASCII(switches::kUseGL, "any");
EXPECT_TRUE(test_launcher_utils::OverrideGLImplementation(
command_line,
gfx::kGLImplementationOSMesaName));
#if defined(OS_MACOSX)
// Accelerated compositing does not work with OSMesa. AcceleratedSurface
// assumes GL contexts are native.
command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
#endif
} }
virtual void SetUpInProcessBrowserTestFixture() { virtual void SetUpInProcessBrowserTestFixture() {
FilePath test_dir; FilePath test_dir;

@ -109,25 +109,12 @@ class GpuPixelBrowserTest : public InProcessBrowserTest {
// This enables DOM automation for tab contents. // This enables DOM automation for tab contents.
EnableDOMAutomation(); EnableDOMAutomation();
// These tests by default use OSMesa. This can be changed if the |kUseGL| // These tests by default use any GL implementation it can find.
// switch is explicitly set to something else or if |kUseGpuInTests| is // This can be changed if the |kUseGL| switch is explicitly set to
// present. // something or if |kUseGpuInTests| is present.
if (command_line->HasSwitch(switches::kUseGL)) { if (!command_line->HasSwitch(switches::kUseGL) &&
using_gpu_ = command_line->GetSwitchValueASCII(switches::kUseGL) != !command_line->HasSwitch(kUseGpuInTests)) {
gfx::kGLImplementationOSMesaName; command_line->AppendSwitchASCII(switches::kUseGL, "any");
} else if (command_line->HasSwitch(kUseGpuInTests)) {
using_gpu_ = true;
} else {
// OSMesa will be used by default.
EXPECT_TRUE(test_launcher_utils::OverrideGLImplementation(
command_line,
gfx::kGLImplementationOSMesaName));
#if defined(OS_MACOSX)
// Accelerated compositing does not work with OSMesa. AcceleratedSurface
// assumes GL contexts are native.
command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
#endif
using_gpu_ = false;
} }
// Allow file access from "file://" protocol. Otherwise, test fails with // Allow file access from "file://" protocol. Otherwise, test fails with
// "Uncaught Error: SECURITY_ERR: DOM Exception 18." // "Uncaught Error: SECURITY_ERR: DOM Exception 18."
@ -144,11 +131,6 @@ class GpuPixelBrowserTest : public InProcessBrowserTest {
else else
generated_img_dir_ = test_data_dir_.AppendASCII("generated"); generated_img_dir_ = test_data_dir_.AppendASCII("generated");
if (using_gpu_)
reference_img_dir_ = test_data_dir_.AppendASCII("gpu_reference");
else
reference_img_dir_ = test_data_dir_.AppendASCII("sw_reference");
test_name_ = testing::UnitTest::GetInstance()->current_test_info()->name(); test_name_ = testing::UnitTest::GetInstance()->current_test_info()->name();
const char* test_status_prefixes[] = {"DISABLED_", "FLAKY_", "FAILS_"}; const char* test_status_prefixes[] = {"DISABLED_", "FLAKY_", "FAILS_"};
for (size_t i = 0; i < arraysize(test_status_prefixes); ++i) { for (size_t i = 0; i < arraysize(test_status_prefixes); ++i) {
@ -172,6 +154,7 @@ class GpuPixelBrowserTest : public InProcessBrowserTest {
bool CompareImages(const SkBitmap& gen_bmp, const std::string& postfix) { bool CompareImages(const SkBitmap& gen_bmp, const std::string& postfix) {
// Determine the name of the image. // Determine the name of the image.
std::string img_name = test_name_; std::string img_name = test_name_;
FilePath ref_img_dir;
if (postfix.length()) if (postfix.length())
img_name += "_" + postfix; img_name += "_" + postfix;
#if defined(OS_WIN) #if defined(OS_WIN)
@ -183,21 +166,25 @@ class GpuPixelBrowserTest : public InProcessBrowserTest {
#else #else
#error "Not implemented for this platform" #error "Not implemented for this platform"
#endif #endif
if (using_gpu_) { GPUInfo info;
GPUInfo info; if (!GetGPUInfo(&info)) {
if (!GetGPUInfo(&info)) { LOG(ERROR) << "Could not get gpu info";
LOG(ERROR) << "Could not get gpu info"; return false;
return false; }
} // TODO(alokp): Why do we treat Mesa differently?
bool using_gpu = info.gl_renderer.compare(0, 4, "Mesa") != 0;
if (using_gpu) {
ref_img_dir = test_data_dir_.AppendASCII("gpu_reference");
img_name = base::StringPrintf("%s_%s_%04x-%04x.png", img_name = base::StringPrintf("%s_%s_%04x-%04x.png",
img_name.c_str(), os_label, info.vendor_id, info.device_id); img_name.c_str(), os_label, info.vendor_id, info.device_id);
} else { } else {
ref_img_dir = test_data_dir_.AppendASCII("sw_reference");
img_name = base::StringPrintf("%s_%s_mesa.png", img_name = base::StringPrintf("%s_%s_mesa.png",
img_name.c_str(), os_label); img_name.c_str(), os_label);
} }
// Read the reference image and verify the images' dimensions are equal. // Read the reference image and verify the images' dimensions are equal.
FilePath ref_img_path = reference_img_dir_.AppendASCII(img_name); FilePath ref_img_path = ref_img_dir.AppendASCII(img_name);
SkBitmap ref_bmp; SkBitmap ref_bmp;
bool should_compare = true; bool should_compare = true;
if (!ReadPNGFile(ref_img_path, &ref_bmp)) { if (!ReadPNGFile(ref_img_path, &ref_bmp)) {
@ -264,12 +251,9 @@ class GpuPixelBrowserTest : public InProcessBrowserTest {
FilePath test_data_dir_; FilePath test_data_dir_;
private: private:
FilePath reference_img_dir_;
FilePath generated_img_dir_; FilePath generated_img_dir_;
// The name of the test, with any special prefixes dropped. // The name of the test, with any special prefixes dropped.
std::string test_name_; std::string test_name_;
// Whether the gpu, or OSMesa is being used for rendering.
bool using_gpu_;
DISALLOW_COPY_AND_ASSIGN(GpuPixelBrowserTest); DISALLOW_COPY_AND_ASSIGN(GpuPixelBrowserTest);
}; };