[Graphics] Reduce code duplicate in rootless debug CTS.

Bug: b/151266652
Test: atest android.gputools.cts.CtsRootlessGpuDebugHostTest
Change-Id: I151dc679ac33354e47dde1fbc33940060b9f2e20
diff --git a/hostsidetests/gputools/layers/Android.bp b/hostsidetests/gputools/layers/Android.bp
index 9d12a7b..3b3a155 100644
--- a/hostsidetests/gputools/layers/Android.bp
+++ b/hostsidetests/gputools/layers/Android.bp
@@ -25,8 +25,6 @@
     shared_libs: [
         "libandroid",
         "libvulkan",
-        "libEGL",
-        "libGLESv3",
         "liblog",
     ],
     stl: "c++_shared",
@@ -46,8 +44,6 @@
     shared_libs: [
         "libandroid",
         "libvulkan",
-        "libEGL",
-        "libGLESv3",
         "liblog",
     ],
     stl: "c++_shared",
@@ -67,8 +63,6 @@
     shared_libs: [
         "libandroid",
         "libvulkan",
-        "libEGL",
-        "libGLESv3",
         "liblog",
     ],
     stl: "c++_shared",
diff --git a/hostsidetests/gputools/layers/jni/nullLayer.cpp b/hostsidetests/gputools/layers/jni/nullLayer.cpp
index c5f84ca..dac52c9 100644
--- a/hostsidetests/gputools/layers/jni/nullLayer.cpp
+++ b/hostsidetests/gputools/layers/jni/nullLayer.cpp
@@ -22,7 +22,8 @@
 #define xstr(a) str(a)
 #define str(a) #a
 
-#define LOG_TAG "nullLayer" xstr(LAYERNAME)
+#define LAYER_FULL_NAME "VK_LAYER_ANDROID_nullLayer" xstr(LAYERNAME)
+#define LOG_TAG LAYER_FULL_NAME
 
 #define ALOGI(msg, ...) \
     __android_log_print(ANDROID_LOG_INFO, LOG_TAG, (msg), __VA_ARGS__)
@@ -35,8 +36,8 @@
             ALOGI("%s", msg);
     }
 };
