1#! /bin/sh 2 3# $Id: check_make_cfg.sh 633243 2021-06-15 18:16:21Z ivanov $ 4# Author: Vladimir Ivanov, NCBI 5# 6########################################################################### 7# 8# Compile a check script and copy necessary files to run tests in the 9# MS VisualC++ / XCODE build tree. 10# 11# Usage: 12# check_make_cfg.sh <compiler> <action> <solution> <static|dll> <cfg> [build_dir] 13# 14# <compiler> - { MSVC | XCODE } 15# <action> - { init | create } 16# init - initialize master script directory (MSVC only); 17# create - create check script. 18# <solution> - solution file name without .sln extention 19# (relative path from build directory). 20# <static|dll> - type of used libraries (static, dll). 21# <cfg> - configuration name 22# (Debug, DebugDLL, DebugMT, Release, ReleaseDLL, ReleaseMT,...). 23# [build_dir] - path to build tree like ".../msvc1000_prj" 24# (default: will try determine path from current work 25# directory -- root of build tree) 26# 27########################################################################### 28 29# Load configuration options 30x_check_scripts_dir=`dirname "$0"` 31. ${x_check_scripts_dir}/check_setup.cfg 32 33 34# Field delimiters in the list (this symbols used directly in the "sed" command) 35x_tmp="/tmp" 36x_date_format="%m/%d/%Y %H:%M:%S" 37 38# Arguments 39x_compiler=$1 40x_action=$2 41x_solution=$3 42x_libdll=$4 43x_cfg=$5 44x_build_dir=$6 45 46 47is_msvc=false 48case "$x_compiler" in 49 MSVC ) is_msvc=true ;; 50 XCODE ) ;; 51 * ) echo "Unknown compiler name \"$x_compiler\"."; exit 1 ;; 52esac 53 54if test ! -z "$x_build_dir"; then 55 if test ! -d "$x_build_dir"; then 56 echo "Build directory \"$x_build_dir\" don't exist." 57 exit 1 58 fi 59 # Expand path and remove trailing slash 60 x_build_dir=`(cd "$x_build_dir"; pwd | sed -e 's/\/$//g')` 61else 62 # Get build dir name from current work directory 63 x_build_dir=`pwd` 64fi 65x_root_dir=`echo "$x_build_dir" | sed -e 's%/compilers/.*$%%'` 66 67### Init 68 69if test $# -eq 2 -a $x_action = "init"; then 70 # MSVC only 71 test $x_compiler != "MSVC" && exit 0; 72 # Change script's command interpreter from /bin/sh to /bin/bash. 73 # Cygwin's shell don't works correctly with process pids. 74 # echo "Changing scripts command interpreter..." 75 script_dirs="scripts" 76 tmp="$x_tmp/check_make_win.$$" 77 78 for d in $script_dirs; do 79 script_list=`find $x_root_dir/$d -name '*.sh'` 80 for s in $script_list; do 81 echo $s | grep 'check_make_' > /dev/null 2>&1 && continue 82 grep '^#! */bin/sh' $s > /dev/null 2>&1 83 if test $? -eq 0; then 84 cp -fp $s $tmp || exit 2 85 sed -e 's|^#! */bin/sh.*$|#! /bin/bash|' $s > $tmp || exit 2 86 chmod a+x $s 87 touch -r $s $tmp || exit 2 88 cp -fp $tmp $s || exit 2 89 rm -f $tmp || exit 2 90 fi 91 done 92 done 93 exit 0; 94fi 95 96 97### Create 98 99if test $# -lt 4; then 100 echo "Usage: $0 <cmd> <solution> <static|dll> <32|64> <cfg> [build_dir]" && exit 1 101fi 102 103# Check list 104 105case "$x_compiler" in 106 MSVC ) x_check_dir="$x_build_dir/$x_libdll/build/${x_solution}.check/$x_cfg" 107 x_time="time.exe -p" 108 ;; 109 XCODE ) x_check_dir="$x_build_dir/$x_libdll/${x_solution}.check/$x_cfg" 110 x_time="time -p" 111 ;; 112esac 113if test ! -d "$x_check_dir"; then 114 echo "Check directory \"$x_check_dir\" not found." 115 exit 1 116fi 117x_list="$x_check_dir/check.sh.list" 118if test ! -f "$x_list"; then 119 echo "Check list file \"$x_list\" not found." 120 exit 1 121fi 122x_out="$x_check_dir/check.sh" 123x_script_name=`echo "$x_out" | sed -e 's%^.*/%%'` 124 125 126# Determine signature of the build (only for automatic builds) 127signature="" 128if test -n "$NCBI_AUTOMATED_BUILD"; then 129 if test $x_compiler = "XCODE"; then 130 ncbiconf="$x_build_dir/$x_libdll/inc/$x_cfg/common/config/ncbiconf_xcode_site.h" 131 signature=`grep "\"XCODE.*\"" $ncbiconf | sed 's/.*\"\(XCODE.*\)\".*/\1/'` 132 else 133 case "$COMPILER" in 134 msvc7 ) signature="MSVC_710" ;; 135 msvc8 ) signature="MSVC_800" ;; 136 msvc9 ) signature="MSVC_900" ;; 137 msvc10 ) signature="MSVC_1000" ;; 138 vs2012 ) signature="VS_2012" ;; 139 vs2013 ) signature="VS_2013" ;; 140 vs2015 ) signature="VS_2015" ;; 141 vs2017 ) signature="VS_2017" ;; 142 esac 143 signature="$signature-${x_cfg}" 144 case "$x_cfg" in 145 *DLL) signature="${signature}MT" ;; 146 *MT ) ;; 147 * ) signature="${signature}ST" ;; 148 esac 149 signature="${signature}${x_libdll}${ARCH}--i386-pc-win${ARCH:-32}-${COMPUTERNAME}" 150 fi 151fi 152 153 154# Check timeout multiplier (increase default check timeout in x times) 155x_check_mult=1 156if test $x_compiler = "MSVC" ; then 157 case "$x_cfg" in 158 Debug* ) 159 x_check_mult=3 160 ;; 161 esac 162fi 163 164 165# Clean up check directory 166(cd "$x_check_dir" && find "$x_check_dir" -maxdepth 1 -mindepth 1 -type d -print | xargs rm -rf) 167 168# Features detection 169fs=`sort -dfu "${x_build_dir}/${x_libdll}/${x_cfg}/features_and_packages.txt" | tr '\r' ' '` 170x_features=" " 171for f in $fs; do 172 x_features="$x_features$f " 173done 174 175 176#////////////////////////////////////////////////////////////////////////// 177 178cat > $x_out <<EOF 179#! /bin/bash 180 181root_dir="$x_root_dir" 182build_dir="$x_build_dir" 183check_dir="$x_check_dir" 184src_dir="\$root_dir/src" 185build_tree="$x_libdll" 186build_cfg="$x_cfg" 187signature="$signature" 188 189res_script="$x_out" 190res_journal="\$res_script.journal" 191res_log="\$res_script.log" 192res_list="\$res_script.list" 193res_concat="\$res_script.out" 194res_concat_err="\$res_script.out_err" 195 196# Define both senses to accommodate shells lacking ! 197is_run=false 198no_run=true 199 200 201# Printout USAGE info and exit 202 203Usage() { 204 cat <<EOF_usage 205 206USAGE: $x_script_name {run | concat | concat_err} 207 208 run Run tests. Create output file ("*.out") for each test, 209 journal and log files. 210 concat Concatenate all output files created during the last "run" 211 into one file "\$res_log". 212 concat_err Like 'concat', but output file "\$res_concat_err" 213 will contains outputs of failed tests only. 214 215ERROR: \$1 216EOF_usage 217 218 exit 1 219} 220 221if test \$# -ne 1 ; then 222 Usage "Invalid number of arguments." 223fi 224 225 226# Action 227 228method="\$1" 229 230case "\$method" in 231#---------------------------------------------------------- 232 run ) 233 is_run=true 234 no_run=false 235 # See RunTest() below 236 ;; 237#---------------------------------------------------------- 238 concat ) 239 rm -f "\$res_concat" 240 ( 241# cat \$res_log 242 test -f \$res_journal || exit 0 243 x_files=\`cat \$res_journal | sed -e 's/ /%gj_s4%/g'\` 244 for x_file in \$x_files; do 245 x_file=\`echo "\$x_file" | sed -e 's/%gj_s4%/ /g'\` 246 echo 247 echo 248 cat \$x_file 249 done 250 ) >> \$res_concat 251 exit 0 252 ;; 253#---------------------------------------------------------- 254 concat_err ) 255 rm -f "\$res_concat_err" 256 ( 257# egrep 'ERR \[|TO -' \$res_log 258 test -f \$res_journal || exit 0 259 x_files=\`cat \$res_journal | sed -e 's/ /%gj_s4%/g'\` 260 for x_file in \$x_files; do 261 x_file=\`echo "\$x_file" | sed -e 's/%gj_s4%/ /g'\` 262 x_code=\`grep -c '@@@ EXIT CODE:' \$x_file\` 263 test \$x_code -ne 0 || continue 264 x_good=\`grep -c '@@@ EXIT CODE: 0' \$x_file\` 265 if test \$x_good -ne 1 ; then 266 echo 267 echo 268 cat \$x_file 269 fi 270 done 271 ) >> \$res_concat_err 272 exit 0 273 ;; 274#---------------------------------------------------------- 275 * ) 276 Usage "Invalid method name \$method." 277 ;; 278esac 279 280 281#////////////////////////////////////////////////////////////////////////// 282 283 284trap "touch \$check_dir/check.failed; exit 1" 1 2 15 285rm \$check_dir/check.failed \$check_dir/check.success > /dev/null 2>&1 286 287# Set log_site for tests 288export NCBI_APPLOG_SITE=testcxx 289 290# Export some global vars 291export top_srcdir="\$root_dir" 292 293# Add current, build and scripts directories to PATH 294export PATH="\${root_dir}/scripts/common/impl:\${root_dir}/scripts/common/check:.:\${build_dir}:\${PATH}" 295 296# Define time-guard script to run tests from other scripts 297export CHECK_EXEC="\${root_dir}/scripts/common/check/check_exec_test.sh" 298export CHECK_EXEC_STDIN="\$CHECK_EXEC -stdin" 299 300# Define signature of the current build to use by test applications 301export CHECK_SIGNATURE="\$signature" 302 303# Enable silent abort for NCBI applications on fatal errors 304export DIAG_SILENT_ABORT="Y" 305 306# Use AppLog-style output format in the testsuite by default 307test -z "\$DIAG_OLD_POST_FORMAT" && export DIAG_OLD_POST_FORMAT=false 308 309# Default check tools 310if test -z "\$NCBI_CHECK_TOOLS"; then 311 NCBI_CHECK_TOOLS="regular" 312fi 313 314# Check timeout multiplier (increase default check timeout in x times) 315if test -z "\$NCBI_CHECK_TIMEOUT_MULT"; then 316 NCBI_CHECK_TIMEOUT_MULT=$x_check_mult 317fi 318 319# Path to test data, used by some scripts and applications 320if test -z "\$NCBI_TEST_DATA"; then 321 case `uname -s` in 322 CYGWIN* ) NCBI_TEST_DATA=//snowman/win-coremake/Scripts/test_data ;; 323 Darwin ) 324 if test -d /am/ncbiapdata/test_data; then 325 NCBI_TEST_DATA=/am/ncbiapdata/test_data 326 else 327 NCBI_TEST_DATA=/Volumes/ncbiapdata/test_data 328 fi 329 ;; 330 *) NCBI_TEST_DATA=/am/ncbiapdata/test_data ;; 331 esac 332 export NCBI_TEST_DATA 333fi 334# Add synonym for it, see: include/common/test_data_path.h (CXX-9239) 335if test -z "\$NCBI_TEST_DATA_PATH"; then 336 NCBI_TEST_DATA_PATH=\$NCBI_TEST_DATA 337 export NCBI_TEST_DATA_PATH 338fi 339 340# Disable BOOST tests to catch asynchronous system failures 341# (signals on *NIX platforms or structured exceptions on Windows) 342BOOST_TEST_CATCH_SYSTEM_ERRORS=no 343export BOOST_TEST_CATCH_SYSTEM_ERRORS 344 345BOOST_TEST_COLOR_OUTPUT=no 346export BOOST_TEST_COLOR_OUTPUT 347 348# Check on linkerd and set backup 349echo test | nc -w 1 linkerd 4142 > /dev/null 2>&1 350if test \$? -ne 0; then 351 NCBI_CONFIG__ID2SNP__PTIS_NAME="pool.linkerd-proxy.service.bethesda-dev.consul.ncbi.nlm.nih.gov:4142" 352 export NCBI_CONFIG__ID2SNP__PTIS_NAME 353fi 354 355 356 357#////////////////////////////////////////////////////////////////////////// 358 359# Check for automated build 360is_automated=false 361is_db_load=false 362if test -n "\$NCBI_AUTOMATED_BUILD"; then 363 is_automated=true 364 if test -n "\$NCBI_CHECK_DB_LOAD"; then 365 is_db_load=true 366 fi 367fi 368 369# Check for ncbi_applog 370have_ncbi_applog=false 371if (ncbi_applog generate) >/dev/null 2>&1; then 372 have_ncbi_applog=true 373fi 374 375#////////////////////////////////////////////////////////////////////////// 376 377 378# Run 379 380count_ok=0 381count_err=0 382count_timeout=0 383count_absent=0 384configurations="$x_confs" 385 386if \$is_run; then 387 rm -f "\$res_journal" 388 rm -f "\$res_log" 389fi 390if \$is_db_load; then 391 echo "--------------------------------------------------" >> "\$build_dir/test_stat_load.log" 2>&1 392 echo "Loading tests from: \$check_dir" >> "\$build_dir/test_stat_load.log" 2>&1 393 echo "--------------------------------------------------" >> "\$build_dir/test_stat_load.log" 2>&1 394fi 395 396 397# Run one test 398 399RunTest() { 400 # Parameters 401 x_wdir="\$1" 402 x_test="\$2" 403 x_app="\$3" 404 x_run="\${4:-\$x_app}" 405 x_alias="\$5" 406 x_name="\${5:-\$x_run}" 407 x_ext="\$6" 408 x_timeout="\$7" 409 x_authors="\$8" 410 411 x_work_dir="\$check_dir/\$x_wdir" 412 mkdir -p "\$x_work_dir" > /dev/null 2>&1 413 414 # Determine test application name 415 x_path_run="\$build_dir/\${build_tree}/bin/\$build_cfg" 416 result=1 417 x_path_app="\$x_path_run/\$x_app" 418 if test ! -f "\$x_path_app"; then 419 x_path_app="\$x_path_run/\$x_test" 420 if test ! -f "\$x_path_app"; then 421 result=0 422 fi 423 fi 424 425 # Run test under all specified check tools 426 for tool in \$NCBI_CHECK_TOOLS; do 427 428 saved_phid='' 429 430 tool_lo=\`echo \$tool | tr '[A-Z]' '[a-z]'\` 431 tool_up=\`echo \$tool | tr '[a-z]' '[A-Z]'\` 432 433 case "\$tool_lo" in 434 regular | inspxe ) ;; 435 * ) continue ;; 436 esac 437 if test \$tool_lo = "regular"; then 438 x_cmd="[\$build_tree/\$build_cfg/\$x_wdir] \$x_name" 439 x_test_out="\$x_work_dir/\$x_app.test_out\$x_ext" 440 x_test_rep="\$x_work_dir/\$x_app.test_rep\$x_ext" 441 x_boost_rep="\$x_work_dir/\$x_app.boost_rep\$x_ext" 442 else 443 x_cmd="[\$build_tree/\$build_cfg/\$x_wdir] \$tool_up \$x_name" 444 x_test_out="\$x_work_dir/\$x_app.test_out\$x_ext.\$tool_lo" 445 x_test_rep="\$x_work_dir/\$x_app.test_rep\$x_ext.\$tool_lo" 446 x_boost_rep="\$x_work_dir/\$x_app.boost_rep\$x_ext.\$tool_lo" 447 fi 448 449 if \$is_run && \$is_automated; then 450 echo "\$signature" >> "\$x_test_rep" 451 echo "\$x_wdir" >> "\$x_test_rep" 452 echo "\$x_run" >> "\$x_test_rep" 453 echo "\$x_alias" >> "\$x_test_rep" 454 case "$x_compiler" in 455 MSVC ) 456 export NCBI_BOOST_REPORT_FILE="\$(cygpath -w "\$x_boost_rep")" 457 ;; 458 XCODE ) 459 export NCBI_BOOST_REPORT_FILE="\$x_boost_rep" 460 ;; 461 esac 462 fi 463 464 # Check existence of the test application 465 if test \$result -eq 1; then 466 467 # Goto the work directory 468 cd "\$x_work_dir" 469 470 # Fix empty parameters (replace "" to \"\", '' to \'\') 471 x_run_fix=\`echo "\$x_run" | sed -e 's/""/\\\\\\\\\\"\\\\\\\\\\"/g' -e "s/''/\\\\\\\\\\'\\\\\\\\\\'/g"\` 472 # Fix empty parameters (put each in '' or "") 473 x_run_fix=\`echo "\$x_run" | sed -e 's/""/'"'&'/g" -e "s/''/\\\\'\\\\'/g"\` 474 475 # Define check tool variables 476 case "\$tool_lo" in 477 regular ) ;; 478 inspxe ) NCBI_CHECK_TOOL="inspxe.sh" 479 NCBI_CHECK_TIMEOUT_MULT=20 480 ;; 481 esac 482 export NCBI_CHECK_TOOL 483 CHECK_TIMEOUT=\`expr \$x_timeout \* \$NCBI_CHECK_TIMEOUT_MULT\` 484 export CHECK_TIMEOUT 485 486 echo \$x_run | grep '\.sh' > /dev/null 2>&1 487 if test \$? -eq 0; then 488 # Run script without any check tools. 489 # It will be applied inside script using \$CHECK_EXEC. 490 xx_run="\$x_run_fix" 491 else 492 # Run under check tool 493 xx_run="\$NCBI_CHECK_TOOL \$x_run_fix" 494 fi 495 496 # Write header to output file 497 echo "\$x_test_out" >> \$res_journal 498 ( 499 echo "======================================================================" 500 echo "\$build_tree/\$build_cfg - \$x_name" 501 echo "======================================================================" 502 echo 503 if test "\$x_run" != "\$x_name"; then 504 echo "Command line: \$x_run" 505 echo 506 fi 507 if test -n "\$NCBI_CHECK_ENV_SETTINGS"; then 508 echo "NCBI_CHECK_ENV_SETTINGS:" 509 for env in \$NCBI_CHECK_ENV_SETTINGS; do 510 echo " \$env = \`eval echo '$'\$env\`" 511 done 512 echo 513 fi 514 ) > \$x_test_out 2>&1 515 516 517 # Run check 518 519 rm -f check_exec.pid > /dev/null 2>&1 520 start_time="\`date +'$x_date_format'\`" 521 check_exec="\$root_dir/scripts/common/check/check_exec.sh" 522 523 # Generate PHID and SID for a new test 524 logfile=\$NCBI_CONFIG__LOG__FILE 525 NCBI_CONFIG__LOG__FILE= 526 export NCBI_CONFIG__LOG__FILE 527 if \$have_ncbi_applog; then 528 eval "\`ncbi_applog generate -phid -sid -format=shell-export | tr -d '\r'\`" 529 if \$is_run && \$is_db_load; then 530 # Use generated PHID for test statistics, and sub-PHID.1 for test itself 531 saved_phid=\$NCBI_LOG_HIT_ID 532 NCBI_LOG_HIT_ID=\$NCBI_LOG_HIT_ID.1 533 export NCBI_LOG_HIT_ID 534 # Create a file in the cirrent directory with initial sub-PHID 535 # (will be incremented by $CHECK_EXEC, if any) 536 echo "0" > \$NCBI_LOG_HIT_ID 537 fi 538 fi 539 NCBI_CONFIG__LOG__FILE=\$logfile 540 export NCBI_CONFIG__LOG__FILE 541 542 \$check_exec $x_time \`eval echo \$xx_run\` > \$x_test_out.\$\$ 2>&1 543 result=\$? 544 stop_time="\`date +'$x_date_format'\`" 545 if \${have_uptime}; then 546 load_avg="\`uptime | sed -e 's/.*averages*: *\(.*\) *$/\1/' -e 's/[, ][, ]*/ /g'\`" 547 else 548 load_avg="unavailable" 549 fi 550 sed -e '/ ["][$][@]["].*\$/ { 551 s/^.*: // 552 s/ ["][$][@]["].*$// 553 }' \$x_test_out.\$\$ >> \$x_test_out 554 555 # Compute RunID 556 runpid='?' 557 test -f check_exec.pid && runpid="\`cat check_exec.pid\`" 558 runid="\`date -u +%y%m%d%H%M%S\`-\$runpid-\`uname -n\`" 559 runid="\`echo \$runid | tr -d '\n\r'\`" 560 rm -f check_exec.pid > /dev/null 2>&1 561 562 # Get application execution time 563 exec_time=\`tail -3 \$x_test_out.\$\$\` 564 exec_time=\`echo "\$exec_time" | tr '\n\r' '%%'\` 565 echo \$exec_time | grep 'real [0-9]\|Maximum execution .* is exceeded' > /dev/null 2>&1 566 if test \$? -eq 0; then 567 exec_time=\`echo \$exec_time | sed -e 's/^%*//' -e 's/%*$//' -e 's/%%/%/g' -e 's/%/, /g' -e 's/[ ] */ /g'\` 568 else 569 exec_time='unparsable timing stats' 570 fi 571 rm -f $x_tmp/\$\$.out 572 rm -f \$x_test_out.\$\$ 573 574 # Write result of the test into the his output file 575 echo "Start time : \$start_time" >> \$x_test_out 576 echo "Stop time : \$stop_time" >> \$x_test_out 577 echo "Load averages: \$load_avg" >> \$x_test_out 578 echo >> \$x_test_out 579 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" >> \$x_test_out 580 echo "@@@ EXIT CODE: \$result" >> \$x_test_out 581 582 # And write result also on the screen and into the log 583 if grep -q NCBI_UNITTEST_DISABLED \$x_test_out >/dev/null; then 584 echo "DIS -- \$x_cmd" 585 echo "DIS -- \$x_cmd" >> \$res_log 586 count_absent=\`expr \$count_absent + 1\` 587 \$is_automated && echo "DIS" >> "\$x_test_rep" 588 589 elif grep NCBI_UNITTEST_SKIPPED \$x_test_out >/dev/null; then 590 echo "SKP -- \$x_cmd" 591 echo "SKP -- \$x_cmd" >> \$res_log 592 count_absent=\`expr \$count_absent + 1\` 593 \$is_automated && echo "SKP" >> "\$x_test_rep" 594 595 elif grep NCBI_UNITTEST_TIMEOUTS_BUT_NO_ERRORS \$x_test_out >/dev/null; then 596 echo "TO -- \$x_cmd" 597 echo "TO -- \$x_cmd" >> \$res_log 598 count_timeout=\`expr \$count_timeout + 1\` 599 \$is_automated && echo "TO" >> "\$x_test_rep" 600 601 elif egrep "Maximum execution .* is exceeded" \$x_test_out >/dev/null; then 602 echo "TO -- \$x_cmd (\$exec_time)" 603 echo "TO -- \$x_cmd (\$exec_time)" >> \$res_log 604 count_timeout=\`expr \$count_timeout + 1\` 605 \$is_automated && echo "TO" >> "\$x_test_rep" 606 607 elif test \$result -eq 0; then 608 echo "OK -- \$x_cmd (\$exec_time)" 609 echo "OK -- \$x_cmd (\$exec_time)" >> \$res_log 610 count_ok=\`expr \$count_ok + 1\` 611 \$is_automated && echo "OK" >> "\$x_test_rep" 612 613 else 614 echo "ERR [\$result] -- \$x_cmd (\$exec_time)" 615 echo "ERR [\$result] -- \$x_cmd (\$exec_time)" >> \$res_log 616 count_err=\`expr \$count_err + 1\` 617 \$is_automated && echo "ERR" >> "\$x_test_rep" 618 fi 619 620 if \$is_automated; then 621 echo "\$start_time" >> "\$x_test_rep" 622 echo "\$result" >> "\$x_test_rep" 623 echo "\$exec_time" >> "\$x_test_rep" 624 echo "\$x_authors" >> "\$x_test_rep" 625 echo "\$load_avg" >> "\$x_test_rep" 626 echo "\$runid" >> "\$x_test_rep" 627 fi 628 629 else # Run test if it exist 630 if \$is_run; then 631 # Test application is absent 632 echo "ABS -- \$x_cmd - \$x_test" 633 echo "ABS -- \$x_cmd - \$x_test" >> \$res_log 634 count_absent=\`expr \$count_absent + 1\` 635 if \$is_automated; then 636 echo "ABS" >> "\$x_test_rep" 637 echo "\`date +'$x_date_format'\`" >> "\$x_test_rep" 638 fi 639 fi 640 fi 641 642 # Load test results to Database and Applog immediately after a test. 643 # Always load test results for automated builds on a 'run' command. 644 645 if \$is_run && \$is_db_load; then 646 echo "\$x_path_app:" >> "\$build_dir/test_stat_load.log" 2>&1 647 if test -n "\$saved_phid"; then 648 NCBI_LOG_HIT_ID=\$saved_phid 649 export NCBI_LOG_HIT_ID 650 fi 651 case "$x_compiler" in 652 MSVC ) 653 test_stat_load "\$(cygpath -w "\$x_test_rep")" "\$(cygpath -w "\$x_test_out")" "\$(cygpath -w "\$x_boost_rep")" "\$(cygpath -w "\$top_srcdir/build_info")" >> "\$build_dir/test_stat_load.log" 2>&1 654 ;; 655 XCODE ) 656 $NCBI/bin/_production/CPPCORE/test_stat_load "\$x_test_rep" "\$x_test_out" "\$x_boost_rep" "\$top_srcdir/build_info" >> "\$build_dir/test_stat_load.log" 2>&1 657 ;; 658 esac 659 echo >> "\$build_dir/test_stat_load.log" 2>&1 660 fi 661 if test \$is_run -a -n "\$saved_phid"; then 662 rm -f \$saved_phid* > /dev/null 2>&1 663 fi 664 665 done # Run test under all specified check tools 666} 667 668 669# Save value of PATH environment variable 670saved_path="\$PATH" 671 672# Features detection 673FEATURES="$x_features" 674export FEATURES 675 676# Redirect output for C++ diagnostic framework to stderr, 677# except if using under 'export_project' tool. 678if test -z "\$NCBI_EXPORT_PROJECT"; then 679 NCBI_CONFIG__LOG__FILE="-" 680 export NCBI_CONFIG__LOG__FILE 681fi 682 683# Export bin and lib paths 684export CFG_BIN="\${build_dir}/\${build_tree}/bin/\${build_cfg}" 685export CFG_LIB="\${build_dir}/\${build_tree}/lib/\${build_cfg}" 686 687# Add current configuration's build 'bin' and 'lib' directories to PATH 688export PATH=".:\${CFG_BIN}:\${CFG_LIB}:\${saved_path}" 689 690 691EOF 692 693#////////////////////////////////////////////////////////////////////////// 694 695 696# Read list with tests and write commands to script file. 697# Also copy necessary files to the test build directory. 698 699 700# Read list with tests 701x_tests=`cat "$x_list" | sed -e 's/ /%gj_s4%/g'` 702x_test_prev="" 703 704# For all tests 705for x_row in $x_tests; do 706 # Get one row from list 707 x_row=`echo "$x_row" | sed -e 's/%gj_s4%/ /g' -e 's/^ *//' -e 's/ ____ /~/g'` 708 709 # Split it to parts 710 x_rel_dir=`echo \$x_row | sed -e 's/~.*$//'` 711 x_src_dir="$x_root_dir/src/$x_rel_dir" 712 x_test=`echo "$x_row" | sed -e 's/^[^~]*~//' -e 's/~.*$//'` 713 x_app=`echo "$x_row" | sed -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/~.*$//'` 714 x_cmd=`echo "$x_row" | sed -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/~.*$//' -e 's/\"/\\\\"/g'` 715 x_name=`echo "$x_row" | sed -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/~.*$//'` 716 x_files=`echo "$x_row" | sed -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/~.*$//'` 717 x_timeout=`echo "$x_row" | sed -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/~.*$//'` 718 ###x_requires=`echo "$x_row" | sed -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/^[^~]*~//' -e 's/~.*$//'` 719 x_authors=`echo "$x_row" | sed -e 's/.*~//'` 720 721 # Default timeout 722 test -z "$x_timeout" && x_timeout=$NCBI_CHECK_TIMEOUT_DEFAULT 723 724 # Check application requirements 725 # TODO: 726 # This check can be removed later, when project_tree_builder starts to check requiments 727 # on check list generation step. 728 ###for x_req in $x_requires; do 729 ### (echo "$x_features" | grep " $x_req " > /dev/null) || continue 2 730 ###done 731 732 # Copy specified files into the check tree 733 if test ! -z "$x_files" ; then 734 x_path="$x_check_dir/$x_rel_dir" 735 mkdir -p "$x_path" 736 # Automatically copy .ini file if exists 737 x_copy="$x_src_dir/$x_app.ini" 738 test -f $x_copy && cp -f "$x_copy" "$x_path" 739 # Copy specified CHECK_COPY files/dirs 740 for i in $x_files ; do 741 x_copy="$x_src_dir/$i" 742 if test -f "$x_copy" -o -d "$x_copy" ; then 743 if $is_msvc; then 744 # Do not preserve permissions, it is not always possible for NTFS 745 cp -rf "$x_copy" "$x_path" 746 else 747 cp -prf "$x_copy" "$x_path" 748 fi 749 find "$x_path/$i" -name .svn -print 2> /dev/null | xargs rm -rf 750 else 751 echo "Warning: \"$x_copy\" must be file or directory!" 752 fi 753 done 754 fi 755 756 # Generate extension for tests output file 757 if test "$x_test" != "$x_test_prev" ; then 758 x_cnt=1 759 x_test_ext="" 760 else 761 x_cnt=`expr $x_cnt + 1` 762 x_test_ext="$x_cnt" 763 fi 764 x_test_prev="$x_test" 765 766 # Write current test commands into a script file 767 cat >> $x_out <<EOF 768###################################################################### 769RunTest "$x_rel_dir" \\ 770 "$x_test" \\ 771 "$x_app" \\ 772 "$x_cmd" \\ 773 "$x_name" \\ 774 "$x_test_ext" \\ 775 "$x_timeout" \\ 776 "$x_authors" 777EOF 778 779#////////////////////////////////////////////////////////////////////////// 780 781done # for x_row in x_tests 782 783 784# Write ending code into the script 785cat >> $x_out <<EOF 786###################################################################### 787 788 789# Restore saved PATH environment variable 790PATH="\$saved_path" 791 792# Write result of the tests execution 793if \$is_run; then 794 echo 795 echo "Succeeded : \$count_ok" 796 echo "Timeout : \$count_timeout" 797 echo "Failed : \$count_err" 798 echo "Absent : \$count_absent" 799 echo 800fi 801 802if test \$count_err -eq 0; then 803 touch \$check_dir/check.success 804else 805 touch \$check_dir/check.failed 806fi 807 808exit \$count_err 809EOF 810 811# Set execute mode to script 812chmod a+x "$x_out" 813 814exit 0 815