tests: Less linking
Build just a few binaries for the gsk tests, avoiding the overhead of linking each one.
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "gsk/gskrendernodeprivate.h"
|
||||
|
||||
#include "gskinternaltests.h"
|
||||
|
||||
static void
|
||||
test_can_diff_basic (void)
|
||||
{
|
||||
@@ -95,14 +97,9 @@ test_can_diff_transform (void)
|
||||
gsk_transform_unref (t2);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
void
|
||||
add_diff_tests (void)
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/node/can-diff/basic", test_can_diff_basic);
|
||||
g_test_add_func ("/node/can-diff/transform", test_can_diff_transform);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
36
testsuite/gsk/gskinternaltests.c
Normal file
36
testsuite/gsk/gskinternaltests.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright © 2023 Matthias Clasen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gskinternaltests.h"
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
add_diff_tests ();
|
||||
add_half_float_tests ();
|
||||
add_rounded_rect_tests ();
|
||||
add_misc_tests ();
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
6
testsuite/gsk/gskinternaltests.h
Normal file
6
testsuite/gsk/gskinternaltests.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
void add_diff_tests (void);
|
||||
void add_half_float_tests (void);
|
||||
void add_rounded_rect_tests (void);
|
||||
void add_misc_tests (void);
|
||||
34
testsuite/gsk/gsktests.c
Normal file
34
testsuite/gsk/gsktests.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright © 2023 Matthias Clasen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gsktests.h"
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
add_transform_tests ();
|
||||
add_shader_tests ();
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
4
testsuite/gsk/gsktests.h
Normal file
4
testsuite/gsk/gsktests.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
void add_transform_tests (void);
|
||||
void add_shader_tests (void);
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "gsk/gl/fp16private.h"
|
||||
|
||||
#include "gskinternaltests.h"
|
||||
|
||||
static void
|
||||
test_constants (void)
|
||||
{
|
||||
@@ -95,14 +97,10 @@ test_many (void)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
void
|
||||
add_half_float_tests (void)
|
||||
{
|
||||
(g_test_init) (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/half-float/constants", test_constants);
|
||||
g_test_add_func ("/half-float/roundtrip", test_roundtrip);
|
||||
g_test_add_func ("/half-float/many", test_many);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
@@ -242,69 +242,52 @@ foreach test : node_parser_tests
|
||||
endif
|
||||
endforeach
|
||||
|
||||
tests = [
|
||||
['transform'],
|
||||
['shader'],
|
||||
test_sources = [
|
||||
'transform.c',
|
||||
'shader.c',
|
||||
'gsktests.c',
|
||||
]
|
||||
|
||||
test_cargs = []
|
||||
gsktests = executable('gsktests',
|
||||
test_sources,
|
||||
dependencies: libgtk_dep,
|
||||
c_args: common_cflags,
|
||||
)
|
||||
|
||||
foreach t : tests
|
||||
test_name = t.get(0)
|
||||
test_srcs = ['@0@.c'.format(test_name)] + t.get(1, [])
|
||||
test_extra_cargs = t.get(2, [])
|
||||
test_extra_ldflags = t.get(3, [])
|
||||
|
||||
test_exe = executable(test_name, test_srcs,
|
||||
dependencies : libgtk_dep,
|
||||
c_args : test_cargs + test_extra_cargs + common_cflags,
|
||||
link_args : test_extra_ldflags,
|
||||
)
|
||||
|
||||
test(test_name, test_exe,
|
||||
args: [ '--tap', '-k' ],
|
||||
protocol: 'tap',
|
||||
env: [
|
||||
test('gsktests', gsktests,
|
||||
args: [ '--tap', '-k' ],
|
||||
protocol: 'tap',
|
||||
env: [
|
||||
'GSK_RENDERER=cairo',
|
||||
'GTK_A11Y=test',
|
||||
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
|
||||
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
|
||||
],
|
||||
suite: 'gsk',
|
||||
)
|
||||
endforeach
|
||||
],
|
||||
suite: 'gsk',
|
||||
)
|
||||
|
||||
internal_tests = [
|
||||
[ 'diff' ],
|
||||
[ 'half-float' ],
|
||||
['rounded-rect'],
|
||||
['misc'],
|
||||
internal_test_sources = [
|
||||
'diff',
|
||||
'half-float',
|
||||
'rounded-rect',
|
||||
'misc',
|
||||
'gskinternaltests.c',
|
||||
]
|
||||
|
||||
foreach t : internal_tests
|
||||
test_name = t.get(0)
|
||||
test_srcs = ['@0@.c'.format(test_name)] + t.get(1, [])
|
||||
test_extra_cargs = t.get(2, [])
|
||||
test_extra_ldflags = t.get(3, [])
|
||||
gskinternaltests = executable('gskinternaltests',
|
||||
test_sources,
|
||||
dependencies: libgtk_static_dep,
|
||||
c_args: common_cflags,
|
||||
)
|
||||
|
||||
test_exe = executable(test_name,
|
||||
sources: test_srcs,
|
||||
dependencies : libgtk_static_dep,
|
||||
c_args : test_cargs + test_extra_cargs + common_cflags,
|
||||
link_args : test_extra_ldflags,
|
||||
)
|
||||
|
||||
test(test_name, test_exe,
|
||||
args: [ '--tap', '-k' ],
|
||||
protocol: 'tap',
|
||||
env: [
|
||||
test('gskinternaltests', gskinternaltests,
|
||||
args: [ '--tap', '-k' ],
|
||||
protocol: 'tap',
|
||||
env: [
|
||||
'GSK_RENDERER=cairo',
|
||||
'GTK_A11Y=test',
|
||||
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
|
||||
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
|
||||
],
|
||||
suite: 'gsk',
|
||||
)
|
||||
endforeach
|
||||
|
||||
|
||||
],
|
||||
suite: 'gsk',
|
||||
)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "gsk/gskrendernodeprivate.h"
|
||||
|
||||
#include "gskinternaltests.h"
|
||||
|
||||
static void
|
||||
test_rendernode_gvalue (void)
|
||||
{
|
||||
@@ -82,15 +84,10 @@ test_conic_gradient_angle (void)
|
||||
gsk_render_node_unref (node);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
void
|
||||
add_misc_tests (void)
|
||||
{
|
||||
(g_test_init) (&argc, &argv, NULL);
|
||||
gtk_init ();
|
||||
|
||||
g_test_add_func ("/rendernode/gvalue", test_rendernode_gvalue);
|
||||
g_test_add_func ("/rendernode/border/uniform", test_bordernode_uniform);
|
||||
g_test_add_func ("/rendernode/conic-gradient/angle", test_conic_gradient_angle);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <gsk/gskroundedrectprivate.h>
|
||||
|
||||
#include "gskinternaltests.h"
|
||||
|
||||
static void
|
||||
test_contains_rect (void)
|
||||
{
|
||||
@@ -160,17 +162,12 @@ test_to_float (void)
|
||||
g_assert_true (flt[10] == 9. && flt[11] == 11.);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
void
|
||||
add_rounded_rect_tests (void)
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/rounded-rect/contains-rect", test_contains_rect);
|
||||
g_test_add_func ("/rounded-rect/intersects-rect", test_intersects_rect);
|
||||
g_test_add_func ("/rounded-rect/contains-point", test_contains_point);
|
||||
g_test_add_func ("/rounded-rect/is-circular", test_is_circular);
|
||||
g_test_add_func ("/rounded-rect/to-float", test_to_float);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gsktests.h"
|
||||
|
||||
/* shader fragment as found in nature */
|
||||
const char shader0[] =
|
||||
"// author: bobylito\n"
|
||||
@@ -290,16 +292,11 @@ test_compile (void)
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
void
|
||||
add_shader_tests (void)
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/shader/create/simple", test_create_simple);
|
||||
g_test_add_func ("/shader/create/data", test_create_data);
|
||||
g_test_add_func ("/shader/format-args", test_format_args);
|
||||
g_test_add_func ("/shader/compile", test_compile);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gsktests.h"
|
||||
|
||||
#define EPSILON (1.f / 1024 / 32) /* 2^-15 */
|
||||
|
||||
/* macros stolen from graphene testsuite, so they get to keep their names */
|
||||
@@ -843,12 +845,9 @@ test_rotate3d_transform (void)
|
||||
gsk_transform_unref (t2);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
void
|
||||
add_transform_tests (void)
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/transform/conversions/simple", test_conversions_simple);
|
||||
g_test_add_func ("/transform/conversions/transformed", test_conversions_transformed);
|
||||
g_test_add_func ("/transform/identity", test_identity);
|
||||
@@ -865,6 +864,4 @@ main (int argc,
|
||||
g_test_add_func ("/transform/perspective", test_perspective_transform);
|
||||
g_test_add_func ("/transform/rotate", test_rotate_transform);
|
||||
g_test_add_func ("/transform/rotate3d", test_rotate3d_transform);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user