[gegl] tests: Test that OpenCL color kernels compiled
- From: Daniel Sabo <daniels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] tests: Test that OpenCL color kernels compiled
- Date: Wed, 16 Oct 2013 19:44:42 +0000 (UTC)
commit 2f3d0f2a7e73f3712dab8a62e709bbbcbad915ef
Author: Daniel Sabo <DanielSabo gmail com>
Date: Wed Oct 16 12:28:21 2013 -0700
tests: Test that OpenCL color kernels compiled
Doesn't check if they're accurate yet, just that they exist.
tests/simple/.gitignore | 1 +
tests/simple/Makefile.am | 1 +
tests/simple/test-opencl-colors.c | 101 +++++++++++++++++++++++++++++++++++++
3 files changed, 103 insertions(+), 0 deletions(-)
---
diff --git a/tests/simple/.gitignore b/tests/simple/.gitignore
index d44873f..7fc5253 100644
--- a/tests/simple/.gitignore
+++ b/tests/simple/.gitignore
@@ -12,6 +12,7 @@
/test-gegl-tile
/test-misc
/test-node-properties
+/test-opencl-colors
/test-path
/test-proxynop-processing
/test-buffer-cast
diff --git a/tests/simple/Makefile.am b/tests/simple/Makefile.am
index ed7bd5e..ee47afc 100644
--- a/tests/simple/Makefile.am
+++ b/tests/simple/Makefile.am
@@ -17,6 +17,7 @@ noinst_PROGRAMS = \
test-gegl-tile \
test-misc \
test-node-properties \
+ test-opencl-colors \
test-path \
test-proxynop-processing \
test-scaled-blit \
diff --git a/tests/simple/test-opencl-colors.c b/tests/simple/test-opencl-colors.c
new file mode 100644
index 0000000..279afc5
--- /dev/null
+++ b/tests/simple/test-opencl-colors.c
@@ -0,0 +1,101 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (C) 2013 Daniel Sabo
+ */
+
+#include <string.h>
+#include <stdio.h>
+
+#include "gegl.h"
+#include "gegl-utils.h"
+#include "opencl/gegl-cl.h"
+
+#define SUCCESS 0
+#define FAILURE -1
+
+static gboolean
+test_opencl_conversion (const char *in_format_name,
+ const char *out_format_name,
+ GeglClColorOp expected_conversion)
+{
+ gboolean result = TRUE;
+ const Babl *in_format = babl_format (in_format_name);
+ const Babl *out_format = babl_format (out_format_name);
+
+ GeglClColorOp conversion_mode = gegl_cl_color_supported (in_format, out_format);
+
+ if (conversion_mode != expected_conversion)
+ {
+ printf ("\n");
+ printf ("Wrong conversion mode (%d) for \"%s\" -> \"%s\"\n", conversion_mode, in_format_name,
out_format_name);
+ result = FALSE;
+ }
+
+ return result;
+}
+
+#define RUN_TEST(in_format, out_format, expected) \
+{ \
+ if (test_opencl_conversion(in_format, out_format, expected)) \
+ { \
+ printf ("."); \
+ fflush(stdout); \
+ tests_passed++; \
+ } \
+ else \
+ { \
+ tests_failed++; \
+ } \
+ tests_run++; \
+}
+
+int main(int argc, char *argv[])
+{
+ gint tests_run = 0;
+ gint tests_passed = 0;
+ gint tests_failed = 0;
+
+ gegl_init (&argc, &argv);
+
+ if (!gegl_cl_is_accelerated())
+ printf ("OpenCL disabled: SKIP");
+ else
+ {
+ RUN_TEST ("RGBA float", "RGBA float", GEGL_CL_COLOR_EQUAL)
+ RUN_TEST ("RGBA float", "RaGaBaA float", GEGL_CL_COLOR_CONVERT)
+ /* RUN_TEST ("RGBA float", "RGB float", GEGL_CL_COLOR_CONVERT) */
+ RUN_TEST ("RGBA float", "R'G'B'A float", GEGL_CL_COLOR_CONVERT)
+ /* RUN_TEST ("RGBA float", "R'aG'aB'aA float", GEGL_CL_COLOR_CONVERT) */
+ RUN_TEST ("RGBA float", "R'G'B'A u8", GEGL_CL_COLOR_CONVERT)
+ RUN_TEST ("RGBA float", "R'G'B' u8", GEGL_CL_COLOR_CONVERT)
+
+ RUN_TEST ("R'G'B'A float", "RGBA float", GEGL_CL_COLOR_CONVERT)
+ RUN_TEST ("R'G'B'A float", "R'G'B'A float", GEGL_CL_COLOR_EQUAL)
+ /* RUN_TEST ("R'G'B'A float", "R'G'B'A u8", GEGL_CL_COLOR_CONVERT) */
+ /* RUN_TEST ("R'G'B'A float", "R'G'B' u8", GEGL_CL_COLOR_CONVERT) */
+
+ RUN_TEST ("R'G'B'A u8", "RGBA float", GEGL_CL_COLOR_CONVERT)
+ /* RUN_TEST ("R'G'B'A u8", "R'G'B'A float", GEGL_CL_COLOR_CONVERT) */
+ RUN_TEST ("R'G'B'A u8", "R'G'B'A u8", GEGL_CL_COLOR_EQUAL)
+ }
+
+ printf ("\n");
+
+ gegl_exit ();
+
+ if (tests_passed == tests_run)
+ return SUCCESS;
+ return FAILURE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]