Issue #246 resolved

Two surface tests fail on amd64 Ubuntu Launchpad builds

Thomas Kluyver
created an issue

These failures only appear on 64-bit - the 32-bit build appears to be OK. I can reproduce the failure locally (on 64 bit Ubuntu) by setting the environment variable SDL_VIDEODRIVER=dummy, which I do in the builds so the tests don't try to access the nonexistant screen and terminal.

If this is a bug in the SDL dummy video driver, I guess the tests should be skipped when that's in use.

======================================================================
FAIL: SurfaceSelfBlitTest.test_blanket_alpha
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/buildd/pygame-1.9.2~pre~ubuntu+2402+13~ubuntu15.04.1/debian/python-pygame/usr/lib/python2.7/dist-packages/pygame/tests/surface_test.py", line 2258, in test_blanket_alpha
    self._assert_same(surf, comp)
  File "/build/buildd/pygame-1.9.2~pre~ubuntu+2402+13~ubuntu15.04.1/debian/python-pygame/usr/lib/python2.7/dist-packages/pygame/tests/surface_test.py", line 2179, in _assert_same
    a.get_bitsize())))
AssertionError: (0, 255, 0, 255) != (255, 0, 0, 255), bpp: 8

======================================================================
FAIL: SurfaceSelfBlitTest.test_colorkey
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/buildd/pygame-1.9.2~pre~ubuntu+2402+13~ubuntu15.04.1/debian/python-pygame/usr/lib/python2.7/dist-packages/pygame/tests/surface_test.py", line 2238, in test_colorkey
    self._assert_same(surf, comp)
  File "/build/buildd/pygame-1.9.2~pre~ubuntu+2402+13~ubuntu15.04.1/debian/python-pygame/usr/lib/python2.7/dist-packages/pygame/tests/surface_test.py", line 2179, in _assert_same
    a.get_bitsize())))
AssertionError: (0, 255, 0, 255) != (255, 0, 0, 255), bpp: 8

Comments (6)

  1. Lenard Lindstrom

    I can reproduce the bug on 64-bit Ubuntu 14.04.2 LTS running on a Pentium. My initial suspicion is that the dummy driver results in a different default surface pixel layout than when an actual video card driver is used; it has exposed a Pygame bug that has otherwise remained hidden.

  2. Lenard Lindstrom

    Fix Issue #246: Surface test fails on x86_64 Ubuntu

    Unit tests SurfaceSelfBlitTest.test_colorkey and SurfaceSelfBlitTest.test_blanket_alpha of surface_test.py failed when running the unit tests with the video driver set to dummy. In particular, the blit to the 8-bit surface tmp of the 32 bit surface comp failed to copy the pixel colors correctly.

    The pygame.Surface.blit() method avoids blitting a per-pixel alpha surface to an 8-bit indexed surface, as this did not work correctly. So the source surface in the blit would first be converted to another format, presumably one without per-pixel alpha. If the display was enabled, then SDL_DisplayFormat was used to do the conversion. Unfortunately, when the display driver is dummy, the surface returned by SDL_DisplayFormat returns an 8-bit indexed surface, with differing palettes depending on the build.

    In the above unit tests, the palette returned by SDL_DisplayFormat did not support the test color used, so replaced it with something else. The unit test assertion would then fail, as the source and comparison surfaces did not match.

    Besides the problem with the dummy video driver, using SDL_DisplayFormat assumes the display format has no per-pixel alpha. This assumption is probably no longer valid. So to fix the bug, the special case where SDL_DisplayFormat was used was removed, with the known default intermediate surface format always used.

    → <<cset b0117d331d33>>

  3. Log in to comment