Don't run GLX_OML_sync_control tests concurrently.

This fixes the swapbuffersmsc-return (with default swap_interval) test,
by not passing it arguments that it doesn't understand.

These tests all require a GLXWindow, so they can't be used in -fbo mode
(and they didn't understand that option anyway).

And though they need the behavior of -auto, none of them parse that
option. These tests have to deal with it in other ways, as illustrated
by commit 1d618f2abbc9f9665505b7082690eebc3bc01a72.

Finally, I think it's a bad idea to run these tests concurrently with
anything else, as interference from other clients could change the
result of attempting to sync to vertical retrace, which is a
screen-global resource.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Theo Hill <Theo0x48@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Simplify piglit_glx_get_all_proc_addresses API.

I couldn't stand the number of ways this API could be misused and the
amount of code duplication it forced--two closely related issues.

This also fixes a bug: The "Failed to get function pointer" test could
never have triggered unless the caller passed incorrect arguments,
which is not the kind of error it was intended to be testing for.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Only test non-default swap_interval if supported.

If this test is compiled on a machine that does not have headers for
GLX_MESA_swap_control, then it should skip any tests that require using
GLX_MESA_swap_control.

I tested this patch in both configurations, using "#if 0 && ..." to
check the unsupported-at-build-time case.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Add piglit_set_timeout for tests that might hang.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Add helper for creating full-screen glX windows.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Theo Hill <Theo0x48@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Allow OML_sync_control tests to run fullscreen.

None of the current tests use this, but we introduce some fullscreen
tests in the next commit.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Theo Hill <Theo0x48@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Validate that OML Sync Control syncs to vblank.

The existing tests don't demonstrate a variety of implementation bugs
that we've observed in current drivers, so this is our attempt to
demonstrate those bugs.

v2:
- Report which loop iteration each warning is from. It's often helpful
  to know whether it was the first iteration or a later one.
- From Eric Anholt's review comments:
  - Added PIGLIT_WARN where appropriate
  - Wrapped lines to 80 characters
  - Removed comments describing checks
  - Removed glFlush()
- From Chris Wilson's review comments:
  - Don't require a glXGetSyncValuesOML call immediately after
    glXWaitForSbc/Msc to return the same UST or MSC, because
    uncontrolled delays during the test may mean that the counters
    increment between the two calls. Instead, require that alternating
    GetSyncValues and Wait calls return monotonically increasing UST and
    MSC values. Since a common failure mode in the current drivers is to
    return UST and MSC as 0 from the WaitForSbc/Msc requests (which
    obviously violates monotonicity), if those values are illegal, try
    to muddle through the rest of the test using the GetSyncValues
    results instead.
  - When divisor is 0 and the target msc equals the current msc, swaps
    may occur without syncing to vertical retrace. So don't test timing
    with a divisor of 0.

v3: Rebase to master, minor piglit style changes (by anholt)

Signed-off-by: Theo Hill <Theo0x48@gmail.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Added timeouts to tests that use SwapBuffersMsc.

We've observed hangs on some drivers in these calls, which make it
harder to run the rest of the Piglit test suite.

Version 2 fixes from Eric Anholt's review:
Set timeouts to 5 seconds instead of trying to calculate them on the fly

Signed-off-by: Theo Hill <Theo0x48@gmail.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
arb_shader_atomic_counters: Test respecification of a bound ABO

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
teximage-colors: fix bogus precision assumptions and other issues

Some formats had some "implied" precision which relied on the driver picking a
specific hw format (e.g. RGB4 and RGB5 both relied on driver picking 565).
These tests will now be skipped (for the exact test).
Others didn't have any implied precision but relied on driver picking a format
with at least 8 bits even though the internal format only implied 4.
Also, the exact tests for srgb8 and srgb8_alpha8 were failing too due to using
GL_BYTE instead of GL_UNSIGNED_BYTE.
With these fixes the only tests llvmpipe is failing seem to be the exact
GL_RGB8_SNORM and GL_RGB16_SNORM ones (1, 2 or 4 channels work and the errors
seem to be one bit so maybe triggers some conversion somewhere using different
signed conversion formula).

v2: fix indentation

Reviewed-by: Brian Paul <brianp@vmware.com>
Revuewed-by: Jason Exstrand <jason.ekstrand@intel.com>
framework tests: fix timeout tests

Currently the timeout tests rely on /usr/bin/sleep and /usr/bin/true.
This is very fragile, since on my (Gentoo) system true is in /bin. The
better solution is to rely on either a shell built-in or to just find
the binary in path.

This of course still has some fragility, so this patch also introduces a
new utility function, binary_check. This function looks for a command
using which (not window safe of course, but most of the unit tests
aren't) or it raises a SkipTest.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
framework: Move tests derived classes into a package

This moves all of the classes that derive from Test into a package
called test. This patch looks very large, but is mostly just moving
files around and changing imports to account for this.

So why all of this code churn? The big advantage is that through
__init__.py magic there is one module to be imported, framework.test.
This module contains all of the public classes, functions, and
constants, in one place while hiding the rest, but allowing them to be
accessed explicitly.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
framework/test: refactor abstract Test and PiglitTest

This creates two separate modules for these classes.

Making this change allows us to separate the basic building blocks of
Test classes and the concrete implementations.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
framework: Split PiglitTest into specific GL and CL classes

This creates two separate classes for OpenGL and OpenCL tests. This
allows the implementation of features, workarounds, etc for only one
standard without adversely effecting the other.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
test: Split the spurious resize code out of PiglitGLTest

This patch splits that run method out into a separate mixin class that
overrides only the _run_command method. This split will be used in the
next patch to apply the same mixin to the GleanTest class, which
theoretically suffers from the same problem but doesn't have this catch.

v2: - add test for WindowResizeMixin

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
framework/test/base.py: Use a flag in _run_command

If there is an error in self._run_command return a flag of either True
or False, instead of checking for self.result['result'] == 'skip' in
Test.run() for early return check for the returned error flag. This
makes the early return mechanism much more flexible and extensible than
it was before, especially for mixins and subclasses that whish to extend
the _run_command method.

v2: - add test for _run_command return code

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
base.py: Extend the WindowResizeMixin to return early

In the event that we get more spurious window resizes than our threshold
(5), mark the test as fail, adds a message in out as to why it failed,
and then returns True so that Test.run() will return early.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
framework: Move PLATFORMS list to core

This allows the PLATFORMS list to be readily shared, and will be used in
the next patch.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
piglit_test.py: Automatically add -auto and -fbo when appropriate

There is a lot of logic in all.py to add -auto and possible -fbo to
tests when it is appropriate. This is rather silly as we can just make
the test class do this for us, which has the added advantage of reducing
the amount of memory each test needs by reducing the number of strings
stored by each instance.

This patch removes the plain_test and concurrent_test wrappers, and
replaces them with PiglitGLTest constructor calls directly. For
plain_test this is all that is needed (because of the modifications that
add -auto and -fbo automatically) for concurrent_test it additionally
adds the run_concurrent=True keyword argument to the constructor.

This is minimally invasive, but allows us to easily pass additional
parameters to the constructors of these tests, and will be used in
subsequent patches to do platform dependent skipping.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
piglit_test.py: Add arguments for platform restrictions to PiglitGLTest

This adds two new keyword arguments to the PiglitGLTest,
require_platform and exclude_platforms. These two arguments are mutually
exclusive and provide a mechanism to fast filter tests that have
platform restrictions.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>