tests: do some cleanup on xglFence.

Refactor a little to clean up code.
Add check for WaitForFences.
diff --git a/tests/xglFence.c b/tests/xglFence.c
index fa9570f..f03456e 100644
--- a/tests/xglFence.c
+++ b/tests/xglFence.c
@@ -38,6 +38,7 @@
     };
     struct app_gpu gpus[MAX_GPUS];
     XGL_PHYSICAL_GPU objs[MAX_GPUS];
+    struct app_gpu *gpu;
     XGL_UINT gpu_count, i, gpu_idx;
     XGL_RESULT err;
     XGL_FENCE_CREATE_INFO fence_info;
@@ -57,40 +58,55 @@
     }
 
     for (gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++) {
-        if (gpus[gpu_idx].dev.heap_count > 0) {
-            memset(&fence_info, 0, sizeof(fence_info));
+        gpu = &gpus[gpu_idx];
+        if (gpu->dev.heap_count == 0) {
+            debug_printf("No heaps available for GPU #%d: %s", gpu_idx, gpu->props.gpuName);
+            continue;
+        }
+
+        memset(&fence_info, 0, sizeof(fence_info));
 
 //            typedef struct _XGL_FENCE_CREATE_INFO
 //            {
 //                XGL_STRUCTURE_TYPE                      sType;      // Must be XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO
 //                const XGL_VOID*                         pNext;      // Pointer to next structure
 //                XGL_FLAGS                               flags;      // Reserved
-            fence_info.sType = XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO;
+        fence_info.sType = XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO;
 
-            err = xglCreateFence(gpus[gpu_idx].dev.obj, &fence_info, &fence);
-            if (err)
-                ERR_EXIT(err);
+        err = xglCreateFence(gpu->dev.obj, &fence_info, &fence);
+        if (err)
+            ERR_EXIT(err);
 
-            printf("xglCreateFence: Passed\n");
+        printf("xglCreateFence: Passed\n");
 
-            err = xglGetFenceStatus(fence);
-            // We've not submitted this fence on a command buffer so should get
-            // XGL_ERROR_UNAVAILABLE
-            if (err != XGL_ERROR_UNAVAILABLE) {
-                ERR_EXIT(err);
-            }
-
-            // TODO: Attached to command buffer and test GetFenceStatus
-
-            err = xglDestroyObject(fence);
-            if (err)
-                ERR_EXIT(err);
-
-            printf("xglDestoryObject(fence): Passed\n");
-
-        } else {
-            debug_printf("No heaps available for GPU #%d: %s", gpu_idx, gpus[gpu_idx].props.gpuName);
+        err = xglGetFenceStatus(fence);
+        // We've not submitted this fence on a command buffer so should get
+        // XGL_ERROR_UNAVAILABLE
+        if (err != XGL_ERROR_UNAVAILABLE) {
+            ERR_EXIT(err);
         }
+
+        // Test glxWaitForFences
+//        XGL_RESULT XGLAPI xglWaitForFences(
+//            XGL_DEVICE                                  device,
+//            XGL_UINT                                    fenceCount,
+//            const XGL_FENCE*                            pFences,
+//            XGL_BOOL                                    waitAll,
+//            XGL_UINT64                                  timeout);
+        err = xglWaitForFences(gpu->dev.obj, 1, &fence, XGL_TRUE, 0);
+        if (err != XGL_ERROR_UNAVAILABLE)
+            ERR_EXIT(err);
+
+        printf("xglWaitForFences(UNAVAILABLE): Passed\n");
+
+        // TODO: Attached to command buffer and test GetFenceStatus
+        // TODO: Add some commands and submit the command buffer
+
+        err = xglDestroyObject(fence);
+        if (err)
+            ERR_EXIT(err);
+
+        printf("xglDestoryObject(fence): Passed\n");
     }
 
     for (i = 0; i < gpu_count; i++)