1#!/bin/bash 2# 3# @echo off 4# 5# The test suite command dispatcher 6# 7# Available commands: 8# 9# 0 - Make and install AML tests 10# 1 - Run specified set of tests in all enabled modes 11# 2 - Compare two multi-results of two runs of tests 12# 3 - Print out the names of all the available test cases 13# 4 - Calculate the current state of all bugs and report the summary 14# tables 15# 5 - Prepare bdemo summary files of one multi-results directory for all 16# modes 17# 6 - Concatenate bdemo summary files of two multi-results 18# 19# Notations: 20# 21# ASL - iASL compiler 22# acpiexec - AcpiExec utility 23# ASLTSDIR - pathname of root directory of aslts test suite 24# 25# External definitions required for particular command: 26# 27# 0 - ASLTSDIR, ASL 28# 1 - ASLTSDIR, acpiexec 29# 2 - ASLTSDIR 30# 3 - none 31# 4 - ASLTSDIR 32# 5 - ASLTSDIR 33# 6 - ASLTSDIR 34# 35# Other: 36# Make sure that "." (current directory) is in your default search path. 37# If necessary, convert all scripts in the aslts/bin directory to unix 38# line endings: 39# d2u aslts/bin/* 40# 41# Concepts: 42# 43# run - execution of the specified set of tests 44# for one particular enabled mode 45# 46# multi-run - execution of the specified set of tests 47# for all the enabled modes 48# 49# multi-result (directory) - directory in RESULTS one containing 50# all results of one multi-run 51# 52# root directory of results - aslts/tmp/RESULTS 53# root directory of aslts - aslts 54# 55# REMEMBER (To-Be-Done items) 56# 57# 1. Dont forget to add testing of aml/nopt mode. 58# 2. Do make-install till the first error automatically 59# 3. Not implemented yet though announced in Usage: 60# - "Do 1 [n32 [n64 [s32 [s64]]]] [<test_case_name> [<test_case_name> [...]]]" 61# - "Make-install all the test cases of the specified test collections" 62# - ... 63# 4. Add checking of presence of "Large reference count" message in logs 64# 65 66STR_BDEMOSSUM="prepare bdemo summary files of one multi-results directory for all modes" 67STR_CONCBDEMOS="concatenate bdemo summary files of two multi-results" 68STR_BDEMOSTABS="calculate the current state of all bugs and report the summary tables" 69 70usage() 71{ 72 echo "Usage:" 73 echo " print out usage:" 74 echo " Do" 75 echo " make and install AML tests:" 76 echo " Do $ASLCOMPILE [ASLTS|aslts]" 77 echo " Do $ASLCOMPILE <test_case_name> [<test_case_name> [...]]" 78 echo " Do $ASLCOMPILE [ALL|all] [functional[complex[exceptions[bdemo[service[mt[Identity2MS]]]]]]]" 79 echo " run specified set of tests in all enabled modes:" 80 echo " Do $RUNTESTS" 81 echo " Do $RUNTESTS [n32 [n64 [s32 [s64]]]] [<test_case_name> [<test_case_name> [...]]]" 82 echo " compare two multi-results of two runs of tests:" 83 echo " Do $DIFFRESULTS" 84 echo " Do $DIFFRESULTS <multi-result directory>" 85 echo " Do $DIFFRESULTS <new multi-result directory> <old multi-result directory>" 86 echo " print out names of all the available test cases:" 87 echo " Do $PRINTTESTCASES" 88 echo " $STR_BDEMOSTABS:" 89 echo " Do $BDEMOSTABS <new multi-result directory> <old multi-result directory> <ALLBUGS Description File>" 90 echo " <kernel bugzilla Bug List file> <local bugzilla Bug List file>" 91 echo " $STR_BDEMOSSUM:" 92 echo " Do $BDEMOSSUM <multi-result directory>" 93 echo " $STR_CONCBDEMOS:" 94 echo " Do $CONCBDEMOS <new multi-result directory> <old multi-result directory>" 95} 96 97# Report message 98msg() 99{ 100 prog_name=`basename "$0"` 101 echo "$prog_name: $1" 102} 103 104# Report error message 105msgE() 106{ 107 prog_name=`basename "$0"` 108 echo "$prog_name[ERROR]: $1" 109} 110 111# Exit the program 112# agr1 - 0 success, non-zero - fail 113do_exit() 114{ 115 if [ $1 -eq 0 ]; then 116 if [ "$2" != "" ]; then 117 msg "$2" 118 fi 119 exit 0 120 else 121 msgE "$2" 122 exit 1 123 fi 124} 125 126# Abort program when arg1 is not a directory 127# arg1 - path name of directory 128check_dir() 129{ 130 if [ ! -d "$1" ]; then 131 do_exit 1 "Not a directory: $1" 132 fi 133} 134 135# Return the string-description of compare command 136# arg1 - opcode of compare command 137cmp_cmd_string() 138{ 139 local msg 140 141 case $1 in 142 1) msg="Compare the last multi-result against the previous one:";; 143 2) msg="Compare the last multi-result against the specified one:";; 144 3) msg="Compare the first(new) specified multi-result against the second(old):";; 145 *) msg="?" 146 esac 147 148 echo "$msg" 149} 150 151# Compare the last multi-result against the previous one 152# arg1 - root directory of results 153do_cmp1() 154{ 155 local x previous last DIR0 DIR1 156 157 x=`get_two_last_dirs "$1"` 158 last=`echo "$x" | awk -F: '{ print $2}'` 159 previous=`echo "$x" | awk -F: '{ print $3}'` 160 161 if [ -n "$previous" -a -n "$last" ]; then 162 163 DIR0="$1/$previous" 164 DIR1="$1/$last" 165 166 echo " root directory of results : $1" 167 echo " the last multi-result : $last" 168 echo " against previous one : $previous" 169 echo "" 170 171 asltsdiffres "$DIR0" "$DIR1" 172 173 elif [ -n "$last" ]; then 174 echo "There is the only component of root directory of results: $last" 175 echo "root directory of results: $1" 176 else 177 echo "No one component in the root directory of results: $1" 178 fi 179} 180 181# Compare the last multi-result against the specified one 182# arg1 - root directory of results 183# arg2 - second multi-result directory 184do_cmp2() 185{ 186 local x last DIR0 DIR1 187 188 x=`get_two_last_dirs "$1"` 189 last=`echo "$x" | awk -F: '{ print $2}'` 190 191 if [ -n "$last" ]; then 192 193 DIR0="$2" 194 DIR1="$1/$last" 195 196 echo " root directory of results : $1" 197 echo " the last multi-result : $DIR1" 198 echo " against the specified one : $DIR0" 199 echo "" 200 201 asltsdiffres "$DIR0" "$DIR1" 202 203 else 204 echo "No one component in the root directory of results: $1" 205 fi 206} 207 208# Compare the first specified multi-result against the second one 209# arg1 - first multi-result directory 210# arg2 - second multi-result directory 211do_cmp3() 212{ 213 local DIR0 DIR1 214 215 DIR0="$2" 216 DIR1="$1" 217 218 echo " First (new) specified multi-result : $DIR1" 219 echo " Second (old) specified multi-result : $DIR0" 220 221 asltsdiffres "$DIR0" "$DIR1" 222} 223 224# Compare two multi-results 225# arg1 - the number of parameters passed to Do utility 226# arg2 - first multi-result directory 227# arg3 - second multi-result directory 228# arg4 - root directory of results 229do_cmp() 230{ 231 cmp_cmd_string $1 232 233 if [ $1 == 1 ]; then 234 do_cmp1 "$4" 235 elif [ $1 == 2 ]; then 236 do_cmp2 "$4" "$3" 237 elif [ $1 == 3 ]; then 238 do_cmp3 "$2" "$3" 239 else 240 do_exit 1 "Invalid usage" 241 fi 242} 243 244 245# Summary files of bdemos 246 247do_bdemo_sums() 248{ 249 dir="$2" 250 251 echo "$STR_BDEMOSSUM:" 252 echo " the multi-result : $dir" 253 254 bdemossum "$dir" 255} 256 257# Concatenate summary files of bdemos 258 259concatenate_bdemo_sums() 260{ 261 local DIR0 DIR1 262 263 DIR0="$2" 264 DIR1="$3" 265 266 echo "$STR_CONCBDEMOS:" 267 268 echo " the first multi-result : $DIR0" 269 echo " the second multi-result : $DIR1" 270 271 bdemosconc "$DIR0" "$DIR1" 272} 273 274# Summary table of bdemos 275 276do_bdemo_table() 277{ 278 local DIR0 DIR1 279 280 DIR0="$2" 281 DIR1="$3" 282 ALLBUGS="$4" 283 KBSUM="$5" 284 LBSUM="$6" 285 286 echo "$STR_BDEMOSTABS:" 287 288 echo " the first multi-result : $DIR0" 289 echo " the second multi-result : $DIR1" 290 echo " ALLBUGS Description File : $ALLBUGS" 291 echo " kernel bugzilla Bug List file : $KBSUM" 292 echo " local bugzilla Bug List file : $LBSUM" 293 echo " BUG_STATE_DIR : $BUG_STATE_DIR" 294 295 bdemostabs "$DIR0" "$DIR1" "$ALLBUGS" "$KBSUM" "$LBSUM" "$BUG_STATE_DIR" 296} 297 298 299# Make-install all the provided test cases 300# (make install from aslts directory) 301# arg1 - root directory of aslts 302make_install_1() 303{ 304 local dir restore_dir 305 306 restore_dir=$PWD 307 dir="$1" 308 309 cd "$dir" 310 311 echo "Running make install from $dir" 312 make install > /dev/null 313 if [ $? -ne 0 ]; then 314 do_exit 1 "make install error" 315 fi 316 cd "$restore_dir" 317} 318 319# Check parameters to be the names of test 320# cases and run make install for each of them 321# if specified. 322# arg1 - root directory of aslts 323# arg2 - all the lexem here must be the names of test cases 324# arg3 - either to actually run make install 325do_test_cases_make_install() 326{ 327 local errors=0 dir restore_dir 328 329 restore_dir=$PWD 330 331 for filename in $2 332 do 333 get_collection_opcode "$filename" 334 ret=$? 335 if [ $ret -eq $COLLS_NUM ]; then 336 do_exit 1 "Not the name of any test case: $filename" 337 fi 338 339 dir="`get_test_case_dir "$1" $ret $filename`" 340 check_dir "$dir" 341 342 if [ $3 != 0 ]; then 343 cd "$dir" 344 make install > /dev/null 345 if [ $? -ne 0 ]; then 346 errors=1 347 fi 348 fi 349 done 350 351 cd "$restore_dir" 352 353 return $errors 354} 355 356# Make-install a list of specified test cases 357# arg1 - root directory of aslts 358# arg2 - all the lexem here must be the names of test cases 359make_install_2() 360{ 361 # Check only all parameters are correct 362 # (abort when something is wrong) 363 364 do_test_cases_make_install "$1" "$2" 0 365 366 # Run actual work 367 368 do_test_cases_make_install "$1" "$2" 1 369} 370 371# Check parameters to be the names of test 372# collections and run make install for each 373# of them, if specified. 374# arg1 - root directory of aslts 375# arg2 - all the lexem here must be the names of test collections 376# arg3 - either to actually run make install 377do_collections_make_install() 378{ 379 local errors=0 dir restore_dir 380 381 restore_dir=$PWD 382 383 for filename in $2 384 do 385 is_collection_name "$filename" 386 if [ $? -ne 0 ]; then 387 do_exit 1 "Not the name of any test collection: $filename" 388 fi 389 390 dir="`get_collections_root_dir "$1"`/$filename" 391 check_dir "$dir" 392 393 if [ $3 != 0 ]; then 394 cd "$dir" 395 make install > /dev/null 396 if [ $? -ne 0 ]; then 397 errors=1 398 fi 399 fi 400 done 401 402 cd "$restore_dir" 403 404 return $errors 405} 406 407# Make-install all the test cases of the specified test collections 408# arg1 - root directory of aslts 409# arg2 - all the lexem here must be the names of test collections 410make_install_3() 411{ 412 # Check only all parameters are correct 413 # (abort when something is wrong) 414 415 do_collections_make_install "$1" "$2" 0 416 417 # Run actual work 418 419 do_collections_make_install "$1" "$2" 1 420} 421 422# Make-install the test case(s). 423# 424# Parameters: 425# 426# 1. Make-install all the provided test cases: 427# 428# aslts 429# 430# 2. Make-install a list of specified test cases: 431# 432# test_case_name [test_case_name...] 433# 434# 3. Make-install all the test cases of the specified test collections: 435# 436# [ALL|all] [functional[complex[exceptions[bdemo[service[mt[Identity2MS]]]]]]] 437# 438# arg1 - root directory of aslts 439# arg2 - number of parameters passed to Do utility 440# arg3 - all parameters passed to Do utility 441run_asl_compiler() 442{ 443 local lexem list nparam=$2 action=100 444 445 lexem=`echo "$3" | awk '{ print $2}'` 446 447 if [ $nparam -le 1 ]; then 448 usage 449 do_exit 1 "Bad parameters 0" 450 elif [ $lexem == ASLTS -o $lexem == aslts ]; then 451 if [ $nparam != 2 ]; then 452 usage 453 do_exit 1 "Bad parameters 1" 454 else 455 action=1 456 fi 457 elif [ $lexem == ALL -o $lexem == all ]; then 458 if [ $nparam -le 2 ]; then 459 usage 460 do_exit 1 "Bad parameters 2" 461 else 462 list=`echo "$3" | cut -c 7-` 463 action=3 464 fi 465 else 466 action=2 467 list=`echo "$3" | cut -c 3-` 468 fi 469 470 if [ $action == 1 ]; then 471 echo "Make-install all the provided test cases" 472 make_install_1 "$1" 473 elif [ $action == 2 ]; then 474 echo "Make-install a list of specified test cases: $list" 475 make_install_2 "$1" "$list" 476 elif [ $action == 3 ]; then 477 echo "Make-install all the test cases of the specified test collections: $list" 478 make_install_3 "$1" "$list" 479 else 480 do_exit 1 "Bad parameters 2" 481 fi 482} 483 484get_aslts_bin_line() 485{ 486 echo "$1" | awk -F: '{ for (i=1; i<=NF; i++) { print $i}}' |\ 487 while [ 1 ] 488 do 489 read line 490 if [ $? -ne 0 ]; then 491 break 492 fi 493 if [[ "$line" == *aslts/bin ]]; then 494 echo "$line" 495 fi 496 done 497} 498 499# ############################## MAIN ############################### 500 501# Init variables of utility 502 503# Available commands 504 505CMD=$1 506NPARAM=$# 507ASLCOMPILE=0 508RUNTESTS=1 509DIFFRESULTS=2 510PRINTTESTCASES=3 511BDEMOSTABS=4 512BDEMOSSUM=5 513CONCBDEMOS=6 514 515# Set defaults 516 517RESULTDIR= 518 519# ################################################################## # 520# ATTENTION: dont use yet here any common stuff till the next remark # 521# ################################################################## # 522 523# Only report USAGE 524 525if [ $NPARAM == 0 ]; then 526 usage 527 do_exit 0 "" 528fi 529 530# Determine the working directory and take precautions (last name should be aslts) 531 532if [ ! -d "$ASLTSDIR" ]; then 533 do_exit 1 "Undefined ASLTSDIR variable! Set it to pathname of root directory of aslts test suite." 534fi 535 536x=`basename "$ASLTSDIR"` 537if [ "$x" != aslts ]; then 538 do_exit 1 "The last name in ASLTSDIR should be 'aslts', but it is $x!" 539fi 540 541check_dir "$ASLTSDIR" 542 543# Set up the additional environment 544 545x=`echo $PATH | grep "aslts/bin"` 546if [ "$x" == "" ]; then 547 PATH=$PATH:$ASLTSDIR/bin 548fi 549 550x=`echo $PATH | grep "aslts/bin"` 551if [ "$x" == "" ]; then 552 do_exit 1 "Failed to set up aslts/bin to PATH!" 553fi 554 555# The simple below doesn't work on Cygwin: 556# BUG_STATE_DIR=$ASLTSDIR/bin/bugstate 557# Basing on grep will not work in abnormal case 558# when there are several "aslts/bin" in PATH, so 559# detailed calculation of line with "aslts/bin": 560x=`get_aslts_bin_line "$PATH"` 561if [ x"$x" == x ]; then 562 do_exit 1 "No aslts/bin in PATH!" 563fi 564 565BUG_STATE_DIR="$x/bugstate" 566PATH=$PATH:$BUG_STATE_DIR 567 568 569# Add the common use stuff 570 571. common 572. settings 573 574# ###################################################### # 575# ATTENTION: can use the common stuff starting from here # 576# ###################################################### # 577 578# Init available tests 579 580RESET_SETTINGS 581INIT_ALL_AVAILABLE_CASES 582INIT_ALL_AVAILABLE_MODES 583 584# Only report available test cases 585 586if [ $CMD == $PRINTTESTCASES ]; then 587 echo_available_test_cases 588 do_exit 0 "" 589fi 590 591# Command execution 592 593if [ $CMD == $ASLCOMPILE ]; then 594 595 # Check access to iASL compiler 596 597 if [ ! -f "$ASL" ]; then 598 do_exit 1 "Undefined ASL variable! Set it to pathname of ASL compiler." 599 fi 600 601 x="$@" 602 run_asl_compiler "$ASLTSDIR" $NPARAM "$x" 603 604elif [ $CMD == $RUNTESTS ]; then 605 606 # Check access to AcpiExec utility 607 608 if [ ! -f "$acpiexec" ]; then 609 do_exit 1 "Undefined acpiexec variable! Set it to pathname of AcpiExec utility." 610 fi 611 612 shift 1 613 ASLTSRUN_PARAMS= 614 615 ENABLED_TMODES= 616 while : 617 do 618 check_mode_id $1 619 if [ $? -eq 1 ]; then 620 break 621 fi 622 ENABLED_TMODES="$1 $ENABLED_TMODES" 623 shift 1 624 done 625 export ENABLED_TMODES 626 627 export ENABLED_TCASES="$@" 628 629 asltsrun 630 631elif [ $CMD == $DIFFRESULTS ]; then 632 633 RESULTDIR="$ASLTSDIR/tmp/RESULTS" 634 check_dir "$RESULTDIR" 635 if [ $NPARAM == 1 ]; then 636 do_cmp $NPARAM 0 0 "$RESULTDIR" 637 elif [ $NPARAM == 2 ]; then 638 do_cmp $NPARAM 0 "$2" "$RESULTDIR" 639 elif [ $NPARAM == 3 ]; then 640 do_cmp $NPARAM "$2" "$3" "$RESULTDIR" 641 else 642 bad_param_number $CMD $NPARAM "not more than 3" 643 fi 644 645elif [ $CMD == $BDEMOSSUM ]; then 646 647 if [ $NPARAM == 2 ]; then 648 do_bdemo_sums "$NPARAM" "$2" 649 else 650 bad_param_number $CMD $NPARAM "2" 651 fi 652 653elif [ $CMD == $CONCBDEMOS ]; then 654 655 if [ $NPARAM == 3 ]; then 656 concatenate_bdemo_sums $NPARAM "$2" "$3" 657 else 658 bad_param_number $CMD $NPARAM "3" 659 fi 660 661elif [ $CMD == $BDEMOSTABS ]; then 662 663 if [ $NPARAM == 6 ]; then 664 do_bdemo_table $NPARAM "$2" "$3" "$4" "$5" "$6" 665 else 666 bad_param_number $CMD $NPARAM "6" 667 fi 668 669else 670 do_exit 1 "Bad parameters 3" 671fi 672