forked from KhronosGroup/Vulkan-Loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_loader_tests.sh
executable file
·146 lines (128 loc) · 5.11 KB
/
run_loader_tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
pushd $(dirname "$0") > /dev/null
RunEnvironmentVariablePathsTest()
{
# Check for proper handling of paths specified via environment variables.
# Set up a layer path that includes default and user-specified locations,
# so that the test app can find them. Include some badly specified elements as well.
vk_layer_path="$VK_LAYER_PATH"
vk_layer_path+=":/usr/local/etc/vulkan/implicit_layer.d:/usr/local/share/vulkan/implicit_layer.d"
vk_layer_path+=":/tmp/carol:::"
vk_layer_path+=":/etc/vulkan/implicit_layer.d:/usr/share/vulkan/implicit_layer.d:$HOME/.local/share/vulkan/implicit_layer.d"
vk_layer_path+=":::::/tandy:"
# Set vars to include some "challenging" paths and run the test.
output=$(VK_LOADER_DEBUG=all \
XDG_CONFIG_DIRS=":/tmp/goober:::::/tmp/goober2/:/tmp/goober3/with spaces:::" \
XDG_DATA_DIRS="::::/tmp/goober4:::::/tmp/goober5:/tmp/goober6/with spaces::::/tmp/goober7:" \
VK_LAYER_PATH=${vk_layer_path} \
GTEST_FILTER=CreateInstance.LayerPresent \
./vk_loader_validation_tests 2>&1)
# Here is a path we expect to find. The loader constructs these from the XDG* env vars.
right_path="/tmp/goober/vulkan/icd.d:/tmp/goober2/vulkan/icd.d:/tmp/goober3/with spaces/vulkan/icd.d"
# There are other paths that come from SYSCONFIG settings established at build time.
# So we can't really guess at what those are here.
right_path+=".*"
# Also expect to find these, since we added them.
right_path+="/tmp/goober4/vulkan/icd.d:/tmp/goober5/vulkan/icd.d:/tmp/goober6/with spaces/vulkan/icd.d:/tmp/goober7/vulkan/icd.d"
echo "$output" | grep -q "$right_path"
ec=$?
if [ $ec -eq 1 ]
then
echo "Environment Variable Path test FAILED - ICD path incorrect" >&2
exit 1
fi
# Change the string to implicit layers.
right_path=${right_path//icd.d/implicit_layer.d}
echo "$output" | grep -q "$right_path"
ec=$?
if [ $ec -eq 1 ]
then
echo "Environment Variable Path test FAILED - Implicit layer path incorrect" >&2
exit 1
fi
# The loader cleans up this path to remove the empty paths, so we need to clean up the right path, too
right_path="${vk_layer_path//:::::/:}"
right_path="${right_path//::::/:}"
echo "$output" | grep -q "$right_path"
ec=$?
if [ $ec -eq 1 ]
then
echo "Environment Variable Path test FAILED - VK_LAYER_PATH incorrect" >&2
exit 1
fi
echo "Environment Variable Path test PASSED"
}
RunCreateInstanceTest()
{
# Check for layer insertion via CreateInstance.
output=$(VK_LOADER_DEBUG=all \
GTEST_FILTER=CreateInstance.LayerPresent \
./vk_loader_validation_tests 2>&1)
echo "$output" | grep -q "Insert instance layer VK_LAYER_LUNARG_test"
ec=$?
if [ $ec -eq 1 ]
then
echo "CreateInstance insertion test FAILED - test layer not detected in instance layers" >&2
exit 1
fi
echo "CreateInstance Insertion test PASSED"
}
RunEnumerateInstanceLayerPropertiesTest()
{
count=$(GTEST_FILTER=EnumerateInstanceLayerProperties.Count \
./vk_loader_validation_tests count 2>&1 |
grep -o 'count=[0-9]\+' | sed 's/^.*=//')
if [ "$count" -gt 1 ]
then
diff \
<(GTEST_PRINT_TIME=0 \
GTEST_FILTER=EnumerateInstanceLayerProperties.OnePass \
./vk_loader_validation_tests count "$count" properties 2>&1 |
grep 'properties') \
<(GTEST_PRINT_TIME=0 \
GTEST_FILTER=EnumerateInstanceLayerProperties.TwoPass \
./vk_loader_validation_tests properties 2>&1 |
grep 'properties')
fi
ec=$?
if [ $ec -eq 1 ]
then
echo "EnumerateInstanceLayerProperties OnePass vs TwoPass test FAILED - properties do not match" >&2
exit 1
fi
echo "EnumerateInstanceLayerProperties OnePass vs TwoPass test PASSED"
}
RunEnumerateInstanceExtensionPropertiesTest()
{
count=$(GTEST_FILTER=EnumerateInstanceExtensionProperties.Count \
./vk_loader_validation_tests count 2>&1 |
grep -o 'count=[0-9]\+' | sed 's/^.*=//')
if [ "$count" -gt 1 ]
then
diff \
<(GTEST_PRINT_TIME=0 \
GTEST_FILTER=EnumerateInstanceExtensionProperties.OnePass \
./vk_loader_validation_tests count "$count" properties 2>&1 |
grep 'properties') \
<(GTEST_PRINT_TIME=0 \
GTEST_FILTER=EnumerateInstanceExtensionProperties.TwoPass \
./vk_loader_validation_tests properties 2>&1 |
grep 'properties')
fi
ec=$?
if [ $ec -eq 1 ]
then
echo "EnumerateInstanceExtensionProperties OnePass vs TwoPass test FAILED - properties do not match" >&2
exit 1
fi
echo "EnumerateInstanceExtensionProperties OnePass vs TwoPass test PASSED"
}
VK_LAYER_PATH="$PWD/layers"
./vk_loader_validation_tests
RunEnvironmentVariablePathsTest
RunCreateInstanceTest
RunEnumerateInstanceLayerPropertiesTest
RunEnumerateInstanceExtensionPropertiesTest
# Test the wrap objects layer.
./run_wrap_objects_tests.sh || exit 1
popd > /dev/null