mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
cogl: Remove the now unused test framework
All tests have been moved into src/tests/, so no need for it anymore. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
This commit is contained in:
parent
30daad4da5
commit
efaf5a25b3
@ -426,12 +426,6 @@ cogl_headers_all = [
|
||||
cogl_deprecated_headers,
|
||||
]
|
||||
|
||||
cogl_test_deps = []
|
||||
|
||||
if have_cogl_tests
|
||||
cogl_test_deps += [libmutter_cogl_test_fixtures_dep]
|
||||
endif
|
||||
|
||||
libmutter_cogl_name = 'mutter-cogl-' + libmutter_api_version
|
||||
libmutter_cogl = shared_library(libmutter_cogl_name,
|
||||
sources: [cogl_sources, cogl_headers_all],
|
||||
@ -439,7 +433,7 @@ libmutter_cogl = shared_library(libmutter_cogl_name,
|
||||
soversion: 0,
|
||||
c_args: cogl_c_args,
|
||||
include_directories: cogl_includepath,
|
||||
dependencies: [cogl_deps, cogl_test_deps],
|
||||
dependencies: cogl_deps,
|
||||
gnu_symbol_visibility: 'hidden',
|
||||
install_rpath: pkglibdir,
|
||||
install_dir: pkglibdir,
|
||||
|
@ -113,11 +113,5 @@ endif
|
||||
supported_cogl_debug_c_args = cc.get_supported_arguments(cogl_debug_c_args)
|
||||
cogl_c_args += cogl_debug_c_args
|
||||
|
||||
if have_cogl_tests
|
||||
subdir('test-fixtures')
|
||||
endif
|
||||
subdir('cogl')
|
||||
subdir('cogl-pango')
|
||||
if have_cogl_tests
|
||||
subdir('tests')
|
||||
endif
|
||||
|
@ -1,22 +0,0 @@
|
||||
cogl_test_fixtures_includepath = [include_directories('.')]
|
||||
|
||||
cogl_test_fixtures_sources = [
|
||||
'test-unit.h',
|
||||
'test-utils.h',
|
||||
'test-utils.c',
|
||||
]
|
||||
|
||||
test_datadir = join_paths(cogl_srcdir, 'tests', 'data')
|
||||
|
||||
libmutter_cogl_test_fixtures = static_library('mutter-cogl-test-fixtures',
|
||||
sources: cogl_test_fixtures_sources,
|
||||
c_args: [cogl_c_args, '-DTEST_DATADIR=@0@'.format(test_datadir)],
|
||||
link_args: ['-Wl,--no-undefined', '-Wl,--unresolved-symbols=ignore-in-object-files'],
|
||||
include_directories: cogl_includepath,
|
||||
dependencies: [cogl_deps],
|
||||
install: false,
|
||||
)
|
||||
|
||||
libmutter_cogl_test_fixtures_dep = declare_dependency(
|
||||
link_with: libmutter_cogl_test_fixtures
|
||||
)
|
@ -1,33 +0,0 @@
|
||||
#ifndef _TEST_UNIT_H_
|
||||
#define _TEST_UNIT_H_
|
||||
|
||||
#include <test-fixtures/test-utils.h>
|
||||
|
||||
#ifdef ENABLE_UNIT_TESTS
|
||||
|
||||
typedef struct _CoglUnitTest
|
||||
{
|
||||
const char *name;
|
||||
TestFlags requirement_flags;
|
||||
TestFlags known_failure_flags;
|
||||
void (*run) (void);
|
||||
} CoglUnitTest;
|
||||
|
||||
#define UNIT_TEST(NAME, REQUIREMENT_FLAGS, KNOWN_FAILURE_FLAGS) \
|
||||
static void NAME (void); \
|
||||
\
|
||||
COGL_EXPORT \
|
||||
const CoglUnitTest unit_test_##NAME; \
|
||||
const CoglUnitTest unit_test_##NAME = \
|
||||
{ #NAME, REQUIREMENT_FLAGS, KNOWN_FAILURE_FLAGS, NAME }; \
|
||||
\
|
||||
static void NAME (void)
|
||||
|
||||
#else /* ENABLE_UNIT_TESTS */
|
||||
|
||||
#define UNIT_TEST(NAME, REQUIREMENT_FLAGS, KNOWN_FAILURE_FLAGS) \
|
||||
static inline void NAME (void)
|
||||
|
||||
#endif /* ENABLE_UNIT_TESTS */
|
||||
|
||||
#endif /* _TEST_UNIT_H_ */
|
@ -1,511 +0,0 @@
|
||||
#include "cogl-config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "test-unit.h"
|
||||
#include "test-utils.h"
|
||||
|
||||
#include "cogl/winsys/cogl-onscreen-glx.h"
|
||||
#include "cogl/winsys/cogl-onscreen-xlib.h"
|
||||
|
||||
#define FB_WIDTH 512
|
||||
#define FB_HEIGHT 512
|
||||
|
||||
static gboolean cogl_test_is_verbose;
|
||||
|
||||
CoglContext *test_ctx;
|
||||
CoglFramebuffer *test_fb;
|
||||
|
||||
static gboolean
|
||||
check_flags (TestFlags flags,
|
||||
CoglRenderer *renderer)
|
||||
{
|
||||
if (flags & TEST_REQUIREMENT_GL &&
|
||||
cogl_renderer_get_driver (renderer) != COGL_DRIVER_GL &&
|
||||
cogl_renderer_get_driver (renderer) != COGL_DRIVER_GL3)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (flags & TEST_REQUIREMENT_TEXTURE_RG &&
|
||||
!cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_RG))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (flags & TEST_REQUIREMENT_MAP_WRITE &&
|
||||
!cogl_has_feature (test_ctx, COGL_FEATURE_ID_MAP_BUFFER_FOR_WRITE))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (flags & TEST_REQUIREMENT_FENCE &&
|
||||
!cogl_has_feature (test_ctx, COGL_FEATURE_ID_FENCE))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (flags & TEST_KNOWN_FAILURE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_boolean_env_set (const char *variable)
|
||||
{
|
||||
char *val = getenv (variable);
|
||||
gboolean ret;
|
||||
|
||||
if (!val)
|
||||
return FALSE;
|
||||
|
||||
if (g_ascii_strcasecmp (val, "1") == 0 ||
|
||||
g_ascii_strcasecmp (val, "on") == 0 ||
|
||||
g_ascii_strcasecmp (val, "true") == 0)
|
||||
ret = TRUE;
|
||||
else if (g_ascii_strcasecmp (val, "0") == 0 ||
|
||||
g_ascii_strcasecmp (val, "off") == 0 ||
|
||||
g_ascii_strcasecmp (val, "false") == 0)
|
||||
ret = FALSE;
|
||||
else
|
||||
{
|
||||
g_critical ("Spurious boolean environment variable value (%s=%s)",
|
||||
variable, val);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static CoglOnscreen *
|
||||
create_onscreen (CoglContext *cogl_context,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
CoglDisplay *display = cogl_context_get_display (test_ctx);
|
||||
CoglRenderer *renderer = cogl_display_get_renderer (display);
|
||||
|
||||
switch (cogl_renderer_get_winsys_id (renderer))
|
||||
{
|
||||
case COGL_WINSYS_ID_GLX:
|
||||
#ifdef COGL_HAS_GLX_SUPPORT
|
||||
return COGL_ONSCREEN (cogl_onscreen_glx_new (cogl_context,
|
||||
width, height));
|
||||
#else
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
#endif
|
||||
case COGL_WINSYS_ID_EGL_XLIB:
|
||||
#ifdef COGL_HAS_EGL_PLATFORM_XLIB_SUPPORT
|
||||
return COGL_ONSCREEN (cogl_onscreen_xlib_new (cogl_context,
|
||||
width, height));
|
||||
#else
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
test_utils_init (TestFlags requirement_flags,
|
||||
TestFlags known_failure_flags)
|
||||
{
|
||||
static int counter = 0;
|
||||
GError *error = NULL;
|
||||
CoglOnscreen *onscreen = NULL;
|
||||
CoglDisplay *display;
|
||||
CoglRenderer *renderer;
|
||||
gboolean missing_requirement;
|
||||
gboolean known_failure;
|
||||
|
||||
if (counter != 0)
|
||||
g_critical ("We don't support running more than one test at a time\n"
|
||||
"in a single test run due to the state leakage that can\n"
|
||||
"cause subsequent tests to fail.\n"
|
||||
"\n"
|
||||
"If you want to run all the tests you should run\n"
|
||||
"$ make test-report");
|
||||
counter++;
|
||||
|
||||
if (is_boolean_env_set ("COGL_TEST_VERBOSE") ||
|
||||
is_boolean_env_set ("V"))
|
||||
cogl_test_is_verbose = TRUE;
|
||||
|
||||
/* NB: This doesn't have any effect since commit 47444dac of glib
|
||||
* because the environment variable is read in a magic constructor
|
||||
* so it is too late to set them here */
|
||||
if (g_getenv ("G_DEBUG"))
|
||||
{
|
||||
char *debug = g_strconcat (g_getenv ("G_DEBUG"), ",fatal-warnings", NULL);
|
||||
g_setenv ("G_DEBUG", debug, TRUE);
|
||||
g_free (debug);
|
||||
}
|
||||
else
|
||||
g_setenv ("G_DEBUG", "fatal-warnings", TRUE);
|
||||
|
||||
g_setenv ("COGL_X11_SYNC", "1", 0);
|
||||
|
||||
test_ctx = cogl_context_new (NULL, &error);
|
||||
if (!test_ctx)
|
||||
g_critical ("Failed to create a CoglContext: %s", error->message);
|
||||
|
||||
display = cogl_context_get_display (test_ctx);
|
||||
renderer = cogl_display_get_renderer (display);
|
||||
|
||||
missing_requirement = !check_flags (requirement_flags, renderer);
|
||||
known_failure = !check_flags (known_failure_flags, renderer);
|
||||
|
||||
if (is_boolean_env_set ("COGL_TEST_ONSCREEN"))
|
||||
{
|
||||
onscreen = create_onscreen (test_ctx, 640, 480);
|
||||
test_fb = COGL_FRAMEBUFFER (onscreen);
|
||||
}
|
||||
else
|
||||
{
|
||||
CoglOffscreen *offscreen;
|
||||
CoglTexture2D *tex = cogl_texture_2d_new_with_size (test_ctx,
|
||||
FB_WIDTH, FB_HEIGHT);
|
||||
offscreen = cogl_offscreen_new_with_texture (COGL_TEXTURE (tex));
|
||||
test_fb = COGL_FRAMEBUFFER (offscreen);
|
||||
}
|
||||
|
||||
if (!cogl_framebuffer_allocate (test_fb, &error))
|
||||
g_critical ("Failed to allocate framebuffer: %s", error->message);
|
||||
|
||||
cogl_framebuffer_clear4f (test_fb,
|
||||
COGL_BUFFER_BIT_COLOR |
|
||||
COGL_BUFFER_BIT_DEPTH |
|
||||
COGL_BUFFER_BIT_STENCIL,
|
||||
0, 0, 0, 1);
|
||||
|
||||
if (missing_requirement)
|
||||
g_print ("WARNING: Missing required feature[s] for this test\n");
|
||||
else if (known_failure)
|
||||
g_print ("WARNING: Test is known to fail\n");
|
||||
|
||||
return (!missing_requirement && !known_failure);
|
||||
}
|
||||
|
||||
void
|
||||
test_utils_fini (void)
|
||||
{
|
||||
if (test_fb)
|
||||
g_object_unref (test_fb);
|
||||
|
||||
if (test_ctx)
|
||||
cogl_object_unref (test_ctx);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
compare_component (int a, int b)
|
||||
{
|
||||
return ABS (a - b) <= 1;
|
||||
}
|
||||
|
||||
void
|
||||
test_utils_compare_pixel_and_alpha (const uint8_t *screen_pixel,
|
||||
uint32_t expected_pixel)
|
||||
{
|
||||
/* Compare each component with a small fuzz factor */
|
||||
if (!compare_component (screen_pixel[0], expected_pixel >> 24) ||
|
||||
!compare_component (screen_pixel[1], (expected_pixel >> 16) & 0xff) ||
|
||||
!compare_component (screen_pixel[2], (expected_pixel >> 8) & 0xff) ||
|
||||
!compare_component (screen_pixel[3], (expected_pixel >> 0) & 0xff))
|
||||
{
|
||||
uint32_t screen_pixel_num = GUINT32_FROM_BE (*(uint32_t *) screen_pixel);
|
||||
char *screen_pixel_string =
|
||||
g_strdup_printf ("#%08x", screen_pixel_num);
|
||||
char *expected_pixel_string =
|
||||
g_strdup_printf ("#%08x", expected_pixel);
|
||||
|
||||
g_assert_cmpstr (screen_pixel_string, ==, expected_pixel_string);
|
||||
|
||||
g_free (screen_pixel_string);
|
||||
g_free (expected_pixel_string);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_utils_compare_pixel (const uint8_t *screen_pixel, uint32_t expected_pixel)
|
||||
{
|
||||
/* Compare each component with a small fuzz factor */
|
||||
if (!compare_component (screen_pixel[0], expected_pixel >> 24) ||
|
||||
!compare_component (screen_pixel[1], (expected_pixel >> 16) & 0xff) ||
|
||||
!compare_component (screen_pixel[2], (expected_pixel >> 8) & 0xff))
|
||||
{
|
||||
uint32_t screen_pixel_num = GUINT32_FROM_BE (*(uint32_t *) screen_pixel);
|
||||
char *screen_pixel_string =
|
||||
g_strdup_printf ("#%06x", screen_pixel_num >> 8);
|
||||
char *expected_pixel_string =
|
||||
g_strdup_printf ("#%06x", expected_pixel >> 8);
|
||||
|
||||
g_assert_cmpstr (screen_pixel_string, ==, expected_pixel_string);
|
||||
|
||||
g_free (screen_pixel_string);
|
||||
g_free (expected_pixel_string);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_utils_check_pixel (CoglFramebuffer *test_fb,
|
||||
int x, int y, uint32_t expected_pixel)
|
||||
{
|
||||
uint8_t pixel[4];
|
||||
|
||||
cogl_framebuffer_read_pixels (test_fb,
|
||||
x, y, 1, 1,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||
pixel);
|
||||
|
||||
test_utils_compare_pixel (pixel, expected_pixel);
|
||||
}
|
||||
|
||||
void
|
||||
test_utils_check_pixel_and_alpha (CoglFramebuffer *test_fb,
|
||||
int x, int y, uint32_t expected_pixel)
|
||||
{
|
||||
uint8_t pixel[4];
|
||||
|
||||
cogl_framebuffer_read_pixels (test_fb,
|
||||
x, y, 1, 1,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||
pixel);
|
||||
|
||||
test_utils_compare_pixel_and_alpha (pixel, expected_pixel);
|
||||
}
|
||||
|
||||
void
|
||||
test_utils_check_pixel_rgb (CoglFramebuffer *test_fb,
|
||||
int x, int y, int r, int g, int b)
|
||||
{
|
||||
g_return_if_fail (r >= 0);
|
||||
g_return_if_fail (g >= 0);
|
||||
g_return_if_fail (b >= 0);
|
||||
g_return_if_fail (r <= 0xFF);
|
||||
g_return_if_fail (g <= 0xFF);
|
||||
g_return_if_fail (b <= 0xFF);
|
||||
|
||||
test_utils_check_pixel (test_fb, x, y,
|
||||
(((guint32) r) << 24) |
|
||||
(((guint32) g) << 16) |
|
||||
(((guint32) b) << 8));
|
||||
}
|
||||
|
||||
void
|
||||
test_utils_check_region (CoglFramebuffer *test_fb,
|
||||
int x, int y,
|
||||
int width, int height,
|
||||
uint32_t expected_rgba)
|
||||
{
|
||||
uint8_t *pixels, *p;
|
||||
|
||||
pixels = p = g_malloc (width * height * 4);
|
||||
cogl_framebuffer_read_pixels (test_fb,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888,
|
||||
p);
|
||||
|
||||
/* Check whether the center of each division is the right color */
|
||||
for (y = 0; y < height; y++)
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
test_utils_compare_pixel (p, expected_rgba);
|
||||
p += 4;
|
||||
}
|
||||
|
||||
g_free (pixels);
|
||||
}
|
||||
|
||||
CoglTexture *
|
||||
test_utils_create_color_texture (CoglContext *context,
|
||||
uint32_t color)
|
||||
{
|
||||
CoglTexture2D *tex_2d;
|
||||
|
||||
color = GUINT32_TO_BE (color);
|
||||
|
||||
tex_2d = cogl_texture_2d_new_from_data (context,
|
||||
1, 1, /* width/height */
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||
4, /* rowstride */
|
||||
(uint8_t *) &color,
|
||||
NULL);
|
||||
|
||||
return COGL_TEXTURE (tex_2d);
|
||||
}
|
||||
|
||||
gboolean
|
||||
cogl_test_verbose (void)
|
||||
{
|
||||
return cogl_test_is_verbose;
|
||||
}
|
||||
|
||||
static void
|
||||
set_auto_mipmap_cb (CoglTexture *sub_texture,
|
||||
const float *sub_texture_coords,
|
||||
const float *meta_coords,
|
||||
void *user_data)
|
||||
{
|
||||
cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (sub_texture),
|
||||
FALSE);
|
||||
}
|
||||
|
||||
CoglTexture *
|
||||
test_utils_texture_new_with_size (CoglContext *ctx,
|
||||
int width,
|
||||
int height,
|
||||
TestUtilsTextureFlags flags,
|
||||
CoglTextureComponents components)
|
||||
{
|
||||
CoglTexture *tex;
|
||||
GError *skip_error = NULL;
|
||||
|
||||
/* First try creating a fast-path non-sliced texture */
|
||||
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
|
||||
|
||||
cogl_texture_set_components (tex, components);
|
||||
|
||||
if (!cogl_texture_allocate (tex, &skip_error))
|
||||
{
|
||||
g_error_free (skip_error);
|
||||
cogl_object_unref (tex);
|
||||
tex = NULL;
|
||||
}
|
||||
|
||||
if (!tex)
|
||||
{
|
||||
/* If it fails resort to sliced textures */
|
||||
int max_waste = flags & TEST_UTILS_TEXTURE_NO_SLICING ?
|
||||
-1 : COGL_TEXTURE_MAX_WASTE;
|
||||
CoglTexture2DSliced *tex_2ds =
|
||||
cogl_texture_2d_sliced_new_with_size (ctx,
|
||||
width,
|
||||
height,
|
||||
max_waste);
|
||||
tex = COGL_TEXTURE (tex_2ds);
|
||||
|
||||
cogl_texture_set_components (tex, components);
|
||||
}
|
||||
|
||||
if (flags & TEST_UTILS_TEXTURE_NO_AUTO_MIPMAP)
|
||||
{
|
||||
/* To be able to iterate the slices of a #CoglTexture2DSliced we
|
||||
* need to ensure the texture is allocated... */
|
||||
cogl_texture_allocate (tex, NULL); /* don't catch exceptions */
|
||||
|
||||
cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (tex),
|
||||
0, 0, 1, 1,
|
||||
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
|
||||
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
|
||||
set_auto_mipmap_cb,
|
||||
NULL); /* don't catch exceptions */
|
||||
}
|
||||
|
||||
cogl_texture_allocate (tex, NULL);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
CoglTexture *
|
||||
test_utils_texture_new_from_bitmap (CoglBitmap *bitmap,
|
||||
TestUtilsTextureFlags flags,
|
||||
gboolean premultiplied)
|
||||
{
|
||||
CoglAtlasTexture *atlas_tex;
|
||||
CoglTexture *tex;
|
||||
GError *internal_error = NULL;
|
||||
|
||||
if (!flags)
|
||||
{
|
||||
/* First try putting the texture in the atlas */
|
||||
atlas_tex = cogl_atlas_texture_new_from_bitmap (bitmap);
|
||||
|
||||
cogl_texture_set_premultiplied (COGL_TEXTURE (atlas_tex), premultiplied);
|
||||
|
||||
if (cogl_texture_allocate (COGL_TEXTURE (atlas_tex), &internal_error))
|
||||
return COGL_TEXTURE (atlas_tex);
|
||||
|
||||
cogl_object_unref (atlas_tex);
|
||||
}
|
||||
|
||||
g_clear_error (&internal_error);
|
||||
|
||||
/* If that doesn't work try a fast path 2D texture */
|
||||
tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap));
|
||||
|
||||
cogl_texture_set_premultiplied (tex, premultiplied);
|
||||
|
||||
if (g_error_matches (internal_error,
|
||||
COGL_SYSTEM_ERROR,
|
||||
COGL_SYSTEM_ERROR_NO_MEMORY))
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_clear_error (&internal_error);
|
||||
|
||||
if (!tex)
|
||||
{
|
||||
/* Otherwise create a sliced texture */
|
||||
int max_waste = flags & TEST_UTILS_TEXTURE_NO_SLICING ?
|
||||
-1 : COGL_TEXTURE_MAX_WASTE;
|
||||
CoglTexture2DSliced *tex_2ds =
|
||||
cogl_texture_2d_sliced_new_from_bitmap (bitmap, max_waste);
|
||||
tex = COGL_TEXTURE (tex_2ds);
|
||||
|
||||
cogl_texture_set_premultiplied (tex, premultiplied);
|
||||
}
|
||||
|
||||
if (flags & TEST_UTILS_TEXTURE_NO_AUTO_MIPMAP)
|
||||
{
|
||||
cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (tex),
|
||||
0, 0, 1, 1,
|
||||
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
|
||||
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
|
||||
set_auto_mipmap_cb,
|
||||
NULL); /* don't catch exceptions */
|
||||
}
|
||||
|
||||
cogl_texture_allocate (tex, NULL);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
CoglTexture *
|
||||
test_utils_texture_new_from_data (CoglContext *ctx,
|
||||
int width,
|
||||
int height,
|
||||
TestUtilsTextureFlags flags,
|
||||
CoglPixelFormat format,
|
||||
int rowstride,
|
||||
const uint8_t *data)
|
||||
{
|
||||
CoglBitmap *bmp;
|
||||
CoglTexture *tex;
|
||||
|
||||
g_assert_cmpint (format, !=, COGL_PIXEL_FORMAT_ANY);
|
||||
g_assert (data != NULL);
|
||||
|
||||
/* Wrap the data into a bitmap */
|
||||
bmp = cogl_bitmap_new_for_data (ctx,
|
||||
width, height,
|
||||
format,
|
||||
rowstride,
|
||||
(uint8_t *) data);
|
||||
|
||||
tex = test_utils_texture_new_from_bitmap (bmp, flags, TRUE);
|
||||
|
||||
cogl_object_unref (bmp);
|
||||
|
||||
return tex;
|
||||
}
|
@ -1,280 +0,0 @@
|
||||
#ifndef _TEST_UTILS_H_
|
||||
#define _TEST_UTILS_H_
|
||||
|
||||
/* NB: This header is for private and public api testing and so
|
||||
* we need consider that if we are testing the public api we should
|
||||
* just include <cogl/cogl.h> but since that will only provide
|
||||
* opaque typedefs we need to include the specific internal headers
|
||||
* for testing private apis...
|
||||
*/
|
||||
#ifdef COGL_COMPILATION
|
||||
#include <cogl/cogl-context.h>
|
||||
#include <cogl/cogl-onscreen.h>
|
||||
#include <cogl/cogl-offscreen.h>
|
||||
#include <cogl/cogl-texture-2d.h>
|
||||
#include <cogl/cogl-primitive-texture.h>
|
||||
#include <cogl/cogl-texture-2d-sliced.h>
|
||||
#include <cogl/cogl-meta-texture.h>
|
||||
#include <cogl/cogl-atlas-texture.h>
|
||||
#else
|
||||
#include <cogl/cogl.h>
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
/* We don't really care about functions that are defined without a
|
||||
header for the unit tests so we can just disable it here */
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
#endif
|
||||
|
||||
typedef enum _TestFlags
|
||||
{
|
||||
TEST_KNOWN_FAILURE = 1<<0,
|
||||
TEST_REQUIREMENT_GL = 1<<1,
|
||||
TEST_REQUIREMENT_TEXTURE_RG = 1<<5,
|
||||
TEST_REQUIREMENT_MAP_WRITE = 1<<8,
|
||||
TEST_REQUIREMENT_FENCE = 1<<11,
|
||||
} TestFlags;
|
||||
|
||||
/**
|
||||
* TestUtilsTextureFlags:
|
||||
* @TEST_UTILS_TEXTURE_NONE: No flags specified
|
||||
* @TEST_UTILS_TEXTURE_NO_AUTO_MIPMAP: Disables the automatic generation of
|
||||
* the mipmap pyramid from the base level image whenever it is
|
||||
* updated. The mipmaps are only generated when the texture is
|
||||
* rendered with a mipmap filter so it should be free to leave out
|
||||
* this flag when using other filtering modes
|
||||
* @TEST_UTILS_TEXTURE_NO_SLICING: Disables the slicing of the texture
|
||||
* @TEST_UTILS_TEXTURE_NO_ATLAS: Disables the insertion of the texture inside
|
||||
* the texture atlas used by Cogl
|
||||
*
|
||||
* Flags to pass to the test_utils_texture_new_* family of functions.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TEST_UTILS_TEXTURE_NONE = 0,
|
||||
TEST_UTILS_TEXTURE_NO_AUTO_MIPMAP = 1 << 0,
|
||||
TEST_UTILS_TEXTURE_NO_SLICING = 1 << 1,
|
||||
TEST_UTILS_TEXTURE_NO_ATLAS = 1 << 2
|
||||
} TestUtilsTextureFlags;
|
||||
|
||||
extern CoglContext *test_ctx;
|
||||
extern CoglFramebuffer *test_fb;
|
||||
|
||||
gboolean
|
||||
test_utils_init (TestFlags requirement_flags,
|
||||
TestFlags known_failure_flags);
|
||||
|
||||
void
|
||||
test_utils_fini (void);
|
||||
|
||||
/*
|
||||
* test_utils_texture_new_with_size:
|
||||
* @context: A #CoglContext
|
||||
* @width: width of texture in pixels.
|
||||
* @height: height of texture in pixels.
|
||||
* @flags: Optional flags for the texture, or %TEST_UTILS_TEXTURE_NONE
|
||||
* @components: What texture components are required
|
||||
*
|
||||
* Creates a new #CoglTexture with the specified dimensions and pixel format.
|
||||
*
|
||||
* The storage for the texture is not necessarily created before this
|
||||
* function returns. The storage can be explicitly allocated using
|
||||
* cogl_texture_allocate() or preferably you can let Cogl
|
||||
* automatically allocate the storage lazily when uploading data when
|
||||
* Cogl may know more about how the texture will be used and can
|
||||
* optimize how it is allocated.
|
||||
*
|
||||
* Return value: A newly created #CoglTexture
|
||||
*/
|
||||
CoglTexture *
|
||||
test_utils_texture_new_with_size (CoglContext *ctx,
|
||||
int width,
|
||||
int height,
|
||||
TestUtilsTextureFlags flags,
|
||||
CoglTextureComponents components);
|
||||
|
||||
/*
|
||||
* test_utils_texture_new_from_data:
|
||||
* @context: A #CoglContext
|
||||
* @width: width of texture in pixels
|
||||
* @height: height of texture in pixels
|
||||
* @flags: Optional flags for the texture, or %TEST_UTILS_TEXTURE_NONE
|
||||
* @format: the #CoglPixelFormat the buffer is stored in in RAM
|
||||
* @rowstride: the memory offset in bytes between the starts of
|
||||
* scanlines in @data
|
||||
* @data: pointer the memory region where the source buffer resides
|
||||
* @error: A #GError to catch exceptional errors or %NULL
|
||||
*
|
||||
* Creates a new #CoglTexture based on data residing in memory.
|
||||
*
|
||||
* Note: If the given @format has an alpha channel then the data
|
||||
* will be loaded into a premultiplied internal format. If you want
|
||||
* to avoid having the source data be premultiplied then you can
|
||||
* either specify that the data is already premultiplied or use
|
||||
* test_utils_texture_new_from_bitmap which lets you explicitly
|
||||
* request whether the data should internally be premultipled or not.
|
||||
*
|
||||
* Return value: A newly created #CoglTexture or %NULL on failure
|
||||
*/
|
||||
CoglTexture *
|
||||
test_utils_texture_new_from_data (CoglContext *ctx,
|
||||
int width,
|
||||
int height,
|
||||
TestUtilsTextureFlags flags,
|
||||
CoglPixelFormat format,
|
||||
int rowstride,
|
||||
const uint8_t *data);
|
||||
|
||||
/*
|
||||
* test_utils_texture_new_from_bitmap:
|
||||
* @bitmap: A #CoglBitmap pointer
|
||||
* @flags: Optional flags for the texture, or %TEST_UTILS_TEXTURE_NONE
|
||||
* @premultiplied: Whether the texture should hold premultipled data.
|
||||
* (if the bitmap already holds premultiplied data
|
||||
* and %TRUE is given then no premultiplication will
|
||||
* be done. The data will be premultipled while
|
||||
* uploading if the bitmap has an alpha channel but
|
||||
* does not already have a premultiplied format.)
|
||||
*
|
||||
* Creates a #CoglTexture from a #CoglBitmap.
|
||||
*
|
||||
* Return value: A newly created #CoglTexture or %NULL on failure
|
||||
*/
|
||||
CoglTexture *
|
||||
test_utils_texture_new_from_bitmap (CoglBitmap *bitmap,
|
||||
TestUtilsTextureFlags flags,
|
||||
gboolean premultiplied);
|
||||
|
||||
/*
|
||||
* test_utils_check_pixel:
|
||||
* @framebuffer: The #CoglFramebuffer to read from
|
||||
* @x: x coordinate of the pixel to test
|
||||
* @y: y coordinate of the pixel to test
|
||||
* @pixel: An integer of the form 0xRRGGBBAA representing the expected
|
||||
* pixel value
|
||||
*
|
||||
* This performs reads a pixel on the given cogl @framebuffer and
|
||||
* asserts that it matches the given color. The alpha channel of the
|
||||
* color is ignored. The pixels are converted to a string and compared
|
||||
* with g_assert_cmpstr so that if the comparison fails then the
|
||||
* assert will display a meaningful message
|
||||
*/
|
||||
void
|
||||
test_utils_check_pixel (CoglFramebuffer *framebuffer,
|
||||
int x, int y, uint32_t expected_pixel);
|
||||
|
||||
/**
|
||||
* @framebuffer: The #CoglFramebuffer to read from
|
||||
* @x: x coordinate of the pixel to test
|
||||
* @y: y coordinate of the pixel to test
|
||||
* @pixel: An integer of the form 0xRRGGBBAA representing the expected
|
||||
* pixel value
|
||||
*
|
||||
* This performs reads a pixel on the given cogl @framebuffer and
|
||||
* asserts that it matches the given color. The alpha channel is also
|
||||
* checked unlike with test_utils_check_pixel(). The pixels are
|
||||
* converted to a string and compared with g_assert_cmpstr so that if
|
||||
* the comparison fails then the assert will display a meaningful
|
||||
* message.
|
||||
*/
|
||||
void
|
||||
test_utils_check_pixel_and_alpha (CoglFramebuffer *fb,
|
||||
int x, int y, uint32_t expected_pixel);
|
||||
|
||||
/*
|
||||
* test_utils_check_pixel:
|
||||
* @framebuffer: The #CoglFramebuffer to read from
|
||||
* @x: x coordinate of the pixel to test
|
||||
* @y: y coordinate of the pixel to test
|
||||
* @pixel: An integer of the form 0xrrggbb representing the expected pixel value
|
||||
*
|
||||
* This performs reads a pixel on the given cogl @framebuffer and
|
||||
* asserts that it matches the given color. The alpha channel of the
|
||||
* color is ignored. The pixels are converted to a string and compared
|
||||
* with g_assert_cmpstr so that if the comparison fails then the
|
||||
* assert will display a meaningful message
|
||||
*/
|
||||
void
|
||||
test_utils_check_pixel_rgb (CoglFramebuffer *framebuffer,
|
||||
int x, int y, int r, int g, int b);
|
||||
|
||||
/*
|
||||
* test_utils_check_region:
|
||||
* @framebuffer: The #CoglFramebuffer to read from
|
||||
* @x: x coordinate of the region to test
|
||||
* @y: y coordinate of the region to test
|
||||
* @width: width of the region to test
|
||||
* @height: height of the region to test
|
||||
* @pixel: An integer of the form 0xrrggbb representing the expected region color
|
||||
*
|
||||
* Performs a read pixel on the specified region of the given cogl
|
||||
* @framebuffer and asserts that it matches the given color. The alpha
|
||||
* channel of the color is ignored. The pixels are converted to a
|
||||
* string and compared with g_assert_cmpstr so that if the comparison
|
||||
* fails then the assert will display a meaningful message
|
||||
*/
|
||||
void
|
||||
test_utils_check_region (CoglFramebuffer *framebuffer,
|
||||
int x, int y,
|
||||
int width, int height,
|
||||
uint32_t expected_rgba);
|
||||
|
||||
/*
|
||||
* test_utils_compare_pixel:
|
||||
* @screen_pixel: A pixel stored in memory
|
||||
* @expected_pixel: The expected RGBA value
|
||||
*
|
||||
* Compares a pixel from a buffer to an expected value. The pixels are
|
||||
* converted to a string and compared with g_assert_cmpstr so that if
|
||||
* the comparison fails then the assert will display a meaningful
|
||||
* message.
|
||||
*/
|
||||
void
|
||||
test_utils_compare_pixel (const uint8_t *screen_pixel, uint32_t expected_pixel);
|
||||
|
||||
/*
|
||||
* test_utils_compare_pixel_and_alpha:
|
||||
* @screen_pixel: A pixel stored in memory
|
||||
* @expected_pixel: The expected RGBA value
|
||||
*
|
||||
* Compares a pixel from a buffer to an expected value. This is
|
||||
* similar to test_utils_compare_pixel() except that it doesn't ignore
|
||||
* the alpha component.
|
||||
*/
|
||||
void
|
||||
test_utils_compare_pixel_and_alpha (const uint8_t *screen_pixel,
|
||||
uint32_t expected_pixel);
|
||||
|
||||
/*
|
||||
* test_utils_create_color_texture:
|
||||
* @context: A #CoglContext
|
||||
* @color: A color to put in the texture
|
||||
*
|
||||
* Creates a 1x1-pixel RGBA texture filled with the given color.
|
||||
*/
|
||||
CoglTexture *
|
||||
test_utils_create_color_texture (CoglContext *context,
|
||||
uint32_t color);
|
||||
|
||||
/* cogl_test_verbose:
|
||||
*
|
||||
* Queries if the user asked for verbose output or not.
|
||||
*/
|
||||
gboolean
|
||||
cogl_test_verbose (void);
|
||||
|
||||
/* test_util_is_pot:
|
||||
* @number: A number to test
|
||||
*
|
||||
* Returns whether the given integer is a power of two
|
||||
*/
|
||||
static inline gboolean
|
||||
test_utils_is_pot (unsigned int number)
|
||||
{
|
||||
/* Make sure there is only one bit set */
|
||||
return (number & (number - 1)) == 0;
|
||||
}
|
||||
|
||||
#endif /* _TEST_UTILS_H_ */
|
@ -1,63 +0,0 @@
|
||||
Outline of test categories:
|
||||
|
||||
The conform/ tests:
|
||||
-------------------
|
||||
These tests should be non-interactive unit-tests that verify a single
|
||||
feature is behaving as documented. See conform/ADDING_NEW_TESTS for more
|
||||
details.
|
||||
|
||||
Although it may seem a bit awkward; all the tests are built into a
|
||||
single binary because it makes building the tests *much* faster by avoiding
|
||||
lots of linking.
|
||||
|
||||
Each test has a wrapper script generated though so running the individual tests
|
||||
should be convenient enough. Running the wrapper script will also print out for
|
||||
convenience how you could run the test under gdb or valgrind like this for
|
||||
example:
|
||||
|
||||
NOTE: For debugging purposes, you can run this single test as follows:
|
||||
$ libtool --mode=execute \
|
||||
gdb --eval-command="b test_cogl_depth_test" \
|
||||
--args ./test-conformance -p /conform/cogl/test_cogl_depth_test
|
||||
or:
|
||||
$ env G_SLICE=always-malloc \
|
||||
libtool --mode=execute \
|
||||
valgrind ./test-conformance -p /conform/cogl/test_cogl_depth_test
|
||||
|
||||
By default the conformance tests are run offscreen. This makes the tests run
|
||||
much faster and they also don't interfere with other work you may want to do by
|
||||
constantly stealing focus. CoglOnscreen framebuffers obviously don't get tested
|
||||
this way so it's important that the tests also get run onscreen every once in a
|
||||
while, especially if changes are being made to CoglFramebuffer related code.
|
||||
Onscreen testing can be enabled by setting COGL_TEST_ONSCREEN=1 in your
|
||||
environment.
|
||||
|
||||
The micro-bench/ tests:
|
||||
-----------------------
|
||||
These should be focused performance tests, ideally testing a
|
||||
single metric. Please never forget that these tests are synthetic and if you
|
||||
are using them then you understand what metric is being tested. They probably
|
||||
don't reflect any real world application loads and the intention is that you
|
||||
use these tests once you have already determined the crux of your problem and
|
||||
need focused feedback that your changes are indeed improving matters. There is
|
||||
no exit status requirements for these tests, but they should give clear
|
||||
feedback as to their performance. If the framerate is the feedback metric, then
|
||||
the test should forcibly enable FPS debugging.
|
||||
|
||||
The data/ directory:
|
||||
--------------------
|
||||
This contains optional data (like images) that can be referenced by a test.
|
||||
|
||||
|
||||
Misc notes:
|
||||
-----------
|
||||
• All tests should ideally include a detailed description in the source
|
||||
explaining exactly what the test is for, how the test was designed to work,
|
||||
and possibly a rationale for the approach taken for testing.
|
||||
|
||||
• When running tests under Valgrind, you should follow the instructions
|
||||
available here:
|
||||
|
||||
http://live.gnome.org/Valgrind
|
||||
|
||||
and also use the suppression file available inside the data/ directory.
|
@ -1,2 +0,0 @@
|
||||
HAVE_GL=@HAVE_GL@
|
||||
HAVE_GLES2=@HAVE_GLES2@
|
@ -1,165 +0,0 @@
|
||||
{
|
||||
ioctl_1
|
||||
Memcheck:Param
|
||||
ioctl(generic)
|
||||
fun:ioctl
|
||||
fun:driDrawableInitVBlank
|
||||
fun:intelMakeCurrent
|
||||
fun:glXMakeContextCurrent
|
||||
}
|
||||
|
||||
{
|
||||
ioctl_2
|
||||
Memcheck:Param
|
||||
ioctl(generic)
|
||||
fun:ioctl
|
||||
fun:driDrawableGetMSC32
|
||||
fun:clutter_backend_glx_redraw
|
||||
}
|
||||
|
||||
{
|
||||
ioctl_3
|
||||
Memcheck:Param
|
||||
ioctl(generic)
|
||||
fun:ioctl
|
||||
fun:driWaitForMSC32
|
||||
fun:clutter_backend_glx_redraw
|
||||
}
|
||||
|
||||
{
|
||||
mesa_init_context
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:glXCreateNewContext
|
||||
}
|
||||
|
||||
{
|
||||
type_register
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:g_type_register_*
|
||||
}
|
||||
|
||||
{
|
||||
type_ref
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:g_type_class_ref
|
||||
}
|
||||
|
||||
{
|
||||
type_interface_prereq
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:g_type_interface_add_prerequisite
|
||||
}
|
||||
|
||||
{
|
||||
get_charset
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:g_get_charset
|
||||
}
|
||||
|
||||
{
|
||||
glx_query_version
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:glXQueryVersion
|
||||
}
|
||||
|
||||
{
|
||||
glx_create_context
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:glXCreateNewContext
|
||||
}
|
||||
|
||||
{
|
||||
glx_make_current
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:glXMakeContextCurrent
|
||||
}
|
||||
|
||||
{
|
||||
gl_draw_arrays
|
||||
Memcheck:Leak
|
||||
fun:*malloc
|
||||
...
|
||||
fun:glDrawArrays
|
||||
}
|
||||
|
||||
{
|
||||
cogl_clear
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:cogl_clear
|
||||
}
|
||||
|
||||
{
|
||||
default_font
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:clutter_backend_get_font_name
|
||||
}
|
||||
|
||||
{
|
||||
id_pool
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:clutter_id_pool_new
|
||||
}
|
||||
|
||||
{
|
||||
x_open_display
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:XOpenDisplay
|
||||
}
|
||||
|
||||
# ... and font descriptions from every "sans 12" type string
|
||||
{
|
||||
pango_font_description_from_string
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:pango_font_description_from_string
|
||||
}
|
||||
|
||||
# other lib init
|
||||
{
|
||||
fontconfig_init
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:FcConfigParseAndLoad
|
||||
}
|
||||
|
||||
{
|
||||
freetype_init
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:FT_Open_Face
|
||||
}
|
||||
|
||||
{
|
||||
x_init_ext
|
||||
Memcheck:Leak
|
||||
fun:*alloc
|
||||
...
|
||||
fun:XInitExtension
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
cogl_run_tests = find_program('run-tests.sh')
|
||||
|
||||
cdata = configuration_data()
|
||||
cdata.set('HAVE_GL', have_gl.to_int())
|
||||
cdata.set('HAVE_GLES2', have_gles2.to_int())
|
||||
|
||||
cogl_installed_tests_libexecdir = join_paths(
|
||||
mutter_installed_tests_libexecdir, 'cogl', 'conform')
|
||||
if have_installed_tests
|
||||
install_data('run-tests.sh', install_dir: cogl_installed_tests_libexecdir)
|
||||
endif
|
||||
|
||||
cogl_config_env = configure_file(
|
||||
input: 'config.env.in',
|
||||
output: 'config.env',
|
||||
configuration: cdata,
|
||||
install: have_installed_tests,
|
||||
install_dir: cogl_installed_tests_libexecdir,
|
||||
)
|
||||
|
||||
subdir('unit')
|
@ -1,169 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o pipefail
|
||||
|
||||
if test -z "$G_DEBUG"; then
|
||||
G_DEBUG=fatal-warnings
|
||||
else
|
||||
G_DEBUG="$G_DEBUG,fatal-warnings"
|
||||
fi
|
||||
|
||||
export G_DEBUG
|
||||
|
||||
ENVIRONMENT_CONFIG=$1
|
||||
shift
|
||||
|
||||
TEST_BINARY=$1
|
||||
shift
|
||||
|
||||
UNIT_TESTS=$1
|
||||
shift
|
||||
|
||||
. "$ENVIRONMENT_CONFIG"
|
||||
|
||||
set +m
|
||||
|
||||
LOG=$(mktemp)
|
||||
|
||||
trap "" ERR
|
||||
trap "" SIGABRT
|
||||
trap "" SIGFPE
|
||||
trap "" SIGSEGV
|
||||
|
||||
EXIT=0
|
||||
MISSING_FEATURE="WARNING: Missing required feature";
|
||||
KNOWN_FAILURE="WARNING: Test is known to fail";
|
||||
|
||||
if [ -z "$RUN_TESTS_QUIET" ]; then
|
||||
echo "Key:"
|
||||
echo "ok = Test passed"
|
||||
echo "n/a = Driver is missing a feature required for the test"
|
||||
echo "FAIL = Unexpected failure"
|
||||
echo "FIXME = Test failed, but it was an expected failure"
|
||||
echo "PASS! = Unexpected pass"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
get_status()
|
||||
{
|
||||
case $1 in
|
||||
# Special value we use to indicate that the test failed
|
||||
# but it was an expected failure so don't fail the
|
||||
# overall test run as a result...
|
||||
300)
|
||||
echo -n "FIXME";;
|
||||
# Special value we use to indicate that the test passed
|
||||
# but we weren't expecting it to pass‽
|
||||
400)
|
||||
echo -n 'PASS!';;
|
||||
|
||||
# Special value to indicate the test is missing a required feature
|
||||
500)
|
||||
echo -n "n/a";;
|
||||
|
||||
0)
|
||||
echo -n "ok";;
|
||||
|
||||
*)
|
||||
echo -n "FAIL";;
|
||||
esac
|
||||
}
|
||||
|
||||
run_test()
|
||||
{
|
||||
if [ -n "${VERBOSE-}" ]; then
|
||||
echo "running $TEST_BINARY $1:"
|
||||
$TEST_BINARY $1 2>&1 | tee "$LOG"
|
||||
else
|
||||
$($TEST_BINARY $1 &> "$LOG")
|
||||
fi
|
||||
TMP=$?
|
||||
var_name=$2_result
|
||||
eval "$var_name=$TMP"
|
||||
if grep -q "$MISSING_FEATURE" "$LOG"; then
|
||||
if test "$TMP" -ne 0; then
|
||||
eval "$var_name=500"
|
||||
else
|
||||
eval "$var_name=400"
|
||||
fi
|
||||
elif grep -q "$KNOWN_FAILURE" "$LOG"; then
|
||||
if test $TMP -ne 0; then
|
||||
eval "$var_name=300"
|
||||
else
|
||||
eval "$var_name=400"
|
||||
fi
|
||||
else
|
||||
if test "$TMP" -ne 0; then EXIT=$TMP; fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -z "$UNIT_TESTS" ]; then
|
||||
echo Missing unit-tests file or names
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TITLE_FORMAT="%35s"
|
||||
printf "$TITLE_FORMAT" "Test"
|
||||
|
||||
if test "$HAVE_GL" -eq 1; then
|
||||
GL_FORMAT=" %6s %8s %7s %6s"
|
||||
printf "$GL_FORMAT" "GL+GLSL" "GL3"
|
||||
fi
|
||||
if test "$HAVE_GLES2" -eq 1; then
|
||||
GLES2_FORMAT=" %6s"
|
||||
printf "$GLES2_FORMAT" "ES2"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
if [ -f "$UNIT_TESTS" ]; then
|
||||
UNIT_TESTS="$(cat $UNIT_TESTS)"
|
||||
fi
|
||||
|
||||
if [ -z "$RUN_TESTS_QUIET" ] || [ "$(echo "$UNIT_TESTS" | wc -w )" -gt 1 ]; then
|
||||
echo ""
|
||||
fi
|
||||
|
||||
for test in $UNIT_TESTS
|
||||
do
|
||||
printf $TITLE_FORMAT "$test:"
|
||||
export COGL_DEBUG=
|
||||
|
||||
if test "$HAVE_GL" -eq 1; then
|
||||
export COGL_DRIVER=gl
|
||||
# NB: we can't explicitly disable fixed + glsl in this case since
|
||||
# the arbfp code only supports fragment processing so we need either
|
||||
# the fixed or glsl vertends
|
||||
export COGL_DEBUG=
|
||||
run_test "$test" gl_arbfp
|
||||
|
||||
export COGL_DRIVER=gl
|
||||
export COGL_DEBUG=disable-fixed,disable-arbfp
|
||||
run_test "$test" gl_glsl
|
||||
|
||||
export COGL_DRIVER=gl3
|
||||
export COGL_DEBUG=
|
||||
run_test "$test" gl3
|
||||
fi
|
||||
|
||||
if test "$HAVE_GLES2" -eq 1; then
|
||||
export COGL_DRIVER=gles2
|
||||
export COGL_DEBUG=
|
||||
run_test "$test" gles2
|
||||
fi
|
||||
|
||||
if test "$HAVE_GL" -eq 1; then
|
||||
printf "$GL_FORMAT" \
|
||||
"$(get_status "$gl_glsl_result")" \
|
||||
"$(get_status "$gl3_result")"
|
||||
fi
|
||||
if test "$HAVE_GLES2" -eq 1; then
|
||||
printf "$GLES2_FORMAT" \
|
||||
"$(get_status "$gles2_result")"
|
||||
fi
|
||||
echo ""
|
||||
done
|
||||
|
||||
rm "$LOG"
|
||||
|
||||
exit "$EXIT"
|
@ -1,39 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
TEST_BINARY=$1
|
||||
shift
|
||||
|
||||
SYMBOL_PREFIX=$1
|
||||
shift
|
||||
|
||||
UNIT_TEST=$1
|
||||
shift
|
||||
|
||||
test -z "${UNIT_TEST}" && {
|
||||
echo "Usage: $0 UNIT_TEST"
|
||||
exit 1
|
||||
}
|
||||
|
||||
BINARY_NAME=$(basename "$TEST_BINARY")
|
||||
UNIT_TEST=$(echo "$UNIT_TEST"|sed 's/-/_/g')
|
||||
|
||||
echo "Running: ./$BINARY_NAME ${UNIT_TEST} $*"
|
||||
echo ""
|
||||
COGL_TEST_VERBOSE=1 "$TEST_BINARY" "${UNIT_TEST}" "$@"
|
||||
exit_val=$?
|
||||
|
||||
if test "$exit_val" -eq 0; then
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "NOTE: For debugging purposes, you can run this single test as follows:"
|
||||
echo "$ libtool --mode=execute \\"
|
||||
echo " gdb --eval-command=\"start\" --eval-command=\"b ${UNIT_TEST#${SYMBOL_PREFIX}}\" \\"
|
||||
echo " --args ./$BINARY_NAME ${UNIT_TEST}"
|
||||
echo "or:"
|
||||
echo "$ env G_SLICE=always-malloc \\"
|
||||
echo " libtool --mode=execute \\"
|
||||
echo " valgrind ./$BINARY_NAME ${UNIT_TEST}"
|
||||
|
||||
exit "$exit_val"
|
@ -1,42 +0,0 @@
|
||||
cogl_test_unit_sources = [
|
||||
'test-unit-main.c',
|
||||
]
|
||||
|
||||
cogl_test_unit_includes = [
|
||||
cogl_includepath,
|
||||
cogl_test_fixtures_includepath,
|
||||
]
|
||||
|
||||
libmutter_cogl_test_unit = executable('test-unit',
|
||||
sources: cogl_test_unit_sources,
|
||||
c_args: cogl_debug_c_args + [
|
||||
'-DCOGL_DISABLE_DEPRECATED',
|
||||
'-DCOGL_COMPILATION',
|
||||
'-DTESTS_DATADIR="@0@/tests/data"'.format(cogl_srcdir),
|
||||
],
|
||||
include_directories: cogl_test_unit_includes,
|
||||
dependencies: [
|
||||
libmutter_cogl_dep,
|
||||
libmutter_cogl_test_fixtures_dep,
|
||||
],
|
||||
install: false,
|
||||
)
|
||||
|
||||
cogl_unit_tests = run_command(
|
||||
find_program('meson/find-unit-tests.sh'), cogl_srcdir, '/dev/stdout',
|
||||
check: true,
|
||||
).stdout().strip().split('\n')
|
||||
|
||||
foreach test_target: cogl_unit_tests
|
||||
test_name = '-'.join(test_target.split('_'))
|
||||
test(test_name, cogl_run_tests,
|
||||
suite: ['cogl', 'cogl/unit'],
|
||||
env: ['RUN_TESTS_QUIET=1'],
|
||||
args: [
|
||||
cogl_config_env,
|
||||
libmutter_cogl_test_unit,
|
||||
'unit_test_' + test_target
|
||||
],
|
||||
is_parallel: false,
|
||||
)
|
||||
endforeach
|
@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
inputdir="$1"
|
||||
outputfile="$2"
|
||||
|
||||
echo > "$outputfile"
|
||||
|
||||
grep -h -r --include \*.c UNIT_TEST "$inputdir" | \
|
||||
sed -n -e 's/^UNIT_TEST *( *\([a-zA-Z0-9_]\{1,\}\).*/\1/p' > "$outputfile"
|
@ -1,51 +0,0 @@
|
||||
#include "cogl-config.h"
|
||||
|
||||
#include <gmodule.h>
|
||||
|
||||
#include <test-fixtures/test-unit.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GModule *main_module;
|
||||
const CoglUnitTest *unit_test;
|
||||
int i;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
g_printerr ("usage %s UNIT_TEST\n", argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* Just for convenience in case people try passing the wrapper
|
||||
* filenames for the UNIT_TEST argument we normalize '-' characters
|
||||
* to '_' characters... */
|
||||
for (i = 0; argv[1][i]; i++)
|
||||
{
|
||||
if (argv[1][i] == '-')
|
||||
argv[1][i] = '_';
|
||||
}
|
||||
|
||||
main_module = g_module_open (NULL, /* use main module */
|
||||
0 /* flags */);
|
||||
|
||||
if (!g_module_symbol (main_module, argv[1], (void **) &unit_test))
|
||||
{
|
||||
g_printerr ("Unknown test name \"%s\"\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (test_utils_init (unit_test->requirement_flags,
|
||||
unit_test->known_failure_flags)
|
||||
|| g_getenv ("COGL_TEST_TRY_EVERYTHING") != NULL)
|
||||
{
|
||||
unit_test->run ();
|
||||
test_utils_fini ();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user