1#!/bin/bash 2# 3# @echo off 4# 5# Run specified set of test cases in all enabled modes 6# 7# DESCRIPTION: 8# 9# 1. A set of test cases to be run is manually 10# specified in INIT_SET_OF_TEST_CASES() routine 11# 12# 2. Modes of runs to be executed are manually 13# specified by non-zero variables: 14# ENABLEOPT32 - 32-bit optimized code 15# ENABLEOPT64 - 64-bit optimized code 16# ENABLENORM32 - 32-bit unoptimized code 17# ENABLENORM64 - 64-bit unoptimized code 18# 19# 3. You can exclude log out to RESULTS directory 20# by setting to zero the variable: 21# ENABLELOG 22# 23# External definitions required: 24# 25# acpiexec - AcpiExec utility 26# ASLTSDIR - the pathname of root directory of aslts test suite 27# 28# Concepts: 29# 30# bitmap of mode - 31# 0-th bit - [0 - 32-bit, 1 - 64-bit] 32# 1-th bit - [0 - nopt, 1 - opt] 33# 34# See comment of Do utility for more information. 35 36# Includes 37 38. common 39. settings 40. diffproc 41 42 43# Store message to the common multi-result log file 44# arg1 - message 45multi_log() 46{ 47 if [ -f "$COMMONLOGFILE" ]; then 48 echo "$1" >> "$COMMONLOGFILE" 49 else 50 echo "$1" 51 fi 52} 53 54# Convert {h:m:s:cs} string to centisecond time units 55# [arg1-arg4] - centisecond time string {h:m:s:cs} 56cent_str_to_cent_units() 57{ 58 local rval 59 60 # Note: '1' before arguments (hours - exception took place) 61 # added to mask first '0' in cases '08' and '09' 62 63 eval "rval=$[ (((1$1 - 100) * 60 + (1$2 - 100)) * 60 + (1$3 - 100)) * 100 + (1$4 - 100) ]" 64 echo "$rval" 65} 66export -f cent_str_to_cent_units 67 68# Convert {h:m:s} string to centisecond time units 69# arg1 - time string {h:m:s} 70sec_str_to_cent_units() 71{ 72 local rval hmscS=$1:00 _ifs="$IFS" 73 74 IFS=: 75 rval=`cent_str_to_cent_units $hmscS` 76 IFS="$_ifs" 77 78 echo "$rval" 79} 80export -f sec_str_to_cent_units 81 82# Return the length of time period in centisecond time units 83# Note: assumed the total running time is less than 24 hours 84# arg1 - start time in centisecond time units 85# arg2 - finish time in centisecond time units 86get_cent_units_diff() 87{ 88 local rval 89 local hmscU=$2 90 91 # Check crossing 24-hour boundary 92 93 if [ $hmscU -lt $1 ]; then 94 hmscU=$[ $hmscU + 8640000 ] 95 fi 96 97 eval "rval=$[ $hmscU - $1 ]" 98 99 echo "$rval" 100} 101export -f get_cent_units_diff 102 103# Calculate and return the length of time period as string {[h:]m:s.c} 104# arg1 - start time string {h:m:s} 105# arg2 - finish time string {h:m:s} 106get_cent_str_diff() 107{ 108 local rval 109 110 RAW_INITIME=`sec_str_to_cent_units $1` 111 RAW_ENDTIME=`sec_str_to_cent_units $2` 112 RAW_RUNTIME=`get_cent_units_diff $RAW_INITIME $RAW_ENDTIME` 113 rval=`cent_units_to_cent_str $RAW_RUNTIME` 114 115 echo "$rval" 116} 117export -f get_cent_str_diff 118 119# Get version of AcpiExec 120get_acpiexec_version() 121{ 122 local x version 123 124 x=`"$acpiexec" -bex,MAIN | grep "Utility version"` 125 if [ x"$x" == x ]; then 126 version=00000000 127 else 128 version=`echo "$x" | awk -F" " '{print $5}'` 129 fi 130 131 echo $version 132} 133 134# Get the patname of AML code of test case 135# arg1 - the name of test case 136# arg2 - bitmap of mode 137get_aml_code_path() 138{ 139 local BITMODE=`get_mode_string $2 2` 140 local OPTMODE=`get_mode_string $2 3` 141 142 path="$ASLTSDIR/tmp/aml/$EXECVERSION/$OPTMODE/$BITMODE/$1.aml" 143 echo "$path" 144} 145export -f get_aml_code_path 146 147# Run particular test case 148# arg1 - the name of test case 149# arg2 - bitmap of mode 150run_test_case() 151{ 152 local amlcodepath tcase=$1 modepart modename BITMODE 153 local options method commandline 154 155 156 modepart=`get_mode_string $2 0` 157 modename=`get_mode_string $2 1` 158 BITMODE=`get_mode_string $2 2` 159 OPTMODE=`get_mode_string $2 3` 160 161 TEST_TITLE="$tcase $modename" 162 163 amlcodepath=`get_aml_code_path $1 $2` 164 if [ ! -f "$amlcodepath" ]; then 165 echo "Test doesn't exist: $amlcodepath" 166 AML_DONT_EXIST=$[ $AML_DONT_EXIST + 1 ] 167 return 168 fi 169 170 # Start time 171 172 FMT_INITIME=$(date +%T) 173 174 # Initial message 175 176 echo "ASLTS: START, $TEST_TITLE, $FMT_INITIME" 177 178 # Simulate test by acpiexec 179 180 amlcodepath=`get_aml_code_path $tcase $2` 181 182 if [ ! -f "$amlcodepath" ]; then 183 echo "Test doesn't exist: $amlcodepath" 184 AML_DONT_EXIST=$[ $AML_DONT_EXIST + 1 ] 185 TEST_RET=1 186 else 187 options="-ef -el -to 60" 188 method=MN00 189 190 if [ "$DO_MEMSTAT" == "yes" ]; then 191 options="$options -ef" 192 fi 193 194 if [[ "$tcase" == mt_* ]]; then 195 commandline="thr,6,1" 196 else 197 commandline=ex 198 fi 199 200 echo "" 201 echo "acpiexec options to reproduce:" 202 echo " $options -b\"$commandline,$method\"" 203 echo "ASLTS aml tables to reproduce:" 204 echo " $amlcodepath" 205 echo "" 206 207 "$acpiexec" $options -b"$commandline,$method" "$amlcodepath" 208 TEST_RET=$? 209 fi 210 211 # Finish time 212 213 FMT_ENDTIME=$(date +%T) 214 215 # Calculate the run time 216 217 FMT_RUNTIME=`get_cent_str_diff $FMT_INITIME $FMT_ENDTIME` 218 219 # Report the status message 220 221 if [ $TEST_RET != 0 ]; then 222 echo "ASLTS: FINISH, $TEST_TITLE, FAIL, $FMT_ENDTIME ($FMT_RUNTIME)" 223 UTILSTATUS=1 224 else 225 echo "ASLTS: FINISH, $TEST_TITLE, SUCCESS, $FMT_ENDTIME ($FMT_RUNTIME)" 226 fi 227 228 return $TEST_RET 229} 230export -f run_test_case 231 232# Run a set of test cases (specified by INIT_SET_OF_TEST_CASES) 233# in one particular mode. 234# arg1 - bitmap of mode 235# arg2 - multi-result directory 236# arg3 - a list of test cases to be run 237run_set_of_test_cases() 238{ 239 local x y z q status=0 total modepart modename tcase amlcodepath 240 test_case_arr=($3) 241 res_dir=$2 242 bit_mode=$1 243 procs=`nproc --all` 244 245 modepart=`get_mode_string $1 0` 246 modename=`get_mode_string $1 1` 247 248 x=$(date +%F) 249 y=$(date +%T) 250 251 multi_log "$modename started $x $y" 252 253 total="$x $y" 254 255 # Explanation of command below: 256 # For each testcase that we will run, we are going to parallelize the 257 # execution with the number of available processors. 258 printf '%s\n' "${test_case_arr[@]}" |\ 259 xargs -n 1 -P $procs -I {} bash -c 'run_test_case $1 $2 > $3/$4/$1'\ 260 _ {} $bit_mode $res_dir $modepart 261 262 z=$(date +%T) 263 q=`get_cent_str_diff $y $z` 264 265 x="$(date +%F)" 266 multi_log "$modename finished $x $z, ($q)" 267 268 total="$modename, $total, $x $z ($q)" 269 270 MODES_SUMMARIES[$1]="$total" 271 272 MODES_TIMES[$1]="$q" 273} 274 275# Get the date-time-like name (used 276# as a multi-result directory name) 277# arg1 - time string {h:m:s} 278# arg2 - date string {y-m-d} 279get_date_time_like_name() 280{ 281 local x y rval 282 283 x=`echo $1 | sed 's/-//g'` 284 y=`echo $2 | sed 's/://g'` 285 rval="$x.$y.$EXECVERSION" 286 287 echo "$rval" 288} 289 290# Check-make multi-result directory 291# arg1 - multi-result directory name 292make_multi_result_dir() 293{ 294 local srcdir=`pwd` path 295 296 cd "$ASLTSDIR" 297 298 make_dir "./tmp" tmp tmp 299 300 cd "./tmp" 301 302 make_dir "./RESULTS" RESULTS RESULTS 303 304 cd "./RESULTS" 305 306 make_dir "./$1" "$1" "RESULTS/$1" 307 308 cd "./$1" 309 310 if [ $ENABLENORM32 != 0 -o $ENABLENORM64 != 0 ]; then 311 path="RESULTS/$1/nopt" 312 make_dir "./nopt" nopt "$path" 313 cd "./nopt" 314 if [ $ENABLENORM32 != 0 ]; then 315 make_dir "./32" 32 "$path/32" 316 fi 317 if [ $ENABLENORM64 != 0 ]; then 318 make_dir "./64" 64 "$path/64" 319 fi 320 321 cd ".." 322 fi 323 324 if [ $ENABLEOPT32 != 0 -o $ENABLEOPT64 != 0 ]; then 325 path="RESULTS/$1/opt" 326 make_dir "./opt" opt "$path" 327 cd "./opt" 328 if [ $ENABLEOPT32 != 0 ]; then 329 make_dir "./32" 32 "$path/32" 330 fi 331 if [ $ENABLEOPT64 != 0 ]; then 332 make_dir "./64" 64 "$path/64" 333 fi 334 fi 335 336 cd "$srcdir" 337} 338 339# Report to multi-log all the specified modes 340# the tests to be run in. 341report_specified_modes() 342{ 343 local flag=0 x=" " 344 345 multi_log "Modes specified for running:" 346 multi_log "" 347 348 if [ $ENABLENORM32 != 0 ]; then 349 multi_log "${x}`get_mode_string $NORM32 1`" 350 flag=1 351 fi 352 if [ $ENABLENORM64 != 0 ]; then 353 multi_log "${x}`get_mode_string $NORM64 1`" 354 flag=1 355 fi 356 if [ $ENABLEOPT32 != 0 ]; then 357 multi_log "${x}`get_mode_string $OPT32 1`" 358 flag=1 359 fi 360 if [ $ENABLEOPT64 != 0 ]; then 361 multi_log "${x}`get_mode_string $OPT64 1`" 362 flag=1 363 fi 364 365 if [ $flag == 0 ]; then 366 multi_log "${x}No any run mode" 367 fi 368} 369 370# Report all status lines encountered in the test case 371# run log file and count and report the summary status 372# line of the test case. 373# arg1 - resulting log file of particular test case run 374# arg2 - the name of test case 375# arg3 - file where to store summary information 376do_summary_of_test_case() 377{ 378 local status cnt=0 pass=0 fail=0 skip=0 start=0 finish=0 total=0 379 local outstand0=0 blck=0 outstand1=0 380 local memcnt=0 memtotal=0 381 local max0=0 max1=0 max2=0 max3=0 max4=0 max5=0 382 local out0=0 out1=0 out2=0 out3=0 out4=0 out5=0 383 local LargeRefCount=0 384 local x=0 exceptionsnum=0 385 local trimmedLine 386 387 OLD_IFS=$IFS 388 IFS=" " 389 cat "$1" |\ 390 while [ 1 ] 391 do 392 read line 393 if [ $? -ne 0 ] ; then 394 echo "|$2|$cnt|$pass|$fail|$skip|$start|$finish|$total|$outstand0|$blck|$memtotal|$max0|$max1|$max2|$max3|$max4|$max5|$out0|$out1|$out2|$out3|$out4|$out5|$outstand1|$LargeRefCount|$exceptionsnum|" >> "$3" 395 break 396 fi 397 if [[ "$line" == *STST* ]]; then 398 echo "$line" 399 cnt=$[ $cnt + 1 ] 400 trimmedLine=`echo "$line" | awk -F"STST:" '{print $2}'` 401 status=`echo "$trimmedLine" | awk -F: '{print $4}'` 402 if [ "$status" == PASS ]; then 403 pass=$[ $pass + 1 ] 404 elif [ "$status" == FAIL ]; then 405 fail=$[ $fail + 1 ] 406 elif [ "$status" == BLOCKED ]; then 407 blck=$[ $blck + 1 ] 408 elif [ "$status" == SKIPPED ]; then 409 skip=$[ $skip + 1 ] 410 fi 411 elif [[ "$line" == "ASLTS:"* ]]; then 412 if [[ "$line" == *START* ]]; then 413 start=`echo "$line" | awk -F" " '{print $7}'` 414 elif [[ "$line" == *FINISH* ]]; then 415 finish=`echo "$line" | awk -F" " '{print $8}'` 416 total=`echo "$line" | awk -F" " '{print $9}'` 417 fi 418 elif [[ "$line" == *"Mem:"* ]]; then 419 if [ $memcnt == 0 ]; then 420 memtotal=`echo "$line" | awk -F" " '{print $13}'` 421 memtotal=$[ 0 + 0x$memtotal ] 422 max0=`echo "$line" | awk -F" " '{print $10}'` 423 out0=`echo "$line" | awk -F" " '{print $12}'` 424 max0=$[ 0 + 0x$max0 ] 425 out0=$[ 0 + 0x$out0 ] 426 elif [ $memcnt == 1 ]; then 427 max1=`echo "$line" | awk -F" " '{print $9}'` 428 out1=`echo "$line" | awk -F" " '{print $11}'` 429 max1=$[ 0 + 0x$max1 ] 430 out1=$[ 0 + 0x$out1 ] 431 elif [ $memcnt == 2 ]; then 432 max2=`echo "$line" | awk -F" " '{print $9}'` 433 out2=`echo "$line" | awk -F" " '{print $11}'` 434 max2=$[ 0 + 0x$max2 ] 435 out2=$[ 0 + 0x$out2 ] 436 elif [ $memcnt == 3 ]; then 437 max3=`echo "$line" | awk -F" " '{print $9}'` 438 out3=`echo "$line" | awk -F" " '{print $11}'` 439 max3=$[ 0 + 0x$max3 ] 440 out3=$[ 0 + 0x$out3 ] 441 elif [ $memcnt == 4 ]; then 442 max4=`echo "$line" | awk -F" " '{print $9}'` 443 out4=`echo "$line" | awk -F" " '{print $11}'` 444 max4=$[ 0 + 0x$max4 ] 445 out4=$[ 0 + 0x$out4 ] 446 elif [ $memcnt == 5 ]; then 447 max5=`echo "$line" | awk -F" " '{print $9}'` 448 out5=`echo "$line" | awk -F" " '{print $11}'` 449 max5=$[ 0 + 0x$max5 ] 450 out5=$[ 0 + 0x$out5 ] 451 fi 452 memcnt=$[ $memcnt + 1 ] 453 elif [[ "$line" == *"Outstanding cache allocations"* ]]; then 454 trimmedLine=`echo "$line" | awk -F" Outstanding cache allocations" '{printf $1}'` 455 outstand1=`echo "$trimmedLine" | awk -F" " '{print $3}'` 456 elif [[ "$line" == *"The total number of exceptions handled"* ]]; then 457 exceptionsnum=`echo "$line" | sed 's/^\[.*\]//g' | awk -F" " '{print $7}'` 458 x=`echo $exceptionsnum | sed 's/"//g'` 459 exceptionsnum=$[ 0 + $x ] 460 elif [[ "$s3" == Large ]]; then 461 if [[ "$line" == "Reference Count"* ]]; then 462 LargeRefCount=$[ $LargeRefCount + 1 ] 463 fi 464 fi 465 done 466 467 IFS=$OLD_IFS 468} 469 470# Report the status lines and summary information 471# for one particular mode of run for each test case 472# specified for running which have the test case run 473# log file located in the given directory. 474# arg1 - directory containing the test case run log files 475# corresponding to one particular mode of run 476# arg2 - a list of test cases the logs of which to be processed 477# arg3 - file where to store summary information 478do_summary_of_mode() 479{ 480 local path 481 482 for filename in $2 483 do 484 path="$1/$filename" 485 if [ -f "$path" ]; then 486 do_summary_of_test_case "$path" "$filename" "$3" 487 fi 488 done 489} 490 491# Prepare all summary information per each test case 492# specified by INIT_SET_OF_TEST_CASES for all the specified 493# modes of runs. 494# arg1 - multi-result directory pathname 495# arg2 - a list of test cases the logs of which to be processed 496do_all_summary() 497{ 498 local path summ 499 500 ls "$1" |\ 501 while [ 1 ] 502 do 503 read filename 504 if [ $? -ne 0 ] ; then 505 break 506 fi 507 508 if [ "$filename" == nopt -o "$filename" == opt ]; then 509 path="$1/$filename" 510 if [ -d "$path/32" ]; then 511 summ="$path/32/__STATUS_OF_TEST_CASES" 512 echo -n "" > "$summ" 513 do_summary_of_mode "$path/32" "$2" "$summ" > "$path/32/__STATUS_OF_TESTS" 514 fi 515 if [ -d "$path/64" ]; then 516 summ="$path/64/__STATUS_OF_TEST_CASES" 517 echo -n "" > "$summ" 518 do_summary_of_mode "$path/64" "$2" "$summ" > "$path/64/__STATUS_OF_TESTS" 519 fi 520 fi 521 done 522} 523 524# Report summary information corresponding 525# to the given mode of run. 526# arg1 - ':' separated total information 527# corresponding to the given mode of run 528# returned by parse_status_of_test_cases() 529# arg2 - summary information corresponding 530# to the given mode of run 531report_total_of_mode() 532{ 533 local x y num memtotal 534 535 multi_log "TOTAL: ($2)" 536 537 x=`echo "$1" | awk -F: '{print $4}'` 538 multi_log " PASS : $x" 539 540 x=`echo "$1" | awk -F: '{print $5}'` 541 multi_log " FAIL : $x" 542 543 x=`echo "$1" | awk -F: '{print $12}'` 544 multi_log " BLOCKED : $x" 545 546 x=`echo "$1" | awk -F: '{print $6}'` 547 multi_log " SKIPPED : $x" 548 549 x=`echo "$1" | awk -F: '{print $3}'` 550 multi_log " Tests : $x" 551 552 get_num_of_available_test_cases 553 num=$? 554 555 x=`echo "$1" | awk -F: '{print $2}'` 556 multi_log " Test Cases : $x (of $num)" 557 558 NUM_DISABLED_BRANCHES=`echo "$1" | awk -F: '{print $7}'` 559 560 x=`echo "$1" | awk -F: '{print $8}'` 561 y=`echo "$1" | awk -F: '{print $9}'` 562 563 multi_log " Test Collections : $x (of $RUNTIME_COLLS_NUM), $y" 564 565 x=`echo "$1" | awk -F: '{print $11}'` 566 multi_log " Outstanding allocations after execution : $x" 567 568 x=`echo "$1" | awk -F: '{print $14}'` 569 multi_log " Outstanding allocations (ACPI Error) : $x" 570 571 x=`echo "$1" | awk -F: '{print $15}'` 572 multi_log " Large Reference Count (ACPI Error) : $x" 573 574 memtotal=`echo "$1" | awk -F: '{print $13}'` 575 multi_log " Memory consumption total : $memtotal Kb" 576} 577 578# Report the status of particular test case 579# and summarize the particular entries of the 580# test cases status lines. 581# arg1 - status line of one particular test case 582report_test_case_summary() 583{ 584 local x y z q l m n o p b u 585 local max0=0 max1=0 max2=0 max3=0 max4=0 max5=0 586 local out0=0 out1=0 out2=0 out3=0 out4=0 out5=0 587 local memtotal=0 588 local outstand1=0 589 local LargeRefCount=0 590 591 x=`echo "$1" | awk -F"|" '{print $2}'` 592 y=`echo "$1" | awk -F"|" '{print $7}'` 593 z=`echo "$1" | awk -F"|" '{print $8}'` 594 q=`echo "$1" | awk -F"|" '{print $9}'` 595 596 l=`echo "$1" | awk -F"|" '{print $4}'` 597 m=`echo "$1" | awk -F"|" '{print $5}'` 598 n=`echo "$1" | awk -F"|" '{print $6}'` 599 o=`echo "$1" | awk -F"|" '{print $3}'` 600 p=`echo "$1" | awk -F"|" '{print $10}'` 601 b=`echo "$1" | awk -F"|" '{print $11}'` 602 603 604 if [ $x == "condbranches" ]; then 605 multi_log "$x: (service-test not counted to TOTAL)" 606 N_DISABLED_BRANCHES="$m" 607 else 608 multi_log "$x:" 609 fi 610 611 multi_log " ($y-$z $q)" 612 multi_log " PASS : $l" 613 multi_log " FAIL : $m" 614 multi_log " BLOCKED : $b" 615 multi_log " SKIPPED : $n" 616 multi_log " total : $o" 617 618 p=$[ 0 + $p ] 619 outstand1=`echo "$1" | awk -F"|" '{print $25}'` 620 621 multi_log " Outstanding allocations after execution : $p" 622 multi_log " Outstanding allocations (ACPI Error) : $outstand1" 623 624 LargeRefCount=`echo "$1" | awk -F"|" '{print $26}'` 625 if [[ "$LargeRefCount" -gt 0 ]]; then 626 multi_log " Large Reference Count (ACPI Error) : $LargeRefCount" 627 fi 628 629 multi_log " Memory statistics (per cache type):" 630 631 memtotal=`echo "$1" | awk -F"|" '{print $12}'` 632 multi_log " Total : $memtotal Kb" 633 634 max0=`echo "$1" | awk -F"|" '{print $13}'` 635 max1=`echo "$1" | awk -F"|" '{print $14}'` 636 max2=`echo "$1" | awk -F"|" '{print $15}'` 637 max3=`echo "$1" | awk -F"|" '{print $16}'` 638 max4=`echo "$1" | awk -F"|" '{print $17}'` 639 max5=`echo "$1" | awk -F"|" '{print $18}'` 640 multi_log " Maximum occupied : $max0(Kb) $max1 $max2 $max3 $max4 $max5" 641 642 out0=`echo "$1" | awk -F"|" '{print $19}'` 643 out1=`echo "$1" | awk -F"|" '{print $20}'` 644 out2=`echo "$1" | awk -F"|" '{print $21}'` 645 out3=`echo "$1" | awk -F"|" '{print $22}'` 646 out4=`echo "$1" | awk -F"|" '{print $23}'` 647 out5=`echo "$1" | awk -F"|" '{print $24}'` 648 multi_log " Outstandings : $out0 $out1 $out2 $out3 $out4 $out5" 649 650 if [ $x != "condbranches" ]; then 651 N_TEST_CASES=$[ $N_TEST_CASES + 1 ] 652 N_PASS=$[ $N_PASS + $l ] 653 N_FAIL=$[ $N_FAIL + $m ] 654 N_SKIP=$[ $N_SKIP + $n ] 655 N_BLCK=$[ $N_BLCK + $b ] 656 N_TESTS=$[ $N_TESTS + $o ] 657 N_OUTSTAND=$[ $N_OUTSTAND + $p ] 658 N_OUTSTAND_1=$[ $N_OUTSTAND_1 + $outstand1 ] 659 N_LARGE_REF_CNT=$[ $N_LARGE_REF_CNT + $LargeRefCount ] 660 N_TOTAL=$[ $N_TOTAL + $memtotal ] 661 fi 662 663 mark_collection_flag "$x" 664} 665 666# Run reporting and summarizing the status lines 667# of test cases present in the given file. 668# arg1 - file containing the status lines of 669# all the test cases have been executed 670# in one particular mode. 671parse_status_of_test_cases() 672{ 673 local x 674 675 cat "$1" |\ 676 while [ 1 ] 677 do 678 read line 679 if [ $? -ne 0 ] ; then 680 x="`get_collections_total`" 681 echo ":$N_TEST_CASES:$N_TESTS:$N_PASS:$N_FAIL:$N_SKIP:$N_DISABLED_BRANCHES:$x:$N_OUTSTAND:$N_BLCK:$N_TOTAL:$N_OUTSTAND_1:$N_LARGE_REF_CNT" 682 break 683 fi 684 if [ -n "$line" ] ; then 685 report_test_case_summary "$line" 686 fi 687 done 688} 689 690# Generalization of summary information 691# prepared for test cases runs for the given 692# mode of run - prepare the convenient view 693# survey in the common multi-result log. 694# arg1 - multi-result directory pathname 695# arg2 - bitmap of mode 696# arg3 - summary information corresponding 697# to the given mode of run 698report_mode_summary() 699{ 700 local x memtotal outstand0 outstand1 LargeRefCount path modepart modename 701 702 modepart=`get_mode_string $2 0` 703 modename=`get_mode_string $2 1` 704 705 path="$1/$modepart/__STATUS_OF_TEST_CASES" 706 707 if [ -f "$path" ]; then 708 709 multi_log "$modename:" 710 multi_log "" 711 712 # Reset test collections involved flags 713 reset_collections_flags 714 715 x=`parse_status_of_test_cases "$path"` 716 717 report_total_of_mode "$x" "$3" 718 719 outstand0=`echo "$x" | awk -F: '{print $11}'` 720 outstand1=`echo "$x" | awk -F: '{print $14}'` 721 LargeRefCount=`echo "$x" | awk -F: '{print $15}'` 722 memtotal=`echo "$x" | awk -F: '{print $13}'` 723 724 if [[ "$LargeRefCount" -gt 0 ]]; then 725 HAVE_LARGE_REF_CNT=yes 726 fi 727 728 echo "|TOTAL|$outstand0|$memtotal|${MODES_TIMES[$2]}|$outstand1|$LargeRefCount|" >> "$path" 729 730 multi_log "" 731 732 else 733 multi_log "$modename: summary information is not present" 734 multi_log "" 735 fi 736} 737 738# Report the test cases specified (by INIT_SET_OF_TEST_CASES) 739# for running. 740# arg1 - a list of test cases to be run 741report_enabled_test_cases() 742{ 743 multi_log "Test cases specified for running:" 744 multi_log "" 745 for name in $1 746 do 747 multi_log " $name" 748 done 749} 750 751# Report comparing results of different mode runs 752# of the same multi-run. 753# arg1 - result of two modes comparing 754# arg2 - first bitmap of mode 755# arg3 - second bitmap of mode 756report_inner_modes_cmp() 757{ 758 local rval=0 759 local modename0 modename1 760 761 modename0=`get_mode_string $2 1` 762 modename1=`get_mode_string $3 1` 763 764 if [ $1 == $CMP_CMP_OP ]; then 765 rval=1 766 multi_log " Compared : <$modename0> and <$modename1>" 767 elif [ $1 == $CMP_MISCMP_OP ]; then 768 rval=1 769 multi_log " Miscompared : <$modename0> and <$modename1>" 770 fi 771 772 return $rval 773} 774 775# Compare results of different mode runs 776# of the same multi-result directory. 777# arg1 - multi-result directory 778do_inner_modes_cmp() 779{ 780 local CMP0 CMP1 CMP2 CMP3 CMP4 CMP5 781 782 # Compare results of different mode runs 783 # and report the summary of comparing. 784 785 multi_log "" 786 multi_log "Compare different mode runs of the same multi-run:" 787 multi_log "" 788 789 do_compare_two_runs "$1" $NORM32 "$1" $OPT32 > /dev/null 790 report_inner_modes_cmp $? $NORM32 $OPT32 791 CMP4=$? 792 do_compare_two_runs "$1" $NORM32 "$1" $NORM64 > /dev/null 793 report_inner_modes_cmp $? $NORM32 $NORM64 794 CMP0=$? 795 do_compare_two_runs "$1" $NORM32 "$1" $OPT64 > /dev/null 796 report_inner_modes_cmp $? $NORM32 $OPT64 797 CMP2=$? 798 do_compare_two_runs "$1" $OPT32 "$1" $NORM64 > /dev/null 799 report_inner_modes_cmp $? $OPT32 $NORM64 800 CMP3=$? 801 do_compare_two_runs "$1" $OPT32 "$1" $OPT64 > /dev/null 802 report_inner_modes_cmp $? $OPT32 $OPT64 803 CMP1=$? 804 do_compare_two_runs "$1" $NORM64 "$1" $OPT64 > /dev/null 805 report_inner_modes_cmp $? $NORM64 $OPT64 806 CMP5=$? 807 808 if [ $CMP0 == 0 -a $CMP1 == 0 -a $CMP2 == 0\ 809 -a $CMP3 == 0 -a $CMP4 == 0 -a $CMP5 == 0 ]; then 810 multi_log " Nothing to compare" 811 fi 812} 813 814# Compare results from two summary files 815# arg1 - summary that this particular test run created 816# arg2 - summary to compare against 817# arg3 - string representing the mode 818compare_summary_of_data() 819{ 820 local mode=$3 821 local result_line delta_data 822 local no_result=no 823 local p1 p2 824 825 result_line=`grep -A 2 -h '^TOTAL: [[:space:]]* ('"$mode" $1` 826 CMP0PASS=`echo "$result_line" | grep 'PASS' | awk -F' ' '{printf $3}'` 827 CMP0FAIL=`echo "$result_line" | grep 'FAIL' | awk -F' ' '{printf $3}'` 828 829 result_line=`grep -A 2 -h '^TOTAL: [[:space:]]* ('"$mode" $2` 830 CMP1PASS=`echo "$result_line" | grep 'PASS' | awk -F' ' '{printf $3}'` 831 CMP1FAIL=`echo "$result_line" | grep 'FAIL' | awk -F' ' '{printf $3}'` 832 833 >&2 echo "==============================================================================" 834 >&2 echo "" 835 >&2 echo " Difference summary of $mode" 836 >&2 echo "" 837 if [ -z $CMP0PASS ]; then 838 >&2 echo " This run did not report any pass numbers for $mode" 839 CMP0PASS=0 840 no_result=yes 841 fi 842 if [ -z $CMP0FAIL ]; then 843 >&2 echo " This run did not report any fail numbers for $mode" 844 CMP0FAIL=0 845 no_result=yes 846 fi 847 if [ -z $CMP1PASS ]; then 848 >&2 echo " The previous run did not report any pass numbers for $mode" 849 CMP1PASS=0 850 no_result=yes 851 fi 852 if [ -z $CMP1FAIL ]; then 853 >&2 echo " The previous run did not report any pass numbers for $mode" 854 CMP1FAIL=0 855 no_result=yes 856 fi 857 if [ no_result = $"no" ]; then 858 >&2 echo "" 859 fi 860 if [ $CMP0PASS -ne $CMP1PASS ] || [ $CMP0FAIL -ne $CMP1FAIL ]; then 861 change_exists=yes 862 >&2 echo " Difference in $mode:" 863 let "delta_data=$CMP0PASS-$CMP1PASS" 864 if [ $delta_data -gt 0 ]; then 865 p1="+" 866 fi 867 >&2 echo " Pass: $p1$delta_data (from $CMP1PASS to $CMP0PASS)" 868 pass_delta=$p1$delta_data 869 let "delta_data=$CMP0FAIL-$CMP1FAIL" 870 if [ $delta_data -gt 0 ]; then 871 p2="+" 872 fi 873 >&2 echo " Fail: $p2$delta_data (from $CMP1FAIL to $CMP0FAIL)" 874 fail_delta=$p2$delta_data 875 else 876 >&2 echo " No pass/fail difference in $mode" 877 >&2 echo " total pass: $CMP0PASS" 878 >&2 echo " total fail: $CMP0FAIL" 879 pass_delta=0 880 fail_delta=0 881 fi 882 >&2 echo "" 883 echo "$pass_delta:$fail_delta" 884} 885 886# Compare results from two summary files 887# arg1 - summary that this particular test run created 888# arg2 - summary to compare against 889compare_two_summaries() 890{ 891 n32res=$(compare_summary_of_data $1 $2 $"32-bit nopt mode") 892 n64res=$(compare_summary_of_data $1 $2 $"64-bit nopt mode") 893 o32res=$(compare_summary_of_data $1 $2 $"32-bit opt mode") 894 o64res=$(compare_summary_of_data $1 $2 $"64-bit opt mode") 895 896 n32p=`echo $n32res | awk -F":" '{print $1}'` 897 n32f=`echo $n32res | awk -F":" '{print $2}'` 898 n64p=`echo $n64res | awk -F":" '{print $1}'` 899 n64f=`echo $n64res | awk -F":" '{print $2}'` 900 o32p=`echo $o32res | awk -F":" '{print $1}'` 901 o32f=`echo $o32res | awk -F":" '{print $2}'` 902 o64p=`echo $o64res | awk -F":" '{print $1}'` 903 o64f=`echo $o64res | awk -F":" '{print $2}'` 904 905 header="%-11s %10s %11s %10s %11s\n" 906 format="%-11s %10d %11d %10d %11d\n" 907 divider="---------------------------------" 908 longDivider="$divider$divider" 909 printf "$header" "test type" "64 bit opt" "64 bit nopt" "32 bit opt" "32 bit nopt" 910 echo "$longDivider" 911 printf "$format" "pass diff" $o64p $n64p $o32p $n32p 912 printf "$format" "fail diff" $o64f $n64f $o32f $n32f 913 for result_value in $o64p $n64p $o32p $n32p $o64f $n64f $o32f $n32f 914 do 915 if [ $result_value -ne 0 ]; then 916 return 1 917 fi 918 done 919} 920 921# ############################## MAIN ############################### 922 923# Init variables of utility 924 925UTILSTATUS=0 926AML_DONT_EXIST=0 927DO_INNER_MODES_COMPARE=no 928 929MULTIPATH= 930export EXECVERSION= 931COMMONLOGFILE= 932MODES_TIMES= 933MODES_SUMMARIES= 934NUM_DISABLED_BRANCHES= 935 936# Do settings: 937# - set up a list of test cases you want to be processed 938# - set up a set of modes to run the tests 939# - init log out results of runs 940 941RESET_SETTINGS 942INIT_ALL_AVAILABLE_CASES 943INIT_ALL_AVAILABLE_MODES 944INIT_SET_OF_TEST_CASES 945INIT_SET_OF_TEST_MODES 946INIT_LOG_RESULTS 947INIT_MEM_STAT 948 949# Check access to AcpiExec utility 950 951if [ ! -f "$acpiexec" ]; then 952 do_exit 1 "Undefined acpiexec variable! Set it to pathname of AcpiExec utility." 953fi 954 955# Determine the working directory and take precautions (last name should be aslts) 956 957if [ ! -d "$ASLTSDIR" ]; then 958 do_exit 1 "Undefined ASLTSDIR variable! Set it to pathname of root directory of aslts test suite." 959fi 960 961x=`basename "$ASLTSDIR"` 962if [ "$x" != aslts ]; then 963 do_exit 1 "The last name in ASLTSDIR should be 'aslts', but it is $x!" 964fi 965 966# Start date and time (used in name of result directory) 967 968TS_FMT_INIDATE=$(date +%F) 969TS_FMT_INITIME=$(date +%T) 970 971# Prepare directory for results 972 973if [ $ENABLELOG != 0 ]; then 974 975 EXECVERSION=`get_acpiexec_version` 976 977 MULTINAME=`get_date_time_like_name "$TS_FMT_INIDATE" "$TS_FMT_INITIME"` 978 979 make_multi_result_dir "$MULTINAME" 980 981 # Set up the common messages log file 982 983 MULTIPATH="$ASLTSDIR/tmp/RESULTS/$MULTINAME" 984 check_dir "$MULTIPATH" 985 echo "Generating ASLTS log into directory $MULTIPATH" 986 987 COMMONLOGFILE="$MULTIPATH/Summary" 988 SUMMARYDELTAFILE="$MULTIPATH/DeltaSummary" 989 echo "# Trace and summary of $MULTINAME bunch of test runs." > "$COMMONLOGFILE" 990 multi_log "" 991 multi_log "ASLTS_SYSTEM `uname -a`" 992 multi_log "" 993fi 994 995# Start of tests run 996 997report_enabled_test_cases "$ENABLED_TCASES" 998 999multi_log "" 1000 1001report_specified_modes 1002 1003multi_log "" 1004 1005multi_log "Execution started $TS_FMT_INIDATE $TS_FMT_INITIME" 1006 1007# Run tests in 32-bit unoptimized code 1008if [ $ENABLENORM32 != 0 ]; then 1009 run_set_of_test_cases $NORM32 "$MULTIPATH" "$ENABLED_TCASES" 1010fi 1011 1012# Run tests in 64-bit unoptimized code 1013if [ $ENABLENORM64 != 0 ]; then 1014 run_set_of_test_cases $NORM64 "$MULTIPATH" "$ENABLED_TCASES" 1015fi 1016 1017# Run tests in 32-bit optimized code 1018if [ $ENABLEOPT32 != 0 ]; then 1019 run_set_of_test_cases $OPT32 "$MULTIPATH" "$ENABLED_TCASES" 1020fi 1021 1022# Run tests in 64-bit optimized code 1023if [ $ENABLEOPT64 != 0 ]; then 1024 run_set_of_test_cases $OPT64 "$MULTIPATH" "$ENABLED_TCASES" 1025fi 1026 1027# Finish of tests run 1028 1029TS_FMT_ENDTIME=$(date +%T) 1030TS_FMT_RUNTIME=`get_cent_str_diff $TS_FMT_INITIME $TS_FMT_ENDTIME` 1031# AcpiExec doesn't provide status of test execution, 1032# so don't report STATUS of AcpiExec execution here 1033# not to mislead as it means STATUS of the tests 1034# execution. 1035# if [ $UTILSTATUS == 0 ]; then 1036# status=PASS 1037# else 1038# status=FAIL 1039# fi 1040multi_log "Execution finished $(date +%F) $TS_FMT_ENDTIME ($TS_FMT_RUNTIME)" 1041 1042if [ $ENABLELOG != 0 ]; then 1043 1044 # Prepare all summaries 1045 1046 do_all_summary "$MULTIPATH" "$ENABLED_TCASES" 1047 1048 # Generalization of summaries 1049 1050 multi_log " " 1051 multi_log " PER-MODE TEST CASES EXECUTION SUMMARY:" 1052 multi_log " " 1053 report_mode_summary "$MULTIPATH" $NORM32 "${MODES_SUMMARIES[$NORM32]}" 1054 report_mode_summary "$MULTIPATH" $NORM64 "${MODES_SUMMARIES[$NORM64]}" 1055 report_mode_summary "$MULTIPATH" $OPT32 "${MODES_SUMMARIES[$OPT32]}" 1056 report_mode_summary "$MULTIPATH" $OPT64 "${MODES_SUMMARIES[$OPT64]}" 1057 1058 # Cross-compare results of runs of the same multi-result directory 1059 1060 if [ "$DO_INNER_MODES_COMPARE" == yes ]; then 1061 do_inner_modes_cmp "$MULTIPATH" 1062 fi 1063 1064 # Alarm the number of excluded testing branches 1065 1066 multi_log "" 1067 1068 if [ -n "$NUM_DISABLED_BRANCHES" ]; then 1069 if [ "$NUM_DISABLED_BRANCHES" != 0 ]; then 1070 multi_log "WARNING: the number of excluded testing branches is non-zero: $NUM_DISABLED_BRANCHES" 1071 fi 1072 fi 1073 1074 TS_FMT_ENDTIME=$(date +%T) 1075 TS_FMT_TOTALTIME=`get_cent_str_diff $TS_FMT_INITIME $TS_FMT_ENDTIME` 1076 multi_log "Summary prepared $(date +%F) $TS_FMT_ENDTIME ($TS_FMT_TOTALTIME)" 1077fi 1078 1079if [ $AML_DONT_EXIST != 0 ]; then 1080 msg="WARNING: some test cases don't have AML code! ($AML_DONT_EXIST)" 1081 echo "$msg" 1082 multi_log "$msg" 1083fi 1084 1085if [ $HAVE_LARGE_REF_CNT == yes ]; then 1086 msg="WARNING: <Large Reference Count> where detected!" 1087 echo "$msg" 1088 multi_log "" 1089 multi_log "$msg" 1090fi 1091 1092# Generate diff of test results based on this run's summary and the latest summary file of a test run. 1093summary_to_compare=`find . -name "Summary" -type f -printf '%T@ %p\n' | sort -k 1 -nr | sed 's/^[^ ]* //' | sed -n 2p` 1094 1095if [ "$summary_to_compare" == "" ]; then 1096 echo "No summary file to compare against." 1097else 1098 echo "comparing against $summary_to_compare" 1099 compare_two_summaries "$COMMONLOGFILE" "$summary_to_compare" 1100 if [ $? -ne 0 ]; then \ 1101 do2path=$MULTIPATH/do2Output.txt 1102 Do 2 > $do2path 1103 if [ $? -ne 0 ]; then \ 1104 echo "Detailed comparison of previous 2 test runs in $do2path" 1105 fi 1106 fi 1107fi 1108 1109exit $UTILSTATUS 1110