code: def test_get_info(ctx_factory):
      ctx = ctx_factory()
      (device,) = ctx.devices
      platform = device.platform
  
      device.persistent_unique_id
      device.hashable_model_and_version_identifier
  
      failure_count = [0]
  
      pocl_quirks = [
          (cl.Buffer, cl.mem_info.OFFSET),
          (cl.Program, cl.program_info.BINARIES),
          (cl.Program, cl.program_info.BINARY_SIZES),
      ]
      if ctx._get_cl_version() >= (
          1,
          2,
      ) and cl.get_cl_header_version() >= (1, 2):
          pocl_quirks.extend(
              [
                  (cl.Program, cl.program_info.KERNEL_NAMES),
                  (cl.Program, cl.program_info.NUM_KERNELS),
              ]
          )
      CRASH_QUIRKS = [  # noqa: N806
          (
              (
                  "NVIDIA Corporation",
                  "NVIDIA CUDA",
                  "OpenCL 1.0 CUDA 3.0.1",
              ),
              [
                  (cl.Event, cl.event_info.COMMAND_QUEUE),
              ],
          ),
          (
              (
                  "NVIDIA Corporation",
                  "NVIDIA CUDA",
                  "OpenCL 1.2 CUDA 7.5",
              ),
              [
                  (
                      cl.Buffer,
                      getattr(cl.mem_info, "USES_SVM_POINTER", None),
                  ),
              ],
          ),
          (
              (
                  "The pocl project",
                  "Portable Computing Language",
                  "OpenCL 1.2 pocl 0.8-pre",
              ),
              pocl_quirks,
          ),
          (
              (
                  "The pocl project",
                  "Portable Computing Language",
                  "OpenCL 1.2 pocl 0.8",
              ),
              pocl_quirks,
          ),
          (
              (
                  "The pocl project",
                  "Portable Computing Language",
                  "OpenCL 1.2 pocl 0.9-pre",
              ),
              pocl_quirks,
          ),
          (
              (
                  "The pocl project",
                  "Portable Computing Language",
                  "OpenCL 1.2 pocl 0.9",
              ),
              pocl_quirks,
          ),
          (
              (
                  "The pocl project",
                  "Portable Computing Language",
                  "OpenCL 1.2 pocl 0.10-pre",
              ),
              pocl_quirks,
          ),
          (
              (
                  "The pocl project",
                  "Portable Computing Language",
                  "OpenCL 1.2 pocl 0.10",
              ),
              pocl_quirks,
          ),
          (
              ("Apple", "Apple", "OpenCL 1.2"),
              [
                  (cl.Program, cl.program_info.SOURCE),
              ],
          ),
      ]
      QUIRKS = []  # noqa: N806
  
      def find_quirk(quirk_list, cl_obj, info):
          for (vendor, name, version), quirks in quirk_list:
              if (
                  vendor == platform.vendor
                  and name == platform.name
                  and platform.version.startswith(version)
              ):
                  for quirk_cls, quirk_info in quirks:
                      if (
                          isinstance(cl_obj, quirk_cls)
                          and quirk_info == info
                      ):
                          return True
  
          return False
  
      def do_test(cl_obj, info_cls, func=None, try_attr_form=True):
          if func is None:
              func = cl_obj.get_info
  
          for info_name in dir(info_cls):
              if (
                  not info_name.startswith("_")
                  and info_name != "to_string"
              ):
                  print(info_cls, info_name)
                  info = getattr(info_cls, info_name)
  
                  if find_quirk(CRASH_QUIRKS, cl_obj, info):
                      print(
                          "not executing get_info",
                          type(cl_obj),
                          info_name,
                      )
                      print(
                          "(known crash quirk for %s)" % platform.name
                      )
                      continue
  
                  try:
                      func(info)
                  except Exception:
                      msg = "failed get_info", type(cl_obj), info_name
  
                      if find_quirk(QUIRKS, cl_obj, info):
                          msg += "(known quirk for %s)" % platform.name
                      else:
                          failure_count[0] += 1
  
                  if try_attr_form:
                      try:
                          getattr(cl_obj, info_name.lower())
                      except Exception:
                          print(
                              "failed attr-based get_info",
                              type(cl_obj),
                              info_name,
                          )
  
                          if find_quirk(QUIRKS, cl_obj, info):
                              print(
                                  "(known quirk for %s)" % platform.name
                              )
                          else:
                              failure_count[0] += 1
  
      do_test(platform, cl.platform_info)
      do_test(device, cl.device_info)
      do_test(ctx, cl.context_info)
  
      props = 0
      if (
          device.queue_properties
          & cl.command_queue_properties.PROFILING_ENABLE
      ):
          profiling = True
          props = cl.command_queue_properties.PROFILING_ENABLE
      queue = cl.CommandQueue(ctx, properties=props)
      do_test(queue, cl.command_queue_info)
  
      prg = cl.Program(
          ctx,
          """
          __kernel void sum(__global float *a)
          { a[get_global_id(0)] *= 2; }
          """,
      ).build()
      do_test(prg, cl.program_info)
      do_test(
          prg,
          cl.program_build_info,
          lambda info: prg.get_build_info(device, info),
          try_attr_form=False,
      )
  
      n = 2000
      a_buf = cl.Buffer(ctx, 0, n * 4)
  
      do_test(a_buf, cl.mem_info)
  
      kernel = prg.all_kernels()[0]
      do_test(kernel, cl.kernel_info)
  
      for _i in range(2):  # exercise cache
          for info_name in dir(cl.kernel_work_group_info):
              if (
                  not info_name.startswith("_")
                  and info_name != "to_string"
              ):
                  try:
                      print("kernel_wg_info: %s" % info_name)
                      kernel.get_work_group_info(
                          getattr(cl.kernel_work_group_info, info_name),
                          device,
                      )
                  except cl.LogicError as err:
                      print("<error: %s>" % err)
  
      evt = kernel(queue, (n,), None, a_buf)
      do_test(evt, cl.event_info)
  
      if profiling:
          evt.wait()
          do_test(
              evt,
              cl.profiling_info,
              lambda info: evt.get_profiling_info(info),
              try_attr_form=False,
          )
  
      # crashes on intel...
      # and pocl does not support CL_ADDRESS_CLAMP
      if device.image_support and platform.vendor not in [
          "Intel(R) Corporation",
          "The pocl project",
      ]:
          smp = cl.Sampler(
              ctx,
              False,
              cl.addressing_mode.CLAMP,
              cl.filter_mode.NEAREST,
          )
          do_test(smp, cl.sampler_info)
  
          img_format = cl.get_supported_image_formats(
              ctx, cl.mem_flags.READ_ONLY, cl.mem_object_type.IMAGE2D
          )[0]
  
          img = cl.Image(
              ctx, cl.mem_flags.READ_ONLY, img_format, (128, 256)
          )
          assert img.shape == (128, 256)
  
          img.depth
          img.image.depth
          do_test(
              img, cl.image_info, lambda info: img.get_image_info(info)
          )
  
imports: import numpy
  import numpy.linalg
  import pytest
  import pyopencl
  import pyopencl.array
  import pyopencl.cltypes
  import pyopencl.clrandom
  from pyopencl.tools import pytest_generate_tests_for_pyopencl, ImmediateAllocator, DeferredAllocator
  from pyopencl.characterize import get_pocl_version
label_desc: Use image node_id 3 for calling a global function with example usage: test_get_info(ctx_factory) and returns: False, True