Skip to content

Commit c2a0b62

Browse files
karl-lunargmark-lunarg
authored andcommitted
tests: Add some env var testing to loader tests.
Tests recently added env var parsing code added to loader. Change-Id: Ic58d92dfeaed725f02a8f4a79c60d9b4b363aa3f
1 parent 06727c7 commit c2a0b62

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

tests/run_loader_tests.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,62 @@
22

33
pushd $(dirname "$0") > /dev/null
44

5+
RunEnvironmentVariablePathsTest()
6+
{
7+
# Check for proper handling of paths specified via environment variables.
8+
9+
# Set up a layer path that includes default and user-specified locations,
10+
# so that the test app can find them. Include some badly specified elements as well.
11+
vk_layer_path="$VK_LAYER_PATH"
12+
vk_layer_path+=":/usr/local/etc/vulkan/implicit_layer.d:/usr/local/share/vulkan/implicit_layer.d"
13+
vk_layer_path+=":/tmp/carol:::"
14+
vk_layer_path+=":/etc/vulkan/implicit_layer.d:/usr/share/vulkan/implicit_layer.d:$HOME/.local/share/vulkan/implicit_layer.d"
15+
vk_layer_path+=":::::/tandy:"
16+
17+
# Set vars to include some "challenging" paths and run the test.
18+
output=$(VK_LOADER_DEBUG=all \
19+
XDG_CONFIG_DIRS=":/tmp/goober:::::/tmp/goober2/:/tmp/goober3/with spaces:::" \
20+
XDG_DATA_DIRS="::::/tmp/goober4:::::/tmp/goober5:/tmp/goober6/with spaces::::/tmp/goober7:" \
21+
VK_LAYER_PATH=${vk_layer_path} \
22+
GTEST_FILTER=CreateInstance.LayerPresent \
23+
./vk_loader_validation_tests 2>&1)
24+
25+
# Here is a path we expect to find. The loader constructs these from the XDG* env vars.
26+
right_path="/tmp/goober/vulkan/icd.d:/tmp/goober2//vulkan/icd.d:/tmp/goober3/with spaces/vulkan/icd.d"
27+
# There are other paths that come from SYSCONFIG settings established at build time.
28+
# So we can't really guess at what those are here.
29+
right_path+=".*"
30+
# Also expect to find these, since we added them.
31+
right_path+="/tmp/goober4/vulkan/icd.d:/tmp/goober5/vulkan/icd.d:/tmp/goober6/with spaces/vulkan/icd.d:/tmp/goober7/vulkan/icd.d"
32+
echo "$output" | grep -q "$right_path"
33+
ec=$?
34+
if [ $ec -eq 1 ]
35+
then
36+
echo "Environment Variable Path test FAILED - ICD path incorrect" >&2
37+
exit 1
38+
fi
39+
# Change the string to implicit layers.
40+
right_path=${right_path//icd.d/implicit_layer.d}
41+
echo "$output" | grep -q "$right_path"
42+
ec=$?
43+
if [ $ec -eq 1 ]
44+
then
45+
echo "Environment Variable Path test FAILED - Implicit layer path incorrect" >&2
46+
exit 1
47+
fi
48+
# Sadly, the loader does not clean up this path and just stumbles through it.
49+
# So just make sure it is the same.
50+
right_path="${vk_layer_path}"
51+
echo "$output" | grep -q "$right_path"
52+
ec=$?
53+
if [ $ec -eq 1 ]
54+
then
55+
echo "Environment Variable Path test FAILED - VK_LAYER_PATH incorrect" >&2
56+
exit 1
57+
fi
58+
echo "Environment Variable Path test PASSED"
59+
}
60+
561
RunCreateInstanceTest()
662
{
763
# Check for layer insertion via CreateInstance.
@@ -78,6 +134,7 @@ RunEnumerateInstanceExtensionPropertiesTest()
78134

79135
./vk_loader_validation_tests
80136

137+
RunEnvironmentVariablePathsTest
81138
RunCreateInstanceTest
82139
RunEnumerateInstanceLayerPropertiesTest
83140
RunEnumerateInstanceExtensionPropertiesTest

0 commit comments

Comments
 (0)