1#!/usr/bin/env bash 2# 3# Copyright 2023-2024 The Khronos Group Inc. 4# 5# SPDX-License-Identifier: Apache-2.0 6 7# testBuild - invoke Makefile with the right options to build the test spec 8# that is found under build_tests. 9 10# Usage: testBuild 11 12# Build the test spec in various configurations: 13function build_spec() { 14 build=$1 15 options=$2 16 17 echo "-----------------------" 18 echo "Building gen-$build ..." 19 20 # Clean existing build, if any 21 rm -rf build_tests/gen-$build 22 23 # Note: let options expand, do not quote 24 ./makeSpec -spec $options -genpath build_tests/gen-$build -test html 25} 26 27# Core: 28build_spec core "core" 29build_spec core-1.0 "core -version 1.0" 30# With VK_EXT_host_image_copy 31build_spec hic "core -extension VK_EXT_host_image_copy" 32build_spec hic-1.0 "core -extension VK_EXT_host_image_copy -version 1.0" 33# With VK_KHR_copy_commands2 34build_spec copy2-1.0 "core -version 1.0 -extension VK_KHR_copy_commands2" 35# All: 36build_spec all "all" 37build_spec all-1.0 "all -version 1.0" 38 39# Test valid usage generation as well 40echo "-----------------------" 41echo "Generating valid usage ..." 42./makeSpec -spec all -genpath build_tests/gen-validusage -test validusage 43 44echo 45echo "=======================" 46 47# Verify the results against expectations. Note: do this after generating all 48# builds. This is to support the build_tests/update-expectations script that 49# copies the results over the expectations. 50result=0 51for build in core core-1.0 hic hic-1.0 copy2-1.0 all all-1.0; do 52 echo "Verifying gen-$build is as expected..." 53 if ! diff build_tests/expectations/$build.html build_tests/gen-$build/out/html/vkspec.html; then 54 echo " FAILED" 55 result=1 56 fi 57done 58 59echo "Verifying validusage in gen-validusage is as expected..." 60if ! diff build_tests/expectations/validusage.json build_tests/gen-validusage/out/validation/validusage.json; then 61 echo " FAILED" 62 result=1 63fi 64 65if [ "$result" -ne 0 ]; then 66 echo 67 echo "All tests have been built successfully, but the results do not match the" 68 echo "expectations." 69 echo "If trivial, you can review the diff per the above output." 70 echo "Otherwise, please review each failing output at:" 71 echo " - build_tests/gen-*/out/html/vkspec.html, and" 72 echo " - build_tests/gen-validusage/out/validation/validusage.json" 73 echo "And ensure they are acceptable. In that case, update the expectations with:" 74 echo " $ cd build_tests && ./update-expectations" 75 exit 1 76fi 77 78echo "Success" 79