-StaticLogMessage g_initMessage("nullLayer" xstr(LAYERNAME) " loaded");
-
+StaticLogMessage
+    g_initMessage("VK_LAYER_ANDROID_nullLayer" xstr(LAYERNAME) " loaded");
 
 namespace {
 
@@ -68,7 +69,10 @@
 }
 
 static const VkLayerProperties LAYER_PROPERTIES = {
-    "VK_LAYER_ANDROID_nullLayer" xstr(LAYERNAME), VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION), 1, "Layer: nullLayer" xstr(LAYERNAME),
+    LAYER_FULL_NAME,
+    VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION),
+    1,
+    "Layer: nullLayer" xstr(LAYERNAME),
 };
 
 VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) {
@@ -97,7 +101,7 @@
 
     VkLayerDeviceCreateInfo *layerCreateInfo = (VkLayerDeviceCreateInfo*)pCreateInfo->pNext;
 
-    const char* msg = "nullCreateDevice called in nullLayer" xstr(LAYERNAME);
+    const char *msg = "nullCreateDevice called in " LAYER_FULL_NAME;
     ALOGI("%s", msg);
 
     // Step through the pNext chain until we get to the link function
@@ -134,7 +138,7 @@
 
     VkLayerInstanceCreateInfo *layerCreateInfo = (VkLayerInstanceCreateInfo *)pCreateInfo->pNext;
 
-    const char* msg = "nullCreateInstance called in nullLayer" xstr(LAYERNAME);
+    const char *msg = "nullCreateInstance called in " LAYER_FULL_NAME;
     ALOGI("%s", msg);
 
     // Step through the pNext chain until we get to the link function
diff --git a/hostsidetests/gputools/src/android/gputools/cts/CtsRootlessGpuDebugHostTest.java b/hostsidetests/gputools/src/android/gputools/cts/CtsRootlessGpuDebugHostTest.java
index fb14756..fc166da 100644
--- a/hostsidetests/gputools/src/android/gputools/cts/CtsRootlessGpuDebugHostTest.java
+++ b/hostsidetests/gputools/src/android/gputools/cts/CtsRootlessGpuDebugHostTest.java
@@ -87,19 +87,16 @@
     // Positive combined tests
     // - Ensure we can load Vulkan and GLES layers at the same time, from multiple external apps (testMultipleExternalApps)
 
-
-
     private static final String CLASS = "RootlessGpuDebugDeviceActivity";
     private static final String ACTIVITY = "android.rootlessgpudebug.app.RootlessGpuDebugDeviceActivity";
-    private static final String LAYER_A = "nullLayerA";
-    private static final String LAYER_B = "nullLayerB";
-    private static final String LAYER_C = "nullLayerC";
-    private static final String LAYER_A_LIB = "libVkLayer_" + LAYER_A + ".so";
-    private static final String LAYER_B_LIB = "libVkLayer_" + LAYER_B + ".so";
-    private static final String LAYER_C_LIB = "libVkLayer_" + LAYER_C + ".so";
-    private static final String LAYER_A_NAME = "VK_LAYER_ANDROID_" + LAYER_A;
-    private static final String LAYER_B_NAME = "VK_LAYER_ANDROID_" + LAYER_B;
-    private static final String LAYER_C_NAME = "VK_LAYER_ANDROID_" + LAYER_C;
+    private static final String VK_LAYER_LIB_PREFIX = "libVkLayer_nullLayer";
+    private static final String VK_LAYER_A_LIB = VK_LAYER_LIB_PREFIX + "A.so";
+    private static final String VK_LAYER_B_LIB = VK_LAYER_LIB_PREFIX + "B.so";
+    private static final String VK_LAYER_C_LIB = VK_LAYER_LIB_PREFIX + "C.so";
+    private static final String VK_LAYER_NAME_PREFIX = "VK_LAYER_ANDROID_nullLayer";
+    private static final String VK_LAYER_A = VK_LAYER_NAME_PREFIX + "A";
+    private static final String VK_LAYER_B = VK_LAYER_NAME_PREFIX + "B";
+    private static final String VK_LAYER_C = VK_LAYER_NAME_PREFIX + "C";
     private static final String DEBUG_APP = "android.rootlessgpudebug.DEBUG.app";
     private static final String RELEASE_APP = "android.rootlessgpudebug.RELEASE.app";
     private static final String INJECT_APP = "android.rootlessgpudebug.INJECT.app";
@@ -117,14 +114,13 @@
     private static final String GLES_LAYER_B_LIB = "libGLES_" + GLES_LAYER_B + ".so";
     private static final String GLES_LAYER_C_LIB = "libGLES_" + GLES_LAYER_C + ".so";
 
-    private static boolean initialized = false;
-
     // This is how long we'll scan the log for a result before giving up. This limit will only
     // be reached if something has gone wrong
     private static final long LOG_SEARCH_TIMEOUT_MS = 5000;
-
     private static final long SETTING_APPLY_TIMEOUT_MS = 5000;
 
+    private static boolean initialized = false;
+
     private String removeWhitespace(String input) {
         return input.replaceAll(System.getProperty("line.separator"), "").trim();
     }
@@ -172,6 +168,32 @@
     }
 
     /**
+     * Check that the layer is loaded by only checking the log after startTime.
+     */
+    private void assertVkLayerLoading(String startTime, String layerName, boolean loaded) throws Exception {
+        String searchString = "nullCreateInstance called in " + layerName;
+        LogScanResult result = scanLog(TAG + "," + layerName, searchString, startTime);
+        if (loaded) {
+            Assert.assertTrue(layerName + " was not loaded", result.found);
+        } else {
+            Assert.assertFalse(layerName + " was loaded", result.found);
+        }
+    }
+
+    /**
+     * Check that the layer is enumerated by only checking the log after startTime.
+     */
+    private void assertVkLayerEnumeration(String startTime, String layerName, boolean enumerated) throws Exception {
+        String searchString = layerName + " loaded";
+        LogScanResult result = scanLog(TAG + "," + layerName, searchString, startTime);
+        if (enumerated) {
+            Assert.assertTrue(layerName + " was not enumerated", result.found);
+        } else {
+            Assert.assertFalse(layerName + " was enumerated", result.found);
+        }
+    }
+
+    /**
      * Simple helper class for returning multiple results
      */
     public class LogScanResult {
@@ -242,9 +264,9 @@
         getDevice().executeAdbCommand("shell", "am", "force-stop", DEBUG_APP);
         getDevice().executeAdbCommand("shell", "am", "force-stop", RELEASE_APP);
         getDevice().executeAdbCommand("shell", "am", "force-stop", INJECT_APP);
-        getDevice().executeAdbCommand("shell", "rm", "-f", "/data/local/tmp/" + LAYER_A_LIB);
-        getDevice().executeAdbCommand("shell", "rm", "-f", "/data/local/tmp/" + LAYER_B_LIB);
-        getDevice().executeAdbCommand("shell", "rm", "-f", "/data/local/tmp/" + LAYER_C_LIB);
+        getDevice().executeAdbCommand("shell", "rm", "-f", "/data/local/tmp/" + VK_LAYER_A_LIB);
+        getDevice().executeAdbCommand("shell", "rm", "-f", "/data/local/tmp/" + VK_LAYER_B_LIB);
+        getDevice().executeAdbCommand("shell", "rm", "-f", "/data/local/tmp/" + VK_LAYER_C_LIB);
         getDevice().executeAdbCommand("shell", "rm", "-f", "/data/local/tmp/" + GLES_LAYER_A_LIB);
         getDevice().executeAdbCommand("shell", "rm", "-f", "/data/local/tmp/" + GLES_LAYER_B_LIB);
         getDevice().executeAdbCommand("shell", "rm", "-f", "/data/local/tmp/" + GLES_LAYER_C_LIB);
@@ -282,20 +304,20 @@
         // Set up layers to be loaded
         applySetting("enable_gpu_debug_layers", "1");
         applySetting("gpu_debug_app", DEBUG_APP);
-        applySetting("gpu_debug_layers", LAYER_A_NAME + ":" + LAYER_B_NAME);
+        applySetting("gpu_debug_layers", VK_LAYER_A + ":" + VK_LAYER_B);
 
         // Copy the layers from our LAYERS APK to tmp
-        setupLayer(LAYER_A_LIB, LAYERS_APP);
-        setupLayer(LAYER_B_LIB, LAYERS_APP);
+        setupLayer(VK_LAYER_A_LIB, LAYERS_APP);
+        setupLayer(VK_LAYER_B_LIB, LAYERS_APP);
 
 
         // Copy them over to our DEBUG app
-        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + VK_LAYER_A_LIB, "|",
                 "run-as", DEBUG_APP, "--user", Integer.toString(getDevice().getCurrentUser()),
-                "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
-        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_B_LIB, "|",
+                "sh", "-c", "\'cat", ">", VK_LAYER_A_LIB, ";", "chmod", "700", VK_LAYER_A_LIB + "\'");
+        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + VK_LAYER_B_LIB, "|",
                 "run-as", DEBUG_APP, "--user", Integer.toString(getDevice().getCurrentUser()),
