summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKonstantin <ria.freelander@gmail.com>2022-06-25 21:58:08 +0300
committerKonstantin <ria.freelander@gmail.com>2022-12-01 08:41:57 +0000
commitddcd4846d1fa8c408733f4435a52344d3eab850e (patch)
treea70161afb4e21bb3534c09ad4446f35d577eba4b /test
parentfdebbc60d89cdc1b3353424b6568b25a61dcf372 (diff)
meson: add glamor gles2 tests
Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Emma Anholt <emma@anholt.net>
Diffstat (limited to 'test')
-rw-r--r--test/bugs/bug1354.c149
-rw-r--r--test/bugs/meson.build51
-rw-r--r--test/meson.build58
-rwxr-xr-xtest/scripts/xephyr-glamor-gles2-piglit.sh34
4 files changed, 287 insertions, 5 deletions
diff --git a/test/bugs/bug1354.c b/test/bugs/bug1354.c
new file mode 100644
index 000000000..edc3f228c
--- /dev/null
+++ b/test/bugs/bug1354.c
@@ -0,0 +1,149 @@
+#include <xcb/xcb.h>
+#include <xcb/xcb_aux.h>
+#include <xcb/xcb_image.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <ctype.h>
+#include <unistd.h>
+
+/*
+ * This is a test which try to test correct glamor colors when rendered.
+ * It should be run with fullscreen Xephyr (with glamor) with present and with
+ * etalon high-level Xserver (can be any, on CI - Xvfb). For testing this test
+ * creates an image in Xephyr X server, which filled by one of colors defined in
+ * test_pixels. Then it captures central pixel from both Xephyr and Xserver above.
+ * If pixels differ - test failed. Sleep is used to ensure than presentation on both
+ * Xephyr and Xvfb kicks (xcb_aux_sync was not enough) and test results will be actual
+ */
+
+#define WIDTH 300
+#define HEIGHT 300
+
+int get_display_pixel(xcb_connection_t* c, xcb_drawable_t win);
+void draw_display_pixel(xcb_connection_t* c, xcb_drawable_t win, uint32_t pixel_color);
+
+int get_display_pixel(xcb_connection_t* c, xcb_drawable_t win)
+{
+ xcb_image_t *image;
+ uint32_t pixel;
+ int format = XCB_IMAGE_FORMAT_XY_PIXMAP;
+
+ image = xcb_image_get (c, win,
+ 0, 0, WIDTH, HEIGHT,
+ UINT32_MAX,
+ format);
+ if (!image) {
+ printf("xcb_image_get failed: exiting\n");
+ exit(1);
+ }
+
+ pixel = xcb_image_get_pixel(image, WIDTH/2, HEIGHT/2);
+
+ return pixel;
+}
+
+void draw_display_pixel(xcb_connection_t* c, xcb_drawable_t win, uint32_t pixel_color)
+{
+ xcb_gcontext_t foreground;
+ uint32_t mask = 0;
+
+ xcb_rectangle_t rectangles[] = {
+ {0, 0, WIDTH, HEIGHT},
+ };
+
+ foreground = xcb_generate_id (c);
+ mask = XCB_GC_FOREGROUND | XCB_GC_LINE_WIDTH | XCB_GC_SUBWINDOW_MODE;
+
+ uint32_t values[] = {
+ pixel_color,
+ 20,
+ XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS
+ };
+
+ xcb_create_gc (c, foreground, win, mask, values);
+
+ xcb_poly_fill_rectangle (c, win, foreground, 1, rectangles);
+ xcb_aux_sync ( c );
+}
+
+
+int main(int argc, char* argv[])
+{
+ xcb_connection_t *c, *r;
+ xcb_screen_t *screen1, *screen2;
+ xcb_drawable_t win1, win2;
+ char *name_test = NULL, *name_relevant = NULL;
+ uint32_t pixel_server1, pixel_server2;
+ int result = 0;
+ uint32_t test_pixels[3] = {0xff0000, 0x00ff00, 0x0000ff};
+ int gv;
+
+ while ((gv = getopt (argc, argv, "t:r:")) != -1)
+ switch (gv)
+ {
+ case 't':
+ name_test = optarg;
+ break;
+ case 'r':
+ name_relevant = optarg;
+ break;
+ case '?':
+ if (optopt == 't' || optopt == 'r')
+ fprintf (stderr, "Option -%c requires an argument - test screen name.\n", optopt);
+ else if (isprint (optopt))
+ fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+ else
+ fprintf (stderr,
+ "Unknown option character `\\x%x'.\n",
+ optopt);
+ return 1;
+ default:
+ abort ();
+ }
+
+ printf("test=%s, rel=%s\n", name_test, name_relevant);
+
+ c = xcb_connect (name_test, NULL);
+ r = xcb_connect (name_relevant, NULL);
+
+ /* get the first screen */
+ screen1 = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
+
+ win1 = xcb_generate_id (c);
+ xcb_create_window (c, /* Connection */
+ XCB_COPY_FROM_PARENT, /* depth (same as root)*/
+ win1, /* window Id */
+ screen1->root, /* parent window */
+ 0, 0, /* x, y */
+ WIDTH, HEIGHT, /* width, height */
+ 20, /* border_width */
+ XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class */
+ screen1->root_visual, /* visual */
+ 0, NULL ); /* masks, not used yet */
+
+
+ /* Map the window on the screen */
+ xcb_map_window (c, win1);
+ xcb_aux_sync(c);
+
+ /* get the first screen */
+ screen2 = xcb_setup_roots_iterator (xcb_get_setup (r)).data;
+
+ /* root window */
+ win2 = screen2->root;
+
+ for(int i = 0; i < 3; i++)
+ {
+ draw_display_pixel(c, win1, test_pixels[i]);
+ xcb_aux_sync(r);
+ pixel_server1 = get_display_pixel(c, win1);
+ sleep(1);
+ pixel_server2 = get_display_pixel(r, win2);
+ xcb_aux_sync(r);
+ printf("p=0x%x, p2=0x%x\n", pixel_server1, pixel_server2);
+ result+= pixel_server1 == pixel_server2;
+ }
+ return result == 3 ? 0 : 1;
+}
diff --git a/test/bugs/meson.build b/test/bugs/meson.build
new file mode 100644
index 000000000..1f5305f56
--- /dev/null
+++ b/test/bugs/meson.build
@@ -0,0 +1,51 @@
+xcb_dep = dependency('xcb', required: false)
+xcb_image_dep = dependency('xcb-image', required: false)
+xcb_util_dep = dependency('xcb-util', required: false)
+
+if get_option('xvfb')
+ xvfb_args = [
+ xvfb_server.full_path(),
+ '-screen',
+ 'scrn',
+ '1280x1024x24'
+ ]
+
+ if xcb_dep.found() and xcb_image_dep.found() and xcb_util_dep.found() and get_option('xvfb') and get_option('xephyr') and build_glamor
+ bug1354 = executable('bug1354', 'bug1354.c', dependencies: [xcb_dep, xcb_image_dep, xcb_util_dep])
+ test('bug1354-gl',
+ simple_xinit,
+ args: [simple_xinit.full_path(),
+ bug1354.full_path(),
+ '-t',':201','-r',':200',
+ '----',
+ xephyr_server.full_path(),
+ '-glamor',
+ '-schedMax', '2000',
+ ':201',
+ '--',
+ xvfb_args,
+ ':200'
+ ],
+ suite: 'xephyr-glamor',
+ timeout: 300,
+ )
+ test('bug1354-gles',
+ simple_xinit,
+ args: [simple_xinit.full_path(),
+ bug1354.full_path(),
+ '-t',':199','-r',':198',
+ '----',
+ xephyr_server.full_path(),
+ '-glamor_gles2',
+ '-schedMax', '2000',
+ ':199',
+ '--',
+ xvfb_args,
+ ':198'
+ ],
+ suite: 'xephyr-glamor-gles2',
+ timeout: 300,
+ should_fail: true,
+ )
+ endif
+endif \ No newline at end of file
diff --git a/test/meson.build b/test/meson.build
index a8d9e8497..662eee4ef 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -9,13 +9,24 @@ piglit_env.set('XSERVER_DIR', meson.source_root())
piglit_env.set('XSERVER_BUILDDIR', meson.build_root())
some_ops = ' -o clear,src,dst,over,xor,disjointover'
-rendercheck_tests = [
+gles2_working_formats = ' -f '+ ','.join(['a8',
+ 'a8r8g8b8',
+ 'x8r8g8b8',
+ 'b8g8r8a8',
+ 'b8g8r8x8',
+ 'r8g8b8',
+ 'r5g5b5',
+ 'b5g5r5',
+ 'r5g6b5',
+ 'b5g6r5',
+ 'b8g8r8',
+ 'x8b8g8r8',
+ 'x2r10g10b10',
+ 'x2b10g10r10'])
+rendercheck_tests_noblend = [
['blend/All/a8r8g8b8', '-t blend -f a8r8g8b8'],
['blend/All/x8r8g8b8', '-t blend -f a8r8g8b8,x8r8g8b8'],
['blend/All/a2r10g10b10', '-t blend -f a8r8g8b8,a2r10g10b10'],
- ['blend/Clear', '-t blend -o clear'],
- ['blend/Src', '-t blend -o src'],
- ['blend/Over', '-t blend -o over'],
['composite/Some/a8r8g8b8', '-t composite -f a8r8g8b8' + some_ops],
['composite/Some/x8r8g8b8', '-t composite -f a8r8g8b8,x8r8g8b8' + some_ops],
['composite/Some/a2r10g10b10', '-t composite -f a8r8g8b8,a2r10g10b10' + some_ops],
@@ -34,7 +45,19 @@ rendercheck_tests = [
['LibreOffice xRGB', '-t libreoffice_xrgb'],
['GTK ARGB vs xBGR', '-t gtk_argb_xbgr'],
]
-
+rendercheck_blend = [
+ ['blend/Clear', '-t blend -o clear'],
+ ['blend/Src', '-t blend -o src'],
+ ['blend/Over', '-t blend -o over'],
+]
+#Exclude 15bpp for now due to GLES limitation (see glamor.c:470)
+rendercheck_blend_gles2 = [
+ ['blend/Clear', '-t blend -o clear' + gles2_working_formats],
+ ['blend/Src', '-t blend -o src' + gles2_working_formats],
+ ['blend/Over', '-t blend -o over' + gles2_working_formats],
+]
+rendercheck_tests = rendercheck_blend + rendercheck_tests_noblend
+rendercheck_tests_gles2 = rendercheck_blend_gles2 + rendercheck_tests_noblend
rendercheck = find_program('rendercheck', required:false)
if get_option('xvfb')
@@ -76,6 +99,12 @@ if get_option('xvfb')
timeout: 1200,
suite: 'xephyr-glamor',
)
+ test('XTS',
+ find_program('scripts/xephyr-glamor-gles2-piglit.sh'),
+ env: piglit_env,
+ timeout: 1200,
+ suite: 'xephyr-glamor-gles2',
+ )
if rendercheck.found()
foreach rctest: rendercheck_tests
@@ -96,6 +125,24 @@ if get_option('xvfb')
timeout: 300,
)
endforeach
+ foreach rctest: rendercheck_tests_gles2
+ test(rctest[0],
+ simple_xinit,
+ args: [simple_xinit.full_path(),
+ rendercheck.path(),
+ rctest[1].split(' '),
+ '----',
+ xephyr_server.full_path(),
+ '-glamor_gles2',
+ '-glamor-skip-present',
+ '-schedMax', '2000',
+ '--',
+ xvfb_args,
+ ],
+ suite: 'xephyr-glamor-gles2',
+ timeout: 300,
+ )
+ endforeach
endif
endif
endif
@@ -116,6 +163,7 @@ endif
subdir('bigreq')
subdir('damage')
subdir('sync')
+subdir('bugs')
if build_xorg
# Tests that require at least some DDX functions in order to fully link
diff --git a/test/scripts/xephyr-glamor-gles2-piglit.sh b/test/scripts/xephyr-glamor-gles2-piglit.sh
new file mode 100755
index 000000000..59ca12d26
--- /dev/null
+++ b/test/scripts/xephyr-glamor-gles2-piglit.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# this times out on Travis, because the tests take too long.
+if test "x$TRAVIS_BUILD_DIR" != "x"; then
+ exit 77
+fi
+
+# Start a Xephyr server using glamor. Since the test environment is
+# headless, we start an Xvfb first to host the Xephyr.
+export PIGLIT_RESULTS_DIR=$XSERVER_BUILDDIR/test/piglit-results/xephyr-glamor-gles2
+
+export SERVER_COMMAND="$XSERVER_BUILDDIR/hw/kdrive/ephyr/Xephyr \
+ -glamor_gles2 \
+ -glamor-skip-present \
+ -noreset \
+ -schedMax 2000 \
+ -screen 1280x1024"
+
+# Tests that currently fail on llvmpipe on CI
+PIGLIT_ARGS="$PIGLIT_ARGS -x xcleararea@6"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xcleararea@7"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xclearwindow@4"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xclearwindow@5"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xcopyarea@1"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@1"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@2"
+
+export PIGLIT_ARGS
+
+$XSERVER_BUILDDIR/test/simple-xinit \
+ $XSERVER_DIR/test/scripts/run-piglit.sh \
+ -- \
+ $XSERVER_BUILDDIR/hw/vfb/Xvfb \
+ -screen scrn 1280x1024x24