annotate SCRIPTS/process.sh @ 121:08f7d7cdf1df

Add speedy option
author Chris Cannam
date Thu, 28 Sep 2017 10:34:24 +0100
parents 6015c2048c3f
children 9efd2d15cd58 89f0fef1fccd
rev   line source
Chris@1 1 #!/bin/bash
Chris@1 2
Chris@6 3 # Run this from the top-level vamp-build-and-test directory
Chris@6 4
Chris@1 5 ## Things to test:
Chris@1 6 ## the plugin builds!
Chris@1 7 ## plugin loads
Chris@1 8 ## passes vamp-plugin-tester tests
Chris@1 9 ## does not export any unnecessary symbols
Chris@1 10 ## has valid .cat and .n3
Chris@1 11
Chris@88 12 set -e
Chris@86 13
Chris@19 14 mydir=$(dirname "$0")
Chris@19 15 case "$mydir" in /*);; *) mydir=$(pwd)/"$mydir";; esac
Chris@19 16
Chris@75 17 . "$mydir"/include.sh
Chris@75 18
Chris@57 19 have_all=true
Chris@66 20 for program in make perl git svn hg zip tar ; do
Chris@57 21 if ! $program --version >/dev/null 2>&1; then
Chris@57 22 if ! $program -v 2>&1 | grep -q version; then
Chris@57 23 echo " ** $program program not found"
Chris@57 24 have_all=false
Chris@57 25 fi
Chris@57 26 fi
Chris@57 27 done
Chris@57 28 if [ "$have_all" != "true" ]; then
Chris@57 29 echo "Not all dependencies found, exiting"
Chris@57 30 exit 1
Chris@57 31 fi
Chris@57 32
Chris@22 33 do_rebuild=""
Chris@121 34 do_speedy=""
Chris@121 35
Chris@121 36 speedy_test_pattern="^[ABE]"
Chris@14 37
Chris@22 38 usage() {
Chris@22 39 echo
Chris@121 40 echo "Usage: $0 <platform> [-c] [-s] [<dir> ...]"
Chris@22 41 echo
Chris@31 42 echo " <platform> one of native, linux32, linux64, mingw32, mingw64, osx32, osx64"
Chris@22 43 echo " -c build from clean"
Chris@121 44 echo " -s speedy build: skip the slower tests"
Chris@22 45 echo " <dir> directory to build (default is all of them)"
Chris@22 46 echo
Chris@22 47 echo "Platform usually should match the platform you are running this"
Chris@22 48 echo "script on, unless you have a cross-compile toolset installed and"
Chris@31 49 echo "this script knows how to run it. The special platform 'native'"
Chris@31 50 echo "tries to guess the currently running platform."
Chris@22 51 echo
Chris@22 52 exit 2
Chris@22 53 }
Chris@21 54
Chris@31 55 platform_arg="$1"
Chris@109 56 platform_native="unknown"
Chris@109 57 case `uname -a` in
Chris@109 58 Linux*x86_64*) platform_native=linux64;;
Chris@109 59 Linux*) platform_native=linux32;;
Chris@109 60 Darwin*) platform_native=osx64;;
Chris@109 61 CYG*) platform_native=mingw32;;
Chris@109 62 MINGW*) platform_native=mingw32;;
Chris@109 63 esac
Chris@31 64
Chris@31 65 if [ "$platform_arg" = "native" ]; then
Chris@109 66 platform_arg="$platform_native"
Chris@31 67 fi
Chris@31 68
Chris@78 69 platform=
Chris@110 70 platform_defines=("UNUSED_=") # Avoid passing empty arg to make as if target
Chris@114 71 pubtag=
Chris@78 72 bits=32
Chris@78 73 altbits=
Chris@78 74 toolprefix=
Chris@78 75 pluginext=
Chris@78 76 hostwrapper=
Chris@78 77 hostext=
Chris@78 78 valgrind=
Chris@78 79 archflags=
Chris@78 80 identpattern=
Chris@96 81 sep=":"
Chris@78 82
Chris@31 83 case "$platform_arg" in
Chris@22 84 linux32)
Chris@22 85 platform=linux
Chris@114 86 pubtag=linux32
Chris@109 87 if [ "$platform_native" = "linux64" ]; then
Chris@109 88 toolprefix=x86_64-unknown-linux-gnu-
Chris@109 89 platform_defines=("CXX=${toolprefix}g++ -m32" "CC=${toolprefix}gcc -m32" "LD=${toolprefix}g++ -m32")
Chris@109 90 fi
Chris@22 91 pluginext=.so
Chris@38 92 valgrind=valgrind
Chris@42 93 identpattern='ELF 32'
Chris@22 94 ;;
Chris@22 95 linux64)
Chris@22 96 platform=linux
Chris@22 97 bits=64
Chris@114 98 pubtag=linux64
Chris@22 99 pluginext=.so
Chris@38 100 valgrind=valgrind
Chris@42 101 identpattern='ELF 64'
Chris@22 102 ;;
Chris@22 103 mingw32)
Chris@22 104 platform=mingw
Chris@114 105 pubtag=win32
Chris@22 106 toolprefix=i686-w64-mingw32-
Chris@22 107 pluginext=.dll
Chris@22 108 hostwrapper=wine
Chris@22 109 hostext=.exe
Chris@36 110 identpattern='PE32.*386.*Windows'
Chris@96 111 sep=";"
Chris@22 112 ;;
Chris@22 113 mingw64)
Chris@22 114 platform=mingw
Chris@22 115 bits=64
Chris@114 116 pubtag=win64
Chris@78 117 altbits=32 # We can usually use a mingw32 Makefile if toolprefix is OK
Chris@22 118 toolprefix=x86_64-w64-mingw32-
Chris@22 119 pluginext=.dll
Chris@22 120 hostwrapper=wine
Chris@22 121 hostext=.exe
Chris@78 122 identpattern='PE32.*x86-64.*Windows'
Chris@96 123 sep=";"
Chris@22 124 ;;
Chris@22 125 osx32)
Chris@22 126 platform=osx
Chris@114 127 pubtag=osx32
Chris@22 128 pluginext=.dylib
Chris@22 129 archflags="-arch i386"
Chris@40 130 identpattern='Mach-O .*i386'
Chris@22 131 ;;
Chris@22 132 osx64)
Chris@22 133 platform=osx
Chris@22 134 bits=64
Chris@114 135 pubtag=osx
Chris@22 136 pluginext=.dylib
Chris@26 137 # This is a difficult choice for various reasons... have to ponder
Chris@107 138 archflags="-mmacosx-version-min=10.7 -arch x86_64 -arch i386 -stdlib=libc++"
Chris@40 139 identpattern='Mach-O 64-bit .*x86_64'
Chris@22 140 ;;
Chris@88 141 *)
Chris@88 142 usage
Chris@88 143 ;;
Chris@22 144 esac;
Chris@22 145
Chris@22 146 shift
Chris@22 147
Chris@22 148 if [ -z "$platform" ]; then
Chris@22 149 usage
Chris@22 150 else
Chris@114 151 echo "(Platform is $platform, $bits bits, package platform tag $pubtag)"
Chris@22 152 fi
Chris@22 153
Chris@78 154 if [ -z "$pluginext" ]; then
Chris@78 155 echo "Internal error: pluginext not set for platform $platform" 1>&2
Chris@78 156 exit 2
Chris@78 157 fi
Chris@78 158
Chris@78 159 if [ -z "$identpattern" ]; then
Chris@78 160 echo "Internal error: identpattern not set for platform $platform" 1>&2
Chris@78 161 exit 2
Chris@78 162 fi
Chris@78 163
Chris@121 164 while true; do
Chris@121 165 case "t$1" in
Chris@121 166 t-c)
Chris@121 167 echo "(Building from clean)"
Chris@121 168 do_rebuild=yes
Chris@121 169 shift ;;
Chris@121 170 t-s)
Chris@121 171 echo "(Speedy build)"
Chris@121 172 do_speedy=yes
Chris@121 173 shift ;;
Chris@121 174 *)
Chris@121 175 break;;
Chris@121 176 esac
Chris@121 177 done
Chris@15 178
Chris@91 179 metadir="$mydir"/../METADATA
Chris@91 180
Chris@19 181 depincdir="$mydir"/../DEPENDENCIES/$platform$bits/include
Chris@19 182 deplibdir="$mydir"/../DEPENDENCIES/$platform$bits/lib
Chris@88 183 depincdir_generic="$mydir"/../DEPENDENCIES/generic/include
Chris@19 184
Chris@88 185 pyver=27
Chris@88 186 pyincdir="$mydir"/../DEPENDENCIES/$platform$bits/Python$pyver/include
Chris@88 187 numpyincdir="$mydir"/../DEPENDENCIES/$platform$bits/Python$pyver/Lib/site-packages/numpy/core/include
Chris@88 188 pylibdir="$mydir"/../DEPENDENCIES/$platform$bits/Python$pyver/libs
Chris@1 189
Chris@11 190 plugindirs="$@"
Chris@11 191 if [ -z "$plugindirs" ]; then
Chris@100 192 plugindirs=$(cat METADATA/repos.txt | grep -v vamp-plugin-sdk | grep -v vamp-plugin-tester | awk '{ print $1; }')
Chris@61 193 else
Chris@61 194 for dir in $plugindirs ; do
Chris@61 195 if [ ! -d "$dir" ]; then
Chris@61 196 echo "ERROR: Directory $dir not found"
Chris@61 197 usage
Chris@61 198 fi
Chris@61 199 done
Chris@11 200 fi
Chris@11 201
Chris@88 202 set -u
Chris@88 203
Chris@6 204 reportdir="REPORTS/$platform$bits"
Chris@49 205 packagedir="PACKAGES/$platform$bits"
Chris@49 206
Chris@49 207 mkdir -p "$reportdir" "$packagedir" || exit 1
Chris@6 208
Chris@9 209 built="/tmp/built.$$.txt"
Chris@9 210 testfailed="/tmp/testfailed.$$.txt"
Chris@19 211 envcheckfailed="/tmp/envcheckfailed.$$.txt"
Chris@9 212 notbuilt="/tmp/notbuilt.$$.txt"
Chris@49 213
Chris@19 214 trap 'rm -f "$built" "$envcheckfailed" "$testfailed" "$notbuilt"' 0
Chris@19 215 touch "$built" "$envcheckfailed" "$testfailed" "$notbuilt"
Chris@9 216
Chris@86 217 target_for() {
Chris@86 218 local dir="$1"
Chris@91 219 if grep -q "^$dir: " ${metadir}/maketarget.txt ; then
Chris@91 220 grep "^$dir: " ${metadir}/maketarget.txt | head -1 | sed 's/^[^:]*: //'
Chris@86 221 fi
Chris@86 222 }
Chris@86 223
Chris@109 224 custom_plugin_dir_for() {
Chris@86 225 local dir="$1"
Chris@91 226 if grep -q "^$dir: " ${metadir}/plugindir.txt ; then
Chris@91 227 echo "${mydir}/../${dir}"/$(grep "^$dir: " ${metadir}/plugindir.txt | head -1 | sed 's/^[^:]*: //')
Chris@86 228 fi
Chris@86 229 }
Chris@86 230
Chris@109 231 plugin_dir_for() {
Chris@109 232 local dir="$1"
Chris@109 233 local pdir=$(custom_plugin_dir_for "$dir")
Chris@109 234 if [ -z "$pdir" ]; then
Chris@109 235 case "$dir" in
Chris@109 236 /*) pdir="$dir" ;;
Chris@109 237 *) pdir="${mydir}/../${dir}";;
Chris@109 238 esac
Chris@109 239 fi
Chris@109 240 echo "$pdir"
Chris@109 241 }
Chris@109 242
Chris@4 243 configure() {
Chris@86 244 local dir="$1"
Chris@4 245 if [ -f "$dir/configure" ] ; then
Chris@6 246 ( cd "$dir" ; ./configure ) 2>&1 | tee "$reportdir/$dir.configure.txt"
Chris@4 247 fi
Chris@4 248 }
Chris@4 249
Chris@1 250 find_makefile() {
Chris@86 251 local dir="$1"
Chris@9 252 for f in \
Chris@19 253 build/$platform$bits/Makefile.$platform$bits \
Chris@13 254 build/$platform/Makefile.$platform$bits \
Chris@19 255 build/$platform$bits/Makefile.$platform \
Chris@19 256 build/$platform$bits/Makefile \
Chris@19 257 build/Makefile.$platform$bits \
Chris@19 258 Makefile.$platform$bits \
Chris@13 259 build/$platform/Makefile.$platform \
Chris@13 260 build/$platform/Makefile \
Chris@13 261 build/Makefile.$platform \
Chris@9 262 Makefile.$platform \
Chris@78 263 build/$platform$altbits/Makefile.$platform$altbits \
Chris@78 264 build/$platform/Makefile.$platform$altbits \
Chris@78 265 build/$platform$altbits/Makefile.$platform \
Chris@78 266 build/$platform$altbits/Makefile \
Chris@78 267 build/Makefile.$platform$altbits \
Chris@78 268 Makefile.$platform$altbits \
Chris@13 269 Makefile ; do
Chris@1 270 if [ -f "$dir/$f" ]; then
Chris@1 271 echo $f
Chris@1 272 break
Chris@1 273 fi
Chris@1 274 done
Chris@1 275 }
Chris@1 276
Chris@86 277 find_vampy_plugins_in() {
Chris@86 278 local dir="$1"
Chris@86 279 local pdir=$(plugin_dir_for "$dir")
Chris@86 280 find "$pdir" -name \*.py -print0 | xargs -0 grep -l 'import.*\bvampy\b'
Chris@86 281 }
Chris@86 282
Chris@86 283 have_vampy_plugins() {
Chris@86 284 local dir="$1"
Chris@86 285 local plugs=$(find_vampy_plugins_in "$dir")
Chris@86 286 if [ -z "$plugs" ]; then
Chris@86 287 return 1
Chris@86 288 else
Chris@86 289 return 0
Chris@86 290 fi
Chris@86 291 }
Chris@86 292
Chris@13 293 configure_maybe() {
Chris@86 294 local dir="$1"
Chris@43 295 if [ t"$do_rebuild" = t"yes" ]; then
Chris@43 296 configure "$dir"
Chris@43 297 else
Chris@43 298 mfile=$(find_makefile "$dir")
Chris@43 299 if [ -z "$mfile" ]; then
Chris@43 300 configure "$dir"
Chris@43 301 fi
Chris@13 302 fi
Chris@13 303 }
Chris@13 304
Chris@44 305 logfile_for() {
Chris@86 306 local activity="$1"
Chris@86 307 local dir="$2"
Chris@44 308 echo "$reportdir/$dir.$activity.txt"
Chris@44 309 }
Chris@44 310
Chris@4 311 build() {
Chris@86 312 local dir="$1"
Chris@86 313 local log=$(logfile_for build "$dir")
Chris@1 314 if configure_maybe "$dir"; then
Chris@1 315 mfile=$(find_makefile "$dir")
Chris@1 316 if [ -n "$mfile" ]; then
Chris@19 317 target=$(target_for "$dir")
Chris@19 318 TOOLPREFIX="$toolprefix" \
Chris@90 319 CXXFLAGS="-I${depincdir} -I${pyincdir} -I${numpyincdir} -I${depincdir_generic} -I${mydir}/../vamp-plugin-sdk" \
Chris@90 320 LDFLAGS="-L${deplibdir} -L${pylibdir} -L${mydir}/../vamp-plugin-sdk" \
Chris@21 321 ARCHFLAGS="$archflags" \
Chris@109 322 make -C "$dir" -f "$mfile" $target "${platform_defines[@]}" 2>&1 | \
Chris@44 323 tee "$log"
Chris@9 324 return ${PIPESTATUS[0]}
Chris@86 325 elif have_vampy_plugins "$dir"; then
Chris@86 326 return 0
Chris@1 327 else
Chris@88 328 echo "*** Failed to find a Makefile in $dir!" | tee "$log"
Chris@4 329 return 1
Chris@1 330 fi
Chris@1 331 fi
Chris@4 332 }
Chris@4 333
Chris@4 334 rebuild() {
Chris@86 335 local dir="$1"
Chris@86 336 local log=$(logfile_for build "$dir")
Chris@13 337 if configure_maybe "$dir"; then
Chris@4 338 mfile=$(find_makefile "$dir")
Chris@4 339 if [ -n "$mfile" ]; then
Chris@77 340 if make -C "$dir" -f "$mfile" distclean; then
Chris@77 341 build "$dir"
Chris@77 342 elif make -C "$dir" -f "$mfile" clean; then
Chris@32 343 build "$dir"
Chris@32 344 else
Chris@88 345 echo "*** Failed to 'make clean' in $dir!" | tee "$log"
Chris@32 346 return 1
Chris@32 347 fi
Chris@86 348 elif have_vampy_plugins "$dir"; then
Chris@86 349 return 0
Chris@4 350 else
Chris@88 351 echo "*** Failed to find a Makefile in $dir!" | tee "$log"
Chris@4 352 return 1
Chris@4 353 fi
Chris@4 354 fi
Chris@4 355 }
Chris@4 356
Chris@22 357 build_or_rebuild() {
Chris@86 358 local dir="$1"
Chris@22 359 if [ -n "$do_rebuild" ]; then
Chris@22 360 rebuild "$dir"
Chris@22 361 else
Chris@22 362 build "$dir"
Chris@22 363 fi
Chris@22 364 }
Chris@22 365
Chris@19 366 have_plugin() {
Chris@86 367 local dir="$1"
Chris@86 368 local log=$(logfile_for build "$dir")
Chris@19 369 for x in "$dir/"*"$pluginext"; do
Chris@19 370 if [ -f "$x" ]; then
Chris@36 371 if file "$x" | grep -q "$identpattern" ; then
Chris@36 372 return 0
Chris@36 373 else
Chris@44 374 echo "Plugin $x exists, but fails to match file type for correct platform (file type is: `file $x`, expected pattern is: $identpattern)" | tee "$log"
Chris@36 375 return 1
Chris@36 376 fi
Chris@19 377 fi
Chris@19 378 done
Chris@86 379 have_vampy_plugins "$dir"
Chris@19 380 }
Chris@19 381
Chris@19 382 is_nondeterministic() {
Chris@19 383 plugin_id="$1"
Chris@91 384 grep -q "^$id\$" ${metadir}/nondeterministic.txt
Chris@19 385 }
Chris@19 386
Chris@44 387 plugin_ids_in() {
Chris@86 388 local dir="$1"
Chris@86 389 local pdir=$(plugin_dir_for "$dir")
Chris@86 390 local vampydir=""
Chris@86 391 if have_vampy_plugins "$pdir"; then
Chris@86 392 vampydir="./vampy"
Chris@86 393 fi
Chris@40 394 # can't use sed to remove \r from DOS line endings -- BSD and GNU
Chris@44 395 # vary in how they interpret \r escape -- so we use perl for that...
Chris@109 396 VAMP_PATH="$pdir$sep$vampydir" $hostwrapper \
Chris@44 397 vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids | \
Chris@44 398 grep '^vamp:' | \
Chris@44 399 sed 's/^vamp://' | \
Chris@44 400 perl -p -e 's/\r//g'
Chris@44 401 }
Chris@44 402
Chris@44 403 run_tester() {
Chris@44 404 ##!!! todo: timeout if the plugin takes too long and report as failure
Chris@86 405 local dir="$1"
Chris@86 406 local log=$(logfile_for test "$dir")
Chris@86 407 local ids=$(plugin_ids_in "$dir")
Chris@86 408 local pdir=$(plugin_dir_for "$dir")
Chris@44 409 cat /dev/null > "$log"
Chris@6 410 if [ -z "$ids" ]; then
Chris@6 411 echo
Chris@44 412 echo "No plugins reported to test in $dir" | tee -a "$log"
Chris@44 413 echo "$dir" >> "$testfailed"
Chris@44 414 return 1
Chris@44 415 fi
Chris@44 416 good=yes
Chris@44 417 for id in $ids; do
Chris@44 418 extra=""
Chris@44 419 if is_nondeterministic "$id"; then
Chris@44 420 extra="-n"
Chris@44 421 fi
Chris@121 422 tests=$($hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext -l | tail -n +6 | sed 's/ *|.*$//' | fmt -1000)
Chris@121 423 for test in $tests; do
Chris@121 424 run_this_test=yes
Chris@121 425 if [ -n "$do_speedy" ]; then
Chris@121 426 if echo "$test" | grep -q "$speedy_test_pattern"; then
Chris@121 427 run_this_test=yes
Chris@121 428 else
Chris@121 429 run_this_test=""
Chris@121 430 fi
Chris@121 431 fi
Chris@121 432 if [ -z "$run_this_test" ]; then
Chris@121 433 continue
Chris@121 434 fi
Chris@121 435 echo "Running command: VAMP_PATH=\"$pdir\" $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext \"$extra\" -t \"$test\" \"$id\"" | tee -a "$log"
Chris@121 436 if ( VAMP_PATH="$pdir$sep./vampy" time $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext "$extra" -t "$test" "$id" 2>&1 | tee -a "$log" ; exit ${PIPESTATUS[0]} ) ; then
Chris@121 437 echo "OK" | tee -a "$log"
Chris@86 438 else
Chris@121 439 if [ -n "$do_speedy" ]; then
Chris@121 440 echo | tee -a "$log"
Chris@121 441 echo "Tester failed for id $id and test $test (not restarting with valgrind, as speedy flag is set)" | tee -a "$log"
Chris@121 442 elif have_vampy_plugins "$pdir"; then # (don't attempt vampy+valgrind)
Chris@121 443 echo | tee -a "$log"
Chris@121 444 echo "Tester failed for id $id and test $test (not restarting with valgrind, as this is a VamPy plugin)" | tee -a "$log"
Chris@121 445 else
Chris@121 446 echo | tee -a "$log"
Chris@121 447 echo "Tester failed for id $id and test $test: running again with valgrind (if available) and verbose for a report..." | tee -a "$log"
Chris@121 448 VAMP_PATH="$pdir$sep./vampy" $valgrind $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext -v "$extra" -t "$test" "$id" 2>&1 | tee -a "$log"
Chris@121 449 fi
Chris@121 450 good=no
Chris@86 451 fi
Chris@121 452 done
Chris@44 453 done
Chris@44 454 if [ "$good" != "yes" ]; then
Chris@23 455 echo "$dir" >> "$testfailed"
Chris@6 456 return 1
Chris@5 457 else
Chris@44 458 return 0
Chris@5 459 fi
Chris@5 460 }
Chris@5 461
Chris@44 462 public_symbols_in() {
Chris@9 463 lib="$1"
Chris@23 464 # nm -g prints global symbols in both OS/X and GNU tools, but
Chris@23 465 # printing only global *defined* symbols is harder. In GNU it is
Chris@23 466 # nm -g --defined-only; the OS/X docs suggest nm -gu should work,
Chris@23 467 # but it doesn't. What I think will work with both is simply
Chris@23 468 # grepping out the undefineds:
Chris@109 469 nm="${toolprefix}nm"
Chris@109 470 if ! type -path "$nm" >/dev/null; then nm=nm; fi
Chris@109 471 "$nm" -g "$lib" | grep -v ' U ' | awk '{ print $3; }'
Chris@9 472 }
Chris@9 473
Chris@44 474 env_test_exports() {
Chris@86 475 local dir="$1"
Chris@86 476 local log=$(logfile_for envtest "$dir")
Chris@86 477 local good=yes
Chris@44 478 for lib in "$dir"/*"$pluginext"; do
Chris@44 479 if [ ! -f "$lib" ]; then
Chris@44 480 # This should only happen if the glob was not expanded at all
Chris@44 481 echo "NOTE: no library found in $dir?" | tee -a "$log"
Chris@44 482 good=no
Chris@44 483 break
Chris@44 484 fi
Chris@44 485 echo
Chris@44 486 echo "Testing for exported symbols in $lib..."
Chris@44 487 if public_symbols_in "$lib" | grep -q vampGetPluginDescriptor; then
Chris@44 488 others=`public_symbols_in "$lib" | grep -v vampGetPluginDescriptor`
Chris@44 489 if [ -n "$others" ]; then
Chris@44 490 count=`echo "$others" | wc -l`
Chris@44 491 echo "ERROR: library $lib exports $count extra symbols in addition to vampGetPluginDescriptor" | tee -a "$log"
Chris@44 492 good=no
Chris@44 493 else
Chris@44 494 echo "GOOD: library $lib only exports vampGetPluginDescriptor" | tee -a "$log"
Chris@44 495 fi
Chris@44 496 else
Chris@44 497 echo "NOTE: found library $lib that is not a Vamp plugin library" | tee -a "$log"
Chris@44 498 fi
Chris@44 499 done
Chris@44 500 [ "$good" = "yes" ]
Chris@44 501 }
Chris@44 502
Chris@44 503 env_test_stdout() {
Chris@86 504 local dir="$1"
Chris@86 505 local log=$(logfile_for envtest "$dir")
Chris@86 506 local pdir=$(plugin_dir_for "$dir")
Chris@86 507 local good=yes
Chris@109 508 local ids=$(VAMP_PATH="$pdir" $hostwrapper vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids);
Chris@44 509 echo
Chris@44 510 echo "Testing for any unwanted output to stdout..."
Chris@44 511 for id in $ids; do
Chris@44 512 case "$id" in
Chris@44 513 vamp:*) ;;
Chris@44 514 *)
Chris@44 515 echo "ERROR: plugin in $dir prints to stdout as it runs: found text $id (should use stderr for debug logging to avoid mixing with batch output stream)" | tee -a "$log"
Chris@44 516 good=no
Chris@44 517 ;;
Chris@44 518 esac
Chris@44 519 done
Chris@44 520 [ "$good" = "yes" ]
Chris@44 521 }
Chris@44 522
Chris@44 523 env_test_cat() {
Chris@86 524 local dir="$1"
Chris@86 525 local log=$(logfile_for envtest "$dir")
Chris@109 526 local pdir=$(custom_plugin_dir_for "$dir")
Chris@86 527 local cdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
Chris@86 528 local good=yes
Chris@86 529 local first=yes
Chris@44 530 echo
Chris@44 531 echo "Testing some details of .cat files..."
Chris@80 532 for catfile in "$cdir"/*".cat"; do
Chris@44 533 if [ ! -f "$catfile" ]; then
Chris@44 534 # This should only happen if the glob was not expanded at all
Chris@44 535 echo "ERROR: no .cat file found in $dir" | tee -a "$log"
Chris@44 536 good=no
Chris@44 537 break
Chris@44 538 fi
Chris@44 539 if [ "$first" = "yes" ]; then
Chris@44 540 first=no
Chris@44 541 else
Chris@80 542 echo "NOTE: multiple .cat files found in $cdir" | tee -a "$log"
Chris@44 543 fi
Chris@44 544 done
Chris@44 545 if [ "$good" = "yes" ]; then
Chris@46 546 excess=$(plugin_ids_in "$dir" | sed 's/^/vamp:/' | \
Chris@85 547 cat - "$cdir"/*".cat" | \
Chris@47 548 sed 's/::.*//' | \
Chris@47 549 sort | \
Chris@47 550 uniq -u)
Chris@44 551 if [ -n "$excess" ]; then
Chris@47 552 echo "ERROR: excess or missing definitions in .cat file? $excess" | tee -a "$log"
Chris@44 553 good=no
Chris@44 554 else
Chris@47 555 echo "GOOD: no excess or missing definitions in .cat files" | tee -a "$log"
Chris@44 556 fi
Chris@44 557 fi
Chris@44 558 [ "$good" = "yes" ]
Chris@44 559 }
Chris@44 560
Chris@44 561 env_test_ttl() {
Chris@86 562 local dir="$1"
Chris@86 563 local log=$(logfile_for envtest "$dir")
Chris@109 564 local pdir=$(custom_plugin_dir_for "$dir")
Chris@86 565 local rdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
Chris@86 566 local good=yes
Chris@86 567 local first=yes
Chris@44 568 echo
Chris@44 569 echo "Testing existence of RDF files..."
Chris@80 570 for ttlfile in "$rdir"/*.{n3,ttl}; do
Chris@44 571 if [ ! -f "$ttlfile" ]; then
Chris@44 572 # Because we have two different extensions, this isn't an
Chris@44 573 # error as it is with e.g. .cat (because one or the other
Chris@44 574 # of .n3 and .ttl almost certainly won't exist). But if we
Chris@44 575 # drop out the bottom and first is still true, then we
Chris@44 576 # know neither matched.
Chris@44 577 :
Chris@44 578 elif [ "$first" = "yes" ]; then
Chris@44 579 first=no
Chris@44 580 else
Chris@80 581 echo "NOTE: multiple .ttl or .n3 files found in $rdir" | tee -a "$log"
Chris@44 582 fi
Chris@44 583 done
Chris@80 584 if [ "$first" = "yes" ]; then
Chris@80 585 echo "ERROR: no .ttl or .n3 files found in $rdir" | tee -a "$log"
Chris@45 586 good=no;
Chris@45 587 else
Chris@45 588 echo "GOOD: found one or more .ttl or .n3 files (we don't actually test their validity or content here though)" | tee -a "$log"
Chris@45 589 fi
Chris@45 590 [ "$good" = "yes" ]
Chris@45 591 }
Chris@45 592
Chris@45 593 env_test_accompaniments() {
Chris@86 594 local dir="$1"
Chris@86 595 local log=$(logfile_for envtest "$dir")
Chris@86 596 local good=yes
Chris@46 597 echo
Chris@46 598 echo "Testing existence of README and accompanying files..."
Chris@66 599 if ! ls -1 "$dir" | egrep -qi "^readme(.txt)?$"; then
Chris@45 600 echo "ERROR: no README file found" | tee -a "$log"
Chris@45 601 good=no
Chris@45 602 fi
Chris@53 603 if ! ls -1 "$dir" | egrep -qi "^(copying|licen[cs]e)(.txt)?$"; then
Chris@45 604 echo "ERROR: no COPYING or LICEN[CS]E file found" | tee -a "$log"
Chris@45 605 good=no
Chris@45 606 fi
Chris@53 607 if ! ls -1 "$dir" | egrep -qi "^citation(.txt)?$"; then
Chris@45 608 echo "NOTE: no CITATION file found" | tee -a "$log"
Chris@45 609 fi
Chris@44 610 [ "$good" = "yes" ]
Chris@44 611 }
Chris@44 612
Chris@9 613 run_environmental_tests() {
Chris@86 614 local dir="$1"
Chris@86 615 local log=$(logfile_for envtest "$dir")
Chris@86 616 local allgood=yes
Chris@44 617 cat /dev/null > "$log"
Chris@45 618 for test in exports stdout cat ttl accompaniments; do
Chris@44 619 "env_test_$test" "$dir" || allgood=no
Chris@9 620 done
Chris@44 621 if [ "$allgood" != "yes" ]; then
Chris@19 622 echo "$dir" >> "$envcheckfailed"
Chris@44 623 return 1
Chris@44 624 else
Chris@44 625 return 0
Chris@19 626 fi
Chris@9 627 }
Chris@4 628
Chris@49 629 package() {
Chris@86 630 local dir="$1"
Chris@86 631 local id=$(vcs_id "$dir")
Chris@114 632 local pstub="$dir-$pubtag-$id"
Chris@86 633 local pdir="$packagedir/$pstub"
Chris@49 634 mkdir -p "$pdir"
Chris@49 635 ( cd "$dir" ;
Chris@49 636 cp -av \
Chris@49 637 *"$pluginext" \
Chris@49 638 *.cat \
Chris@49 639 *.n3 \
Chris@49 640 *.ttl \
Chris@49 641 [Rr][Ee][Aa][Dd][Mm][Ee]* \
Chris@49 642 [Cc][Oo][Pp][Yy][Ii][Nn][Gg]* \
Chris@49 643 [Ll][Ii][Cc][Ee][Nn][CcSs][Ee]* \
Chris@49 644 [Cc][Ii][Tt][Aa][Tt][Ii][Oo][Nn]* \
Chris@49 645 [Cc][Hh][Aa][Nn][Gg][Ee][Ll][Oo][Gg]* \
Chris@105 646 ../"$pdir"/ || true
Chris@86 647 if have_vampy_plugins "$dir"; then
Chris@86 648 find_vampy_plugins_in "$dir" | while read p; do
Chris@86 649 cp -av "$p" ../"$pdir"/
Chris@86 650 done
Chris@86 651 fi
Chris@49 652 )
Chris@49 653 ( cd "$packagedir";
Chris@49 654 if [ "$platform" = "mingw" ]; then
Chris@54 655 zip -r "$pstub".zip "$pstub"
Chris@49 656 else
Chris@53 657 tar cvjf "$pstub".tar.bz2 "$pstub"
Chris@49 658 fi;
Chris@53 659 rm -rf "$pstub"
Chris@49 660 )
Chris@49 661 }
Chris@49 662
Chris@22 663 if ! build_or_rebuild "vamp-plugin-sdk"; then
Chris@88 664 echo "*** Failed to build Vamp plugin SDK!"
Chris@5 665 exit 1
Chris@5 666 fi
Chris@5 667
Chris@26 668 # Ensure we can only link statically against these
Chris@26 669 for x in vamp-hostsdk vamp-sdk; do
Chris@26 670 for y in dylib dll so; do
Chris@26 671 rm -f "vamp-plugin-sdk/lib$x.$y"
Chris@26 672 rm -f "vamp-plugin-sdk/$x.$y"
Chris@26 673 done
Chris@26 674 done
Chris@26 675
Chris@22 676 if ! build_or_rebuild "vamp-plugin-tester"; then
Chris@88 677 echo "*** Failed to build Vamp plugin tester!"
Chris@5 678 exit 1
Chris@5 679 fi
Chris@5 680
Chris@88 681 need_vampy=no
Chris@88 682 for dir in $plugindirs ; do
Chris@88 683 if have_vampy_plugins "$dir"; then
Chris@88 684 need_vampy=yes
Chris@88 685 break
Chris@88 686 fi
Chris@88 687 done
Chris@88 688 if [ "$need_vampy" = "yes" ] && [ "$plugindirs" != "vampy" ]; then
Chris@88 689 if ! build_or_rebuild "vampy"; then
Chris@88 690 echo "*** Failed to build VamPy! (needed for other plugins)"
Chris@88 691 exit 1
Chris@88 692 fi
Chris@88 693 fi
Chris@88 694
Chris@11 695 for dir in $plugindirs ; do
Chris@31 696 dir=${dir%/*}
Chris@4 697 echo
Chris@4 698 echo "Processing: $dir"
Chris@31 699 if [ ! -d "$dir" ]; then
Chris@31 700 echo "Directory $dir not found!"
Chris@31 701 echo "$dir" >> "$notbuilt"
Chris@31 702 elif build_or_rebuild "$dir"; then
Chris@19 703 if have_plugin "$dir" ; then
Chris@19 704 echo "$dir" >> "$built"
Chris@86 705 if ! run_tester "$dir"; then
Chris@86 706 echo "Tester failed for $dir"
Chris@86 707 fi
Chris@86 708 if ! run_environmental_tests "$dir"; then
Chris@86 709 echo "Environmental tests failed for $dir"
Chris@86 710 fi
Chris@19 711 else
Chris@44 712 log=$(logfile_for build "$dir")
Chris@44 713 echo "Build apparently succeeded, but no resulting plugin(s) found, or plugin(s) have wrong file type or platform" | tee -a "$log"
Chris@19 714 echo "$dir" >> "$notbuilt"
Chris@19 715 fi
Chris@4 716 else
Chris@6 717 echo "$dir" >> "$notbuilt"
Chris@4 718 fi
Chris@44 719 slog=$(logfile_for summary "$dir")
Chris@86 720 echo "initialising logfile $slog for $dir"
Chris@44 721 cat /dev/null > "$slog"
Chris@1 722 done
Chris@1 723
Chris@49 724 cat "$built" | while read dir; do
Chris@49 725 package "$dir"
Chris@49 726 done
Chris@49 727
Chris@4 728 echo
Chris@49 729 echo "** Built, tested, checked, and packaged:"
Chris@44 730 cat "$built" | while read dir; do
Chris@44 731 slog=$(logfile_for summary "$dir")
Chris@44 732 if ! grep -q "^$dir\$" "$testfailed"; then
Chris@44 733 if ! grep -q "^$dir\$" "$envcheckfailed"; then
Chris@44 734 echo "$dir"
Chris@59 735 echo "$dir: OK: Success" >> "$slog"
Chris@32 736 fi
Chris@6 737 fi
Chris@6 738 done | sort
Chris@4 739
Chris@4 740 echo
Chris@19 741 echo "** Failed tests:"
Chris@44 742 cat "$testfailed" | sort | uniq | while read dir; do
Chris@44 743 slog=$(logfile_for summary "$dir")
Chris@44 744 echo "$dir"
Chris@59 745 echo "$dir: TEST_FAILED: Built successfully, but failed tests" >> "$slog"
Chris@6 746 done
Chris@5 747
Chris@5 748 echo
Chris@19 749 echo "** Failed environmental checks:"
Chris@44 750 cat "$envcheckfailed" | sort | uniq | while read dir; do
Chris@44 751 slog=$(logfile_for summary "$dir")
Chris@44 752 echo "$dir"
Chris@59 753 echo "$dir: ENV_FAILED: Built successfully, but failed environmental checks" >> "$slog"
Chris@19 754 done
Chris@19 755
Chris@19 756 echo
Chris@4 757 echo "** Failed to build:"
Chris@44 758 cat "$notbuilt" | sort | while read dir; do
Chris@44 759 slog=$(logfile_for summary "$dir")
Chris@44 760 echo "$dir"
Chris@59 761 echo "$dir: BUILD_FAILED: Failed to compile" >> "$slog"
Chris@6 762 done
Chris@4 763
Chris@4 764 echo