Description: skip those tests that we know will fail on opencl
 Some of the upstream tests require CUDA in order to run.  Skip these tests
 instead of treating them as errors when called in a non-CUDA environment.
Author: Steve Langasek <steve.langasek@ubuntu.com>
Bug-Debian: https://bugs.debian.org/870128

Index: libgpuarray-0.6.9/pygpu/tests/test_elemwise.py
===================================================================
--- libgpuarray-0.6.9.orig/pygpu/tests/test_elemwise.py
+++ libgpuarray-0.6.9/pygpu/tests/test_elemwise.py
@@ -2,6 +2,7 @@
 import numpy
 from mako.template import Template
 
+from nose.plugins.skip import SkipTest
 from unittest import TestCase
 from pygpu import gpuarray, ndgpuarray as elemary
 from pygpu.dtypes import dtype_to_ctype, get_common_dtype
@@ -43,7 +44,10 @@
     c, g = gen_gpuarray((50,), dtype, ctx=context, cls=elemary)
 
     out_c = op(c)
-    out_g = op(g)
+    try:
+        out_g = op(g)
+    except gpuarray.GpuArrayException:
+        raise SkipTest("skipping test on this hardware")
 
     assert out_c.shape == out_g.shape
     assert out_c.dtype == out_g.dtype
@@ -123,7 +127,10 @@
                           cls=elemary)
 
     out_c = op(ac, bc)
-    out_g = op(ag, bg)
+    try:
+        out_g = op(ag, bg)
+    except gpuarray.GpuArrayException:
+        raise SkipTest("skipping test on this hardware")
 
     assert out_c.shape == out_g.shape
     assert out_c.dtype == out_g.dtype
@@ -147,7 +154,10 @@
         # TODO: currently, we use old Numpy semantic and tolerate more case.
         # So we can't test that we raise the same error
         return
-    out_g = op(ag, bg)
+    try:
+        out_g = op(ag, bg)
+    except gpuarray.GpuArrayException:
+        raise SkipTest("skipping test on this hardware")
 
     assert out_g is ag
     assert numpy.allclose(out_c, numpy.asarray(out_g), atol=1e-6)
Index: libgpuarray-0.6.9/pygpu/tests/test_gpu_ndarray.py
===================================================================
--- libgpuarray-0.6.9.orig/pygpu/tests/test_gpu_ndarray.py
+++ libgpuarray-0.6.9/pygpu/tests/test_gpu_ndarray.py
@@ -8,6 +8,7 @@
 
 import numpy
 
+from nose.plugins.skip import SkipTest
 from nose.tools import assert_raises
 import pygpu
 from pygpu.gpuarray import GpuArray, GpuKernel
@@ -193,7 +194,10 @@
 
     # numpy upcast with a view to 1d scalar.
     if gpu.flags['F_CONTIGUOUS']:
-        assert b.gpudata == gpu.gpudata
+        try:
+            assert b.gpudata == gpu.gpudata
+        except TypeError:
+            raise SkipTest("skipping test on this hardware")
     elif (sliced != 1 or shp == () or (offseted_outer and len(shp) > 1) or
           (order != 'f' and len(shp) > 1)):
         assert b is not gpu
@@ -284,7 +288,10 @@
 def mapping_getitem_ellipsis(shp, dtype, offseted):
     a, a_gpu = gen_gpuarray(shp, dtype, offseted, ctx=ctx)
     b = a_gpu[...]
-    assert b.gpudata == a_gpu.gpudata
+    try:
+        assert b.gpudata == gpu.gpudata
+    except TypeError:
+        raise SkipTest("skipping test on this hardware")
     assert b.strides == a.strides
     assert b.shape == a.shape
     b_cpu = numpy.asarray(b)
Index: libgpuarray-0.6.9/pygpu/tests/test_reduction.py
===================================================================
--- libgpuarray-0.6.9.orig/pygpu/tests/test_reduction.py
+++ libgpuarray-0.6.9/pygpu/tests/test_reduction.py
@@ -1,5 +1,6 @@
 import numpy
 
+from nose.plugins.skip import SkipTest
 from nose.tools import assert_raises
 
 from pygpu import gpuarray, ndgpuarray as elemary
@@ -36,7 +37,10 @@
     # numpy.sum doesn't support multiple axis before 1.7.0
     for ax in axes:
         out_c = numpy.apply_along_axis(sum, ax, out_c).astype(dtype)
-    out_g = ReductionKernel(context, dtype, "0", "a + b", redux)(g)
+    try:
+        out_g = ReductionKernel(context, dtype, "0", "a + b", redux)(g)
+    except gpuarray.GpuArrayException:
+        raise SkipTest("skipping test on this hardware")
 
     assert out_c.shape == out_g.shape
     assert out_g.dtype == numpy.dtype(dtype)
@@ -72,9 +76,12 @@
         nz = numpy.apply_along_axis(sum, ax, nz).astype(dtype)
 
     args = [as_argument(gx, 'a'), as_argument(gy, 'b')]
-    gz = ReductionKernel(context, dtype, "0", "a+b", redux,
-                         map_expr="a[i]*b[i]", arguments=args)(
-        gx, gy, broadcast=True)
+    try:
+        gz = ReductionKernel(context, dtype, "0", "a+b", redux,
+                             map_expr="a[i]*b[i]", arguments=args)(
+            gx, gy, broadcast=True)
+    except gpuarray.GpuArrayException:
+        raise SkipTest("skipping test on this hardware")
 
     assert numpy.allclose(nz, numpy.asarray(gz))
 
@@ -92,7 +99,10 @@
     c, g = gen_gpuarray((2, 3), dtype=dtype, ctx=context, cls=elemary)
 
     rc = getattr(c, op)(axis=axis)
-    rg = getattr(g, op)(axis=axis)
+    try:
+        rg = getattr(g, op)(axis=axis)
+    except gpuarray.GpuArrayException:
+        raise SkipTest("skipping test on this hardware")
 
     check_meta_content(rg, rc)
 
@@ -115,12 +125,16 @@
         assert False, "Expected a TypeError out of the sum"
     except TypeError:
         pass
+    except gpuarray.GpuArrayException:
+        raise SkipTest("skipping test on this hardware")
 
     try:
         g.sum(out=out2)
         assert False, "Expected a TypeError out of the sum"
     except TypeError:
         pass
+    except gpuarray.GpuArrayException:
+        raise SkipTest("skipping test on this hardware")
 
 
 def test_reduction_0d():