-                "sh", "-c", "\'cat", ">", LAYER_B_LIB, ";", "chmod", "700", LAYER_B_LIB + "\'");
+                "sh", "-c", "\'cat", ">", VK_LAYER_B_LIB, ";", "chmod", "700", VK_LAYER_B_LIB + "\'");
 
 
         // Kick off our DEBUG app
@@ -303,12 +325,12 @@
         getDevice().executeAdbCommand("shell", "am", "start", "-n", DEBUG_APP + "/" + ACTIVITY);
 
         // Check that both layers were loaded, in the correct order
-        String searchStringA = "nullCreateInstance called in " + LAYER_A;
-        LogScanResult resultA = scanLog(TAG + "," + LAYER_A + "," + LAYER_B, searchStringA, appStartTime);
+        String searchStringA = "nullCreateInstance called in " + VK_LAYER_A;
+        LogScanResult resultA = scanLog(TAG + "," + VK_LAYER_A + "," + VK_LAYER_B, searchStringA, appStartTime);
         Assert.assertTrue("LayerA was not loaded", resultA.found);
 
-        String searchStringB = "nullCreateInstance called in " + LAYER_B;
-        LogScanResult resultB = scanLog(TAG + "," + LAYER_A + "," + LAYER_B, searchStringB, appStartTime);
+        String searchStringB = "nullCreateInstance called in " + VK_LAYER_B;
+        LogScanResult resultB = scanLog(TAG + "," + VK_LAYER_A + "," + VK_LAYER_B, searchStringB, appStartTime);
         Assert.assertTrue("LayerB was not loaded", resultB.found);
 
         Assert.assertTrue("LayerA should be loaded before LayerB", resultA.lineNumber < resultB.lineNumber);
