tests: test layer insertion
Change-Id: I315a7312514fba817906facf42597c858e2fecd9
diff --git a/tests/test_wrap_objects.sh b/tests/test_wrap_objects.sh
index 7c422fc..2f19f3b 100755
--- a/tests/test_wrap_objects.sh
+++ b/tests/test_wrap_objects.sh
@@ -4,27 +4,134 @@
echo "Testing wrap-objects layer..."
-# Don't print the elapsed time of each test.
-export GTEST_PRINT_TIME=0
-
-# Run the layer validation tests with and without the wrap-objects layer. Diff the results.
-diff \
- <(./vk_layer_validation_tests) \
- <(VK_LAYER_PATH=$VK_LAYER_PATH:`pwd`/layers \
+# Check for insertion of wrap-objects layer.
+output=$(VK_LAYER_PATH=$VK_LAYER_PATH:`pwd`/layers \
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/layers \
VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_wrap_objects \
- ./vk_layer_validation_tests) \
+ VK_LOADER_DEBUG=all \
+ GTEST_FILTER=WrapObjects.Insert \
+ ./vk_loader_validation_tests 2>&1)
-result=$?
+echo "$output" | grep -q "Insert instance layer VK_LAYER_LUNARG_wrap_objects"
+ec=$?
-popd > /dev/null
-
-if [ $result -eq 1 ]
+if [ $ec -eq 1 ]
then
- echo "TEST FAILED - Diff detected" >&2
+ echo "Insertion test FAILED - wrap-objects not detected in instance layers" >&2
exit 1
fi
+echo "$output" | grep -q "Insert device layer VK_LAYER_LUNARG_wrap_objects"
+ec=$?
+
+if [ $ec -eq 1 ]
+then
+ echo "Insertion test FAILED - wrap-objects not detected in device layers" >&2
+ exit 1
+fi
+echo "Insertion test PASSED"
+
+# Check for insertion of wrap-objects layer in front.
+output=$(VK_LAYER_PATH=$VK_LAYER_PATH:`pwd`/layers \
+ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/layers \
+ VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_parameter_validation:VK_LAYER_LUNARG_wrap_objects \
+ VK_LOADER_DEBUG=all \
+ GTEST_FILTER=WrapObjects.Insert \
+ ./vk_loader_validation_tests 2>&1)
+
+echo "$output" | grep -q "Insert instance layer VK_LAYER_LUNARG_wrap_objects"
+ec=$?
+
+if [ $ec -eq 1 ]
+then
+ echo "Front insertion test FAILED - wrap-objects not detected in instance layers" >&2
+ exit 1
+fi
+
+echo "$output" | grep -q "Insert device layer VK_LAYER_LUNARG_wrap_objects"
+ec=$?
+
+if [ $ec -eq 1 ]
+then
+ echo "Front insertion test FAILED - wrap-objects not detected in device layers" >&2
+ exit 1
+fi
+echo "Front insertion test PASSED"
+
+# Check for insertion of wrap-objects layer in back.
+output=$(VK_LAYER_PATH=$VK_LAYER_PATH:`pwd`/layers \
+ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/layers \
+ VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_wrap_objects:VK_LAYER_LUNARG_parameter_validation \
+ VK_LOADER_DEBUG=all \
+ GTEST_FILTER=WrapObjects.Insert \
+ ./vk_loader_validation_tests 2>&1)
+
+echo "$output" | grep -q "Insert instance layer VK_LAYER_LUNARG_wrap_objects"
+ec=$?
+
+if [ $ec -eq 1 ]
+then
+ echo "Back insertion test FAILED - wrap-objects not detected in instance layers" >&2
+ exit 1
+fi
+
+echo "$output" | grep -q "Insert device layer VK_LAYER_LUNARG_wrap_objects"
+ec=$?
+
+if [ $ec -eq 1 ]
+then
+ echo "Back insertion test FAILED - wrap-objects not detected in device layers" >&2
+ exit 1
+fi
+echo "Back insertion test PASSED"
+
+# Check for insertion of wrap-objects layer in middle.
+output=$(VK_LAYER_PATH=$VK_LAYER_PATH:`pwd`/layers \
+ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/layers \
+ VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_device_limits:VK_LAYER_LUNARG_wrap_objects:VK_LAYER_LUNARG_parameter_validation \
+ VK_LOADER_DEBUG=all \
+ GTEST_FILTER=WrapObjects.Insert \
+ ./vk_loader_validation_tests 2>&1)
+
+echo "$output" | grep -q "Insert instance layer VK_LAYER_LUNARG_wrap_objects"
+ec=$?
+
+if [ $ec -eq 1 ]
+then
+ echo "Middle insertion test FAILED - wrap-objects not detected in instance layers" >&2
+ exit 1
+fi
+
+echo "$output" | grep -q "Insert device layer VK_LAYER_LUNARG_wrap_objects"
+ec=$?
+
+if [ $ec -eq 1 ]
+then
+ echo "Middle insertion test FAILED - wrap-objects not detected in device layers" >&2
+ exit 1
+fi
+echo "Middle insertion test PASSED"
+
+# Run the layer validation tests with and without the wrap-objects layer. Diff the results.
+diff \
+ <(GTEST_PRINT_TIME=0 \
+ ./vk_layer_validation_tests) \
+ <(GTEST_PRINT_TIME=0 \
+ VK_LAYER_PATH=$VK_LAYER_PATH:`pwd`/layers \
+ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/layers \
+ VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_wrap_objects \
+ ./vk_layer_validation_tests)
+ec=$?
+
+if [ $ec -eq 1 ]
+then
+ echo "TEST FAILED - wrap-objects altered the results of the layer validation tests" >&2
+ exit 1
+fi
+echo "wrap-objects completed layer validation tests"
+
echo "TEST PASSED"
+popd > /dev/null
+
exit 0