summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2019-07-03 11:34:37 -0700
committerEric Anholt <[email protected]>2019-09-04 16:43:36 -0700
commit281466332ba81a4277a1ebd379d7463586125086 (patch)
treeb0568b648d03857e0767af1eedb17edfb521358a
parentd89d075589964b88c98f885d07fa45a6ec9d066c (diff)
gallium/osmesa: Introduce a test.
Given that we occasionally touch this code and probably nobody really wants to think about it, introduce a minimal test so that we know we haven't completely broken OSMesa. Reviewed-by: Timothy Arceri <[email protected]>
-rw-r--r--src/gallium/targets/osmesa/meson.build9
-rw-r--r--src/gallium/targets/osmesa/test-render.c43
2 files changed, 52 insertions, 0 deletions
diff --git a/src/gallium/targets/osmesa/meson.build b/src/gallium/targets/osmesa/meson.build
index e873e311aa0..1612908d016 100644
--- a/src/gallium/targets/osmesa/meson.build
+++ b/src/gallium/targets/osmesa/meson.build
@@ -62,3 +62,12 @@ pkg.generate(
libraries : libosmesa,
libraries_private : gl_priv_libs,
)
+
+if with_tests
+ test('osmesa-render',
+ executable('osmesa-render',
+ 'test-render.c',
+ include_directories : inc_common,
+ link_with: libosmesa),
+ suite: 'gallium')
+endif
diff --git a/src/gallium/targets/osmesa/test-render.c b/src/gallium/targets/osmesa/test-render.c
new file mode 100644
index 00000000000..62118607713
--- /dev/null
+++ b/src/gallium/targets/osmesa/test-render.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "GL/osmesa.h"
+
+static void
+render(void)
+{
+ glClearColor(0, 1, 0, 0);
+ glClear(GL_COLOR_BUFFER_BIT);
+}
+
+int
+main(int argc, char **argv)
+{
+ OSMesaContext ctx;
+ uint32_t pixel;
+ uint32_t green = 0xff << 8;
+ int w = 1, h = 1;
+
+ ctx = OSMesaCreateContext(GL_RGBA, NULL);
+ if (!ctx) {
+ fprintf(stderr, "Context create failed\n");
+ return 1;
+ }
+
+ if (!OSMesaMakeCurrent(ctx, &pixel, GL_UNSIGNED_BYTE, w, h )) {
+ fprintf(stderr, "MakeCurrent failed\n");
+ return 1;
+ }
+
+ render();
+ glFinish();
+
+ if (pixel != green) {
+ fprintf(stderr, "Expected: 0x%08x\n", green);
+ fprintf(stderr, "Probed: 0x%08x\n", pixel);
+ return 1;
+ }
+
+ OSMesaDestroyContext(ctx);
+
+ return 0;
+}