@@ -318,24 +340,22 @@
         // Set up a layers to be loaded for RELEASE or INJECT app
         applySetting("enable_gpu_debug_layers", "1");
         applySetting("gpu_debug_app", APP_NAME);
-        applySetting("gpu_debug_layers", LAYER_A_NAME + ":" + LAYER_B_NAME);
+        applySetting("gpu_debug_layers", VK_LAYER_A + ":" + VK_LAYER_B);
 
         // Copy a layer from our LAYERS APK to tmp
-        setupLayer(LAYER_A_LIB, LAYERS_APP);
+        setupLayer(VK_LAYER_A_LIB, LAYERS_APP);
 
         // Attempt to copy them over to our RELEASE or INJECT app (this should fail)
-        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + VK_LAYER_A_LIB, "|",
             "run-as", APP_NAME, "--user", Integer.toString(getDevice().getCurrentUser()),
-            "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'", "||", "echo", "run-as", "failed");
+            "sh", "-c", "\'cat", ">", VK_LAYER_A_LIB, ";", "chmod", "700", VK_LAYER_A_LIB + "\'", "||", "echo", "run-as", "failed");
 
         // Kick off our RELEASE app
         String appStartTime = getTime();
         getDevice().executeAdbCommand("shell", "am", "start", "-n", APP_NAME + "/" + ACTIVITY);
 
         // Ensure we don't load the layer in base dir
-        String searchStringA = LAYER_A_NAME + "loaded";
-        LogScanResult resultA = scanLog(TAG + "," + LAYER_A, searchStringA, appStartTime);
-        Assert.assertFalse("LayerA was enumerated", resultA.found);
+        assertVkLayerEnumeration(appStartTime, VK_LAYER_A, false);
     }
 
     /**
@@ -366,24 +386,22 @@
         // Ensure the global layer enable settings is NOT enabled
         applySetting("enable_gpu_debug_layers", "0");
         applySetting("gpu_debug_app", DEBUG_APP);
-        applySetting("gpu_debug_layers", LAYER_A_NAME);
+        applySetting("gpu_debug_layers", VK_LAYER_A);
 
         // Copy a layer from our LAYERS APK to tmp
-        setupLayer(LAYER_A_LIB, LAYERS_APP);
+        setupLayer(VK_LAYER_A_LIB, LAYERS_APP);
 
         // Copy it over to our DEBUG app
-        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + VK_LAYER_A_LIB, "|",
                 "run-as", DEBUG_APP, "--user", Integer.toString(getDevice().getCurrentUser()),
-                "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
+                "sh", "-c", "\'cat", ">", VK_LAYER_A_LIB, ";", "chmod", "700", VK_LAYER_A_LIB + "\'");
 
         // Kick off our DEBUG app
         String appStartTime = getTime();
         getDevice().executeAdbCommand("shell", "am", "start", "-n", DEBUG_APP + "/" + ACTIVITY);
 
         // Ensure we don't load the layer in base dir
-        String searchStringA = LAYER_A_NAME + "loaded";
-        LogScanResult resultA = scanLog(TAG + "," + LAYER_A, searchStringA, appStartTime);
-        Assert.assertFalse("LayerA was enumerated", resultA.found);
+        assertVkLayerEnumeration(appStartTime, VK_LAYER_A, false);
     }
 
     /**
@@ -396,24 +414,22 @@
         // Ensure the gpu_debug_app does not match what we launch
         applySetting("enable_gpu_debug_layers", "1");
         applySetting("gpu_debug_app", RELEASE_APP);
-        applySetting("gpu_debug_layers", LAYER_A_NAME);
+        applySetting("gpu_debug_layers", VK_LAYER_A);
 
         // Copy a layer from our LAYERS APK to tmp
-        setupLayer(LAYER_A_LIB, LAYERS_APP);
+        setupLayer(VK_LAYER_A_LIB, LAYERS_APP);
 
         // Copy it over to our DEBUG app
-        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + VK_LAYER_A_LIB, "|",
                 "run-as", DEBUG_APP, "--user", Integer.toString(getDevice().getCurrentUser()),
-                "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
+                "sh", "-c", "\'cat", ">", VK_LAYER_A_LIB, ";", "chmod", "700", VK_LAYER_A_LIB + "\'");
 
         // Kick off our DEBUG app
         String appStartTime = getTime();
         getDevice().executeAdbCommand("shell", "am", "start", "-n", DEBUG_APP + "/" + ACTIVITY);
 
         // Ensure we don't load the layer in base dir
-        String searchStringA = LAYER_A_NAME + "loaded";
-        LogScanResult resultA = scanLog(TAG + "," + LAYER_A, searchStringA, appStartTime);
-        Assert.assertFalse("LayerA was enumerated", resultA.found);
+        assertVkLayerEnumeration(appStartTime, VK_LAYER_A, false);
     }
 
     /**
@@ -429,21 +445,19 @@
         applySetting("gpu_debug_layers", "foo");
 
         // Copy a layer from our LAYERS APK to tmp
-        setupLayer(LAYER_A_LIB, LAYERS_APP);
+        setupLayer(VK_LAYER_A_LIB, LAYERS_APP);
 
         // Copy it over to our DEBUG app
-        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + VK_LAYER_A_LIB, "|",
                 "run-as", DEBUG_APP, "--user", Integer.toString(getDevice().getCurrentUser()),
-                "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
+                "sh", "-c", "\'cat", ">", VK_LAYER_A_LIB, ";", "chmod", "700", VK_LAYER_A_LIB + "\'");
 
         // Kick off our DEBUG app
         String appStartTime = getTime();
         getDevice().executeAdbCommand("shell", "am", "start", "-n", DEBUG_APP + "/" + ACTIVITY);
 
         // Ensure layerA is not loaded
-        String searchStringA = "nullCreateInstance called in " + LAYER_A;
-        LogScanResult resultA = scanLog(TAG + "," + LAYER_A, searchStringA, appStartTime);
-        Assert.assertFalse("LayerA was loaded", resultA.found);
+        assertVkLayerLoading(appStartTime, VK_LAYER_A, false);
     }
 
     /**
@@ -458,20 +472,15 @@
         deleteSetting("gpu_debug_layers");
 
         // Enable layerC (which is packaged with the RELEASE app) with system properties
-        getDevice().executeAdbCommand("shell", "setprop", "debug.vulkan.layers " + LAYER_C_NAME);
+        getDevice().executeAdbCommand("shell", "setprop", "debug.vulkan.layers " + VK_LAYER_C);
 
         // Kick off our RELEASE app
         String appStartTime = getTime();
         getDevice().executeAdbCommand("shell", "am", "start", "-n", RELEASE_APP + "/" + ACTIVITY);
 
         // Check that only layerC was loaded
-        String searchStringA = LAYER_A_NAME + "loaded";
-        LogScanResult resultA = scanLog(TAG + "," + LAYER_A, searchStringA, appStartTime);
-        Assert.assertFalse("LayerA was enumerated", resultA.found);
-
-        String searchStringC = "nullCreateInstance called in " + LAYER_C;
-        LogScanResult resultC = scanLog(TAG + "," + LAYER_C, searchStringC, appStartTime);
-        Assert.assertTrue("LayerC was not loaded", resultC.found);
+        assertVkLayerEnumeration(appStartTime, VK_LAYER_A, false);
+        assertVkLayerLoading(appStartTime, VK_LAYER_C, true);
     }
 
     /**
@@ -483,35 +492,30 @@
         // Set up layerA to be loaded, but not layerB
         applySetting("enable_gpu_debug_layers", "1");
         applySetting("gpu_debug_app", DEBUG_APP);
-        applySetting("gpu_debug_layers", LAYER_A_NAME);
+        applySetting("gpu_debug_layers", VK_LAYER_A);
 
         // Copy the layers from our LAYERS APK
-        setupLayer(LAYER_A_LIB, LAYERS_APP);
-        setupLayer(LAYER_B_LIB, LAYERS_APP);
+        setupLayer(VK_LAYER_A_LIB, LAYERS_APP);
+        setupLayer(VK_LAYER_B_LIB, LAYERS_APP);
 
         // Copy them over to our DEBUG app
-        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + VK_LAYER_A_LIB, "|",
                 "run-as", DEBUG_APP, "--user", Integer.toString(getDevice().getCurrentUser()),
-                "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
-        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_B_LIB, "|",
+                "sh", "-c", "\'cat", ">", VK_LAYER_A_LIB, ";", "chmod", "700", VK_LAYER_A_LIB + "\'");
+        getDevice().executeAdbCommand("shell", "cat", "/data/local/tmp/" + VK_LAYER_B_LIB, "|",
                 "run-as", DEBUG_APP, "--user", Integer.toString(getDevice().getCurrentUser()),
-                "sh", "-c", "\'cat", ">", LAYER_B_LIB, ";", "chmod", "700", LAYER_B_LIB + "\'");
+                "sh", "-c", "\'cat", ">", VK_LAYER_B_LIB, ";", "chmod", "700", VK_LAYER_B_LIB + "\'");
 
         // Enable layerB with system properties
-        getDevice().executeAdbCommand("shell", "setprop", "debug.vulkan.layers " + LAYER_B_NAME);
+        getDevice().executeAdbCommand("shell", "setprop", "debug.vulkan.layers " + VK_LAYER_B);
 
         // Kick off our DEBUG app
         String appStartTime = getTime();
         getDevice().executeAdbCommand("shell", "am", "start", "-n", DEBUG_APP + "/" + ACTIVITY);
 
         // Ensure only layerA is loaded
-        String searchStringA = "nullCreateInstance called in " + LAYER_A;
-        LogScanResult resultA = scanLog(TAG + "," + LAYER_A, searchStringA, appStartTime);
-        Assert.assertTrue("LayerA was not loaded", resultA.found);
-
-        String searchStringB = "nullCreateInstance called in " + LAYER_B;
-        LogScanResult resultB = scanLog(TAG + "," + LAYER_B, searchStringB, appStartTime);
-        Assert.assertFalse("LayerB was loaded", resultB.found);
+        assertVkLayerLoading(appStartTime, VK_LAYER_A, true);
+        assertVkLayerLoading(appStartTime, VK_LAYER_B, false);
     }
 
 
@@ -520,7 +524,7 @@
         // Set up layers to be loaded
         applySetting("enable_gpu_debug_layers", "1");
         applySetting("gpu_debug_app", APP_NAME);
-        applySetting("gpu_debug_layers", LAYER_C_NAME);
+        applySetting("gpu_debug_layers", VK_LAYER_C);
 
         // Specify the external app that hosts layers
         applySetting("gpu_debug_layer_app", LAYERS_APP);
@@ -530,9 +534,7 @@
         getDevice().executeAdbCommand("shell", "am", "start", "-n", APP_NAME + "/" + ACTIVITY);
 
         // Check that our external layer was loaded
-        String searchStringC = "nullCreateInstance called in " + LAYER_C;
-        LogScanResult resultC = scanLog(TAG + "," + LAYER_C, searchStringC, appStartTime);
-        Assert.assertTrue("LayerC was not loaded", resultC.found);
+        assertVkLayerLoading(appStartTime, VK_LAYER_C, true);
     }
 
     /**
@@ -820,7 +822,7 @@
         // Set up layers to be loaded
         applySetting("enable_gpu_debug_layers", "1");
         applySetting("gpu_debug_app", DEBUG_APP);
-        applySetting("gpu_debug_layers", LAYER_C_NAME);
+        applySetting("gpu_debug_layers", VK_LAYER_C);
         applySetting("gpu_debug_layers_gles", GLES_LAYER_C_LIB);
 
         // Specify multple external apps that host layers
@@ -831,9 +833,7 @@
         getDevice().executeAdbCommand("shell", "am", "start", "-n", DEBUG_APP + "/" + ACTIVITY);
 
         // Check that external layers were loaded from both apps
-        String vulkanString = "nullCreateInstance called in " + LAYER_C;
-        LogScanResult vulkanResult = scanLog(TAG + "," + LAYER_C, vulkanString, appStartTime);
-        Assert.assertTrue(LAYER_C + " was not loaded", vulkanResult.found);
+        assertVkLayerLoading(appStartTime, VK_LAYER_C, true);
 
         String glesString = "glesLayer_eglChooseConfig called in " + GLES_LAYER_C;
         LogScanResult glesResult = scanLog(TAG + "," + GLES_LAYER_C, glesString, appStartTime);