util: Refactor parsing subtest args

Pre-patch, piglit-framework-gl.c:process_args() parsed subtest args
'-subtest' and '-list-subtests' with inline code. This patch moves that
code to a new function, piglit_parse_subtest_args().

This prepares for using Piglit's subtest magic in non-GL tests.
Currently, all the code for subtests lives in piglit-framework-gl.{c,h},
and so must be moved out to the API-independent piglit-util.{c,h}.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
util/gl: Reject unrecongized subtest names

If the user specifies "-subtest $NAME" on the command line, but
the test defines no subtest with that name, then
piglit_parse_subtest_args() now reports PIGLIT_FAIL.

The test should fail early as possible on usage errors. Pre-patch, if
the user requested an invalid subtest name, the test did not fail until
it attempted to execute the invalid subtest. Post-patch, the test fails
during arg parsing.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
util/gl: Rename struct piglit_gl_subtest -> piglit_subtest

This prepares for using Piglit's subtest magic in non-GL tests.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
util/gl: Rename PIGLIT_GL_SUBTEST_END -> PIGLIT_SUBTEST_END

This prepares for using Piglit's subtest magic for non-GL tests.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
util: Move subtest utils to API-independent files

Pre-patch, piglit-framework-gl.{c,h} defined the function and structs
for working with subtests. This patch moves them to piglit-util.{c,h},
so that they become available for non-GL tests.

This is simply a copy-paste patch. The patch does not modify the
relocated code.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
util/egl: Add EGLDisplay parameter to piglit_require_egl_extension()

Without an explicit EGLDisplay parameter, it's not possible to call
piglit_require_egl_extension() without first binding the display to
a context with eglMakeCurrent(). Some EGL tests, though, will never need
to or want to create a context.

Also, this makes the signature of piglit_require_egl_extension()
match that of piglit_is_egl_extension_supported().

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
util/egl: piglit_egl_bind_api: Add a missing newline to an error message
util/egl: Add a checked version of eglGetProcAddress

The new piglit_egl_get_proc_address fails the test if eglGetProcAddress
returns NULL.
util/egl: Add piglit_egl_get_default_display()

This function gets the default display for the given platform.
util: Add func piglit_gettid()

On Linux, piglit_gettid() wraps the gettid() syscall.
It returns 0 on unsupported systems.

This is useful for printing messages in multi-threaded tests.
util/log: Add logging module

Add new header piglit-log.h which exposes the following functions:
    piglit_log_get_opt()
    piglit_log_set_opt()
    piglit_loge()
    piglit_logi()

This new module should help to reduce redundant logging boilerplate
found in many Piglit files.
util: Use piglit-log in piglit-util.c

This patch replaces each occurence of printf in piglit-util.c, when
appropriate,  with piglit_loge() or piglit_logi().
cmake: Check for pthreads

If CMake succeeds in compiling a small test file that uses
pthread_self(), then set PIGLIT_HAS_PTHREADS as a CMake variable and
feature macro.
EGL_KHR_fence_sync: WIP