3 pushd $(dirname "$0") > /dev/null
7 # Check for local implicit directory.
9 local implicitDirectory="$HOME/.local/share/vulkan/implicit_layer.d"
10 if [ ! -d "$implicitDirectory" ]
12 mkdir -p "$implicitDirectory"
15 # Check for the shared object.
16 local sharedObject="libVkLayer_test.so"
17 local layerDirectory="./layers"
18 if [ ! -f "$layerDirectory/$sharedObject" ]
20 echo "The file, $layerDirectory/$sharedObject, can not be found." >&2
24 # Check for the json which does not include the optional enable environment variable.
25 local json="VkLayer_test.json"
26 if [ ! -f "$layerDirectory/$json" ]
28 echo "The file, $layerDirectory/$json, can not be found." >&2
32 # Copy the test layer into the implicit directory.
33 if ! cp "$layerDirectory/$sharedObject" "$implicitDirectory/" || ! cp "$layerDirectory/$json" "$implicitDirectory/"
35 echo "unable to install test layer" >&2
39 # Test without setting enable environment variable. The loader should not load the layer.
40 output=$(GTEST_FILTER=ImplicitLayer.Present \
41 ./vk_loader_validation_tests 2>&1)
42 if echo "$output" | grep -q "VK_LAYER_LUNARG_test: CreateInstance"
44 echo "test layer detected but enable environment variable was not set" >&2
48 # Test enable environment variable with good value. The loader should load the layer.
49 output=$(ENABLE_LAYER_TEST_1=enable \
50 GTEST_FILTER=ImplicitLayer.Present \
51 ./vk_loader_validation_tests 2>&1)
52 if ! echo "$output" | grep -q "VK_LAYER_LUNARG_test: CreateInstance"
54 echo "test layer not detected" >&2
58 # Test enable environment variable with bad value. The loader should not load the layer.
59 output=$(ENABLE_LAYER_TEST_1=wrong \
60 GTEST_FILTER=ImplicitLayer.Present \
61 ./vk_loader_validation_tests 2>&1)
62 if echo "$output" | grep -q "VK_LAYER_LUNARG_test: CreateInstance"
64 echo "test layer detected but enable environment variable was set to wrong value" >&2
68 # Test disable environment variable. The loader should not load the layer.
69 output=$(DISABLE_LAYER_TEST_1=value \
70 GTEST_FILTER=ImplicitLayer.Present \
71 ./vk_loader_validation_tests 2>&1)
72 if echo "$output" | grep -q "VK_LAYER_LUNARG_test: CreateInstance"
74 echo "test layer detected but disable environment variable was set" >&2
78 # Remove the enable environment variable.
79 if ! sed -i '/enable_environment\|ENABLE_LAYER_TEST_1\|},/d' "$implicitDirectory/$json"
81 echo "unable to remove enable environment variable" >&2
85 # Test without setting enable environment variable. The loader should load the layer.
86 output=$(GTEST_FILTER=ImplicitLayer.Present \
87 ./vk_loader_validation_tests 2>&1)
88 if ! echo "$output" | grep -q "VK_LAYER_LUNARG_test: CreateInstance"
90 echo "test layer not detected" >&2
94 # Remove the test layer.
95 if ! rm "$implicitDirectory/$sharedObject" || ! rm "$implicitDirectory/$json"
97 echo "unable to uninstall test layer" >&2
101 echo "ImplicitLayer test PASSED"
104 ! RunImplicitLayerTest && echo "ImplicitLayer test FAILED" >&2 && exit 1