Skip compiler unload/reload tests if compiler is not available (#986)

* Skip compiler unload/reload tests if compiler is not available

Note that tests that use the compiler helper functions but won't work without a
compiler are in the `subtests_to_skip_with_offline_compiler` list.  I didn't do
that here because they tests directly use `clBuildProgram` etc directly,
because they're specifically testing it's behaviour in edge-cases.

* Change type of status variable
diff --git a/test_conformance/compiler/procs.h b/test_conformance/compiler/procs.h
index 38188d3..10ae142 100644
--- a/test_conformance/compiler/procs.h
+++ b/test_conformance/compiler/procs.h
@@ -19,6 +19,25 @@
 #include "harness/mt19937.h"
 #include "harness/typeWrappers.h"
 
+// This is a macro rather than a function to be able to use and act like the
+// existing test_error macro.
+//
+// Not all compiler tests need to use this macro, only those that don't use the
+// test harness compiler helpers.
+#define check_compiler_available(DEVICE)                                       \
+    {                                                                          \
+        cl_bool compilerAvailable = CL_FALSE;                                  \
+        cl_int error = clGetDeviceInfo((DEVICE), CL_DEVICE_COMPILER_AVAILABLE, \
+                                       sizeof(compilerAvailable),              \
+                                       &compilerAvailable, NULL);              \
+        test_error(error, "Unable to query CL_DEVICE_COMPILER_AVAILABLE");     \
+        if (compilerAvailable == CL_FALSE)                                     \
+        {                                                                      \
+            log_info("Skipping test - no compiler is available.\n");           \
+            return TEST_SKIPPED_ITSELF;                                        \
+        }                                                                      \
+    }
+
 extern int test_load_program_source(cl_device_id deviceID, cl_context context,
                                     cl_command_queue queue, int num_elements);
 extern int test_load_multistring_source(cl_device_id deviceID,
diff --git a/test_conformance/compiler/test_feature_macro.cpp b/test_conformance/compiler/test_feature_macro.cpp
index 1dd3549..ac355dd 100644
--- a/test_conformance/compiler/test_feature_macro.cpp
+++ b/test_conformance/compiler/test_feature_macro.cpp
@@ -721,21 +721,15 @@
 int test_features_macro(cl_device_id deviceID, cl_context context,
                         cl_command_queue queue, int num_elements)
 {
-    cl_bool compilerAvailable = CL_FALSE;
-    cl_int error =
-        clGetDeviceInfo(deviceID, CL_DEVICE_COMPILER_AVAILABLE,
-                        sizeof(compilerAvailable), &compilerAvailable, NULL);
-    test_error(error, "Unable to query CL_DEVICE_COMPILER_AVAILABLE");
-    if (compilerAvailable == CL_FALSE)
-    {
-        // Note: Not checking that the feature array is empty because the
-        // specification says "For devices that do not support compilation from
-        // OpenCL C source, this query may return an empty array."  It "may"
-        // return an empty array implies that an implementation also "may not".
-        log_info("Skipping test - no compiler is available.\n");
-        return TEST_SKIPPED_ITSELF;
-    }
 
+    // Note: Not checking that the feature array is empty for the compiler not
+    // available case because the specification says "For devices that do not
+    // support compilation from OpenCL C source, this query may return an empty
+    // array."  It "may" return an empty array implies that an implementation
+    // also "may not".
+    check_compiler_available(deviceID);
+
+    int error = TEST_PASS;
     cl_bool supported = CL_FALSE;
     std::string test_macro_name = "";
     std::vector<std::string> supported_features_vec;
diff --git a/test_conformance/compiler/test_opencl_c_versions.cpp b/test_conformance/compiler/test_opencl_c_versions.cpp
index d3c28c3..d750366 100644
--- a/test_conformance/compiler/test_opencl_c_versions.cpp
+++ b/test_conformance/compiler/test_opencl_c_versions.cpp
@@ -289,15 +289,7 @@
 int test_opencl_c_versions(cl_device_id device, cl_context context,
                            cl_command_queue queue, int num_elements)
 {
-    cl_bool compilerAvailable = CL_FALSE;
-    cl_int error =
-        clGetDeviceInfo(device, CL_DEVICE_COMPILER_AVAILABLE,
-                        sizeof(compilerAvailable), &compilerAvailable, NULL);
-    if (compilerAvailable == CL_FALSE)
-    {
-        log_info("Skipping test - no compiler is available.\n");
-        return TEST_SKIPPED_ITSELF;
-    }
+    check_compiler_available(device);
 
     const Version version = get_device_cl_version(device);
 
diff --git a/test_conformance/compiler/test_unload_platform_compiler.cpp b/test_conformance/compiler/test_unload_platform_compiler.cpp
index bb3ee95..a180a58 100644
--- a/test_conformance/compiler/test_unload_platform_compiler.cpp
+++ b/test_conformance/compiler/test_unload_platform_compiler.cpp
@@ -409,6 +409,8 @@
 int test_unload_repeated(cl_device_id device, cl_context context,
                          cl_command_queue, int)
 {
+    check_compiler_available(device);
+
     const cl_platform_id platform = device_platform(device);
     try
     {
@@ -438,6 +440,8 @@
 int test_unload_compile_unload_link(cl_device_id device, cl_context context,
                                     cl_command_queue, int)
 {
+    check_compiler_available(device);
+
     const cl_platform_id platform = device_platform(device);
     try
     {
@@ -468,6 +472,8 @@
                                            cl_context context, cl_command_queue,
                                            int)
 {
+    check_compiler_available(device);
+
     const cl_platform_id platform = device_platform(device);
     try
     {
@@ -497,6 +503,8 @@
 int test_unload_link_different(cl_device_id device, cl_context context,
                                cl_command_queue, int)
 {
+    check_compiler_available(device);
+
     const cl_platform_id platform = device_platform(device);
 
     static const char *sources_1[] = { "unsigned int a() { return 42; }" };
@@ -645,6 +653,8 @@
 {
     using clock = std::chrono::steady_clock;
 
+    check_compiler_available(device);
+
     const cl_platform_id platform = device_platform(device);
 
     const auto end = clock::now() + std::chrono::seconds(5);
@@ -732,6 +742,8 @@
 int test_unload_build_info(cl_device_id device, cl_context context,
                            cl_command_queue, int)
 {
+    check_compiler_available(device);
+
     const cl_platform_id platform = device_platform(device);
 
     static const char *sources[] = { write_kernel_source };
@@ -893,6 +905,8 @@
 int test_unload_program_binaries(cl_device_id device, cl_context context,
                                  cl_command_queue, int)
 {
+    check_compiler_available(device);
+
     const cl_platform_id platform = device_platform(device);
 
     static const char *sources[] = { write_kernel_source };