yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
5b9931456
master
1#!/usr/bin/env bash 2set -e 3 4show_help () { 5me =$( basename " $ 0" ) 6cat <<EOF 7$ me : Run all of the examples in test mode 8 9Usage: $ me --os <os> --config <config> --bin-dir <path> --skip-file <path> [--dry-run] 10 11Options: 12--help Show this help message 13--dry-run Skip running the examples. 14--bin-dir <path> Path to binary directory. 15Must contain all of the example binaries. 16--skip-file <path> Path to file containing skip patterns. 17See the 'Skip file' section, below. 18--os <os> Operating system. 19Valid <os> values: 'macos', 'windows', 'linux' 20--config <config> Build configuration. 21Valid <config> values: 'debug', 'release'. 22 23--platform <platform> Target platform. 24Valid <platform> values: 'x86_64', 'aarch64'. 25 26Skip file: 27 28The skip patterns are regexp patterns on the following format: 29<os>:<platform>:<config>:<sample> # Some comment describing why test is disabled 30 31For example: 32# Bug 123: foo-example fails (both debug and release) 33windows:x86_64(debug|release):foo-example 34# Bug 456: bar-example fails in release mode on Linux 35linux:aarch64:release:bar-example 36 37EOF 38} 39 40function user_error () { 41echo "error: $ 1 " >&2 42echo "" >&2 43show_help >&2 44exit 1 45} 46 47while [[" $ #" -gt 0 ]];do 48case $ 1 in 49 -h| --help) 50show_help 51exit 0 52 ;; 53 --dry-run) 54dry_run =true 55 ;; 56 --bin-dir) 57bin_dir =" $ 2 " 58shift 59 ;; 60 --skip-file) 61skip_file =" $ 2 " 62shift 63 ;; 64 --os) 65case $ 2 in 66 windows| linux| macos) ;; 67 *) 68user_error "Unrecognized os: ' $ 2 '" 69 ;; 70esac 71os =" $ 2 " 72shift 73 ;; 74 --config) 75case $ 2 in 76 debug| release) ;; 77 *) 78user_error "Unrecognized config: ' $ 2 '" 79 ;; 80esac 81config =" $ 2 " 82shift 83 ;; 84 --platform) 85case $ 2 in 86 x86_64| aarch64) ;; 87 *) 88user_error "Unrecognized platform: ' $ 2 '" 89 ;; 90esac 91platform =" $ 2 " 92shift 93 ;; 94 *) 95user_error "Unrecognized argument: ' $ 1 '" 96 ;; 97esac 98shift 99done 100 101if [[" $ os " =="" ]];then 102user_error "No OS specified." 103fi 104 105if [[" $ config " =="" ]];then 106user_error "No build configuration specified." 107fi 108 109if [[" $ bin_dir " =="" ]];then 110user_error "No binary directory specified." 111fi 112 113if [[" $ skip_file " =="" ]];then 114user_error "No skip file specified." 115fi 116 117if [[" $ platform " =="" ]];then 118user_error "No platform specified." 119fi 120 121if [[ ! -f" $ skip_file " ]];then 122user_error "Skip file ' $ skip_file ' does not exist." 123fi 124 125if [[ ! -d" $ bin_dir " ]];then 126user_error "Binary directory ' $ bin_dir ' does not exist." 127fi 128 129summary =() 130failure_count =0 131skip_count =0 132sample_count =0 133 134function skip { 135 localp 136 localline_index 137p =" $ 1 " 138line_index =1 139while read -r pattern;do 140pat =$ pattern 141if [[ !$ pat =~ .*# ]];then 142user_error "Skip pattern on line $ line_index is missing a comment!" 143fi 144pat =" ${ pattern %% *#*} " 145if [[$ p =~ ^$pat$ ]];then 146return 0 147fi 148line_index =$((line_index + 1)) 149done < " $ skip_file " 150 151return 1 152} 153 154function run_sample { 155 localsample 156 localargs 157sample =" $ 1 " 158shift 159args =(" $ @" ) 160sample_count =$((sample_count + 1)) 161summary =(" ${ summary [@]} " " $ sample : " ) 162if skip " $ os : $ platform : $ config : $ sample " ;then 163echo "Skipping $ sample ..." 164summary =(" ${ summary [@]} " " skipped" ) 165skip_count =$((skip_count + 1)) 166return 167fi 168echo "Running ' $ sample ${ args [*]} '..." 169result =0 170pushd " $ bin_dir " 1 > /dev/null2 >&1 171if [[ !" $ dry_run " = true ]];then 172./ " $ sample " " ${ args [@]} " ||result =$ ? 173if [[ -f ./"log- $ sample .txt" ]];then 174cat ./"log- $ sample .txt" 175fi 176fi 177if [[$ result -eq 0 ]];then 178summary =(" ${ summary [@]} " " success" ) 179else 180summary =(" ${ summary [@]} " " failure (exit code: $ result )" ) 181failure_count =$((failure_count + 1)) 182fi 183popd 1 > /dev/null2 >&1 184} 185 186sample_commands =( 187'platform-test --test-mode' 188'ray-tracing-pipeline --test-mode' 189'ray-tracing --test-mode' 190'shader-toy --test-mode' 191'triangle --test-mode' 192'model-viewer --test-mode' 193'shader-object' 194'reflection-api' 195'hello-world' 196'gpu-printing' 197'cpu-hello-world' 198'cpu-com-example' 199) 200 201for sample_command in " ${ sample_commands [@]} " ;do 202run_sample ${ sample_command } 203echo "" 204done 205 206echo "" 207echo "Summary: " 208echo 209for line in " ${ summary [@]} " ;do 210printf ' %s\n' " $ line " 211done 212echo "" 213echo " $ failure_count failed, and $ skip_count skipped, out of $ sample_count tests" 214if [[$ failure_count -ne 0 ]];then 215exit 1 216fi