1#!/bin/bash 2# 3# @echo off 4# 5# The common use data and routines 6 7# Report message 8msg() 9{ 10 prog_name=`basename "$0"` 11 echo "$prog_name: $1" 12} 13 14# Report error message 15msgE() 16{ 17 prog_name=`basename "$0"` 18 echo "$prog_name[ERROR]: $1" 19} 20 21# Exit the program 22do_exit() 23{ 24 if [ $1 -eq 0 ]; then 25 if [ "$2" != "" ]; then 26 msg "$2" 27 fi 28 exit 0 29 else 30 msgE "$2" 31 exit 1 32 fi 33} 34 35# Make directory 36# arg1 - pathname of directory 37make_dir() 38{ 39 if [ ! -d "$1" ]; then 40 mkdir "$2" 41 if [ $? -ne 0 ]; then 42 do_exit 1 "Failed to make $3 directory" 43 fi 44 fi 45} 46 47# Abort the program if arg1 is not a directory 48# arg1 - path name of directory 49check_dir() 50{ 51 if [ ! -d "$1" ]; then 52 do_exit 1 "Not a directory: $1" 53 fi 54} 55 56# Invalid number of parameters reaction 57bad_param_number() 58{ 59 do_exit 1 "Invalid number of parameters for command $1: applied $2, expected $3" 60} 61 62# Print out a list of lexems 63echo_list() 64{ 65 echo "" 66 echo " $1:" 67 echo "" 68 69 for lexem in $2 70 do 71 echo " $lexem" 72 done 73} 74 75# Return separated by ':' sorted last and previous 76# elements of directory. 77# arg1 - directory 78get_two_last_dirs() 79{ 80 local path previous last 81 82 ls "$1" | sort -r |\ 83 while [ 1 ] 84 do 85 read filename 86 if [ $? -ne 0 ] ; then 87 echo ":$last:$previous:" 88 break 89 fi 90 path="$1/$filename" 91 if [ -d "$path" ]; then 92 if [ -z "$last" ]; then 93 last="$filename" 94 elif [ -z "$previous" ]; then 95 previous="$filename" 96 fi 97 fi 98 if [ -n "$previous" -a -n "$last" ]; then 99 echo ":$last:$previous:" 100 break 101 fi 102 done 103} 104 105# Return string describing mode of run 106# arg1 - bitmap of mode 107# arg2 - what to print: 108# 0 - part of pathname 109# 1 - name of mode 110# 2 - BITMODE 111# 3 - OPTMODE 112get_mode_string() 113{ 114 local x OPTMODE BITMODE 115 116 eval "x=$[ $1 & $FLAGOPT ]" 117 if [ $x == 0 ]; then 118 OPTMODE="nopt" 119 else 120 OPTMODE="opt" 121 fi 122 123 eval "x=$[ $1 & $FLAG64 ]" 124 if [ $x == 0 ]; then 125 BITMODE=32 126 else 127 BITMODE=64 128 fi 129 130 if [ $2 == 0 ]; then 131 echo "$OPTMODE/$BITMODE" 132 elif [ $2 == 1 ]; then 133 echo "$BITMODE-bit $OPTMODE mode" 134 elif [ $2 == 2 ]; then 135 echo "$BITMODE" 136 elif [ $2 == 3 ]; then 137 echo "$OPTMODE" 138 fi 139} 140export -f get_mode_string 141 142# Return string describing mode of run 143# arg1 - bitmap of mode 144get_mode_id() 145{ 146 local x OPTMODE BITMODE 147 148 eval "x=$[ $1 & $FLAGOPT ]" 149 if [ $x == 0 ]; then 150 OPTMODE="n" 151 else 152 OPTMODE="o" 153 fi 154 155 eval "x=$[ $1 & $FLAG64 ]" 156 if [ $x == 0 ]; then 157 BITMODE=32 158 else 159 BITMODE=64 160 fi 161 162 echo "$BITMODE:$OPTMODE" 163} 164 165# check if mode id is valid 166check_mode_id() { 167 local m 168 169 for m in $ALL_AVAILABLE_TEST_MODES; do 170 if [ "x$m" = "x$1" ]; then 171 return 0 172 fi 173 done 174 return 1 175} 176 177# Echo the name of collection 178# arg1 - opcode of collection 179get_collection_name() 180{ 181 local dirname 182 183 case $1 in 184 $FUNC_COLL_OP) dirname=functional;; 185 $CPLX_COLL_OP) dirname=complex;; 186 $EXCP_COLL_OP) dirname=exceptions;; 187 $BDEMO_COLL_OP) dirname=bdemo;; 188 $SERV_COLL_OP) dirname=service;; 189 $MT_COLL_OP) dirname=mt;; 190 $MS_IDENT_COLL_OP) dirname=Identity2MS;; 191 $IMPL_COLL_OP) dirname=IMPL;; 192 193 *) dirname="?" 194 esac 195 196 echo "$dirname" 197} 198 199# Return non-zero when the string is a name of some test collection 200# arg1 - string (to be the name of some test collection) 201is_collection_name() 202{ 203 echo $ALL_AVAILABLE_COLLS | grep $1 > /dev/null 204 return $? 205} 206 207# Return opcode of the test collection which 208# contains the test case named as string parameter, 209# COLLS_NUM, if no one collection contains such 210# test case. 211# arg1 - string (to be the name of some test case) 212get_collection_opcode() 213{ 214 local rval=0 215 216 if [ -z $1 ]; then 217 return $COLLS_NUM 218 fi 219 220 echo $FUNC_COLL | grep -w $1 > /dev/null 221 if [ $? -eq 0 ]; then 222 return $FUNC_COLL_OP 223 fi 224 225 echo $CPLX_COLL | grep -w $1 > /dev/null 226 if [ $? -eq 0 ]; then 227 return $CPLX_COLL_OP 228 fi 229 230 echo $EXCP_COLL | grep -w $1 > /dev/null 231 if [ $? -eq 0 ]; then 232 return $EXCP_COLL_OP 233 fi 234 235 echo $BDEMO_COLL | grep -w $1 > /dev/null 236 if [ $? -eq 0 ]; then 237 return $BDEMO_COLL_OP 238 fi 239 240 echo $SERV_COLL | grep -w $1 > /dev/null 241 if [ $? -eq 0 ]; then 242 return $SERV_COLL_OP 243 fi 244 245 echo $MT_COLL | grep -w $1 > /dev/null 246 if [ $? -eq 0 ]; then 247 return $MT_COLL_OP 248 fi 249 250 echo $MS_IDENT_COLL | grep -w $1 > /dev/null 251 if [ $? -eq 0 ]; then 252 return $MS_IDENT_COLL_OP 253 fi 254 255 echo $IMPL_COLL | grep -w $1 > /dev/null 256 if [ $? -eq 0 ]; then 257 return $IMPL_COLL_OP 258 fi 259 260 return $COLLS_NUM 261} 262 263# Mark - test collection was involved in processing 264# arg1 - name of test case 265mark_collection_flag() 266{ 267 local ret 268 269 get_collection_opcode "$1" 270 ret=$? 271 272 case $ret in 273 $FUNC_COLL_OP) FUNC_COLL_FLAG=1;; 274 $CPLX_COLL_OP) CPLX_COLL_FLAG=1;; 275 $EXCP_COLL_OP) EXCP_COLL_FLAG=1;; 276 $BDEMO_COLL_OP) BDEMO_COLL_FLAG=1;; 277 $SERV_COLL_OP) SERV_COLL_FLAG=1;; 278 $MT_COLL_OP) MT_COLL_FLAG=1;; 279 $MS_IDENT_COLL_OP) MS_IDENT_COLL_FLAG=1;; 280 $IMPL_COLL_OP) IMPL_COLL_FLAG=1;; 281 *) do_exit 1 "Not the name of any test case: $1" 282 esac 283} 284 285# Get ' ' blank-separated collections involved total 286get_collections_total() 287{ 288 local count=0 msg=" " 289 290 if [ $FUNC_COLL_FLAG != 0 ]; then 291 count=$[ $count + 1 ] 292 msg="$msg `get_collection_name $FUNC_COLL_OP`" 293 fi 294 if [ $CPLX_COLL_FLAG != 0 ]; then 295 count=$[ $count + 1 ] 296 msg="$msg `get_collection_name $CPLX_COLL_OP`" 297 fi 298 if [ $EXCP_COLL_FLAG != 0 ]; then 299 count=$[ $count + 1 ] 300 msg="$msg `get_collection_name $EXCP_COLL_OP`" 301 fi 302 if [ $BDEMO_COLL_FLAG != 0 ]; then 303 count=$[ $count + 1 ] 304 msg="$msg `get_collection_name $BDEMO_COLL_OP`" 305 fi 306 if [ $SERV_COLL_FLAG != 0 ]; then 307 count=$[ $count + 1 ] 308 msg="$msg `get_collection_name $SERV_COLL_OP`" 309 fi 310 if [ $MT_COLL_FLAG != 0 ]; then 311 count=$[ $count + 1 ] 312 msg="$msg `get_collection_name $MT_COLL_OP`" 313 fi 314 if [ $MS_IDENT_COLL_FLAG != 0 ]; then 315 count=$[ $count + 1 ] 316 msg="$msg `get_collection_name $MS_IDENT_COLL_OP`" 317 fi 318 if [ $IMPL_COLL_FLAG != 0 ]; then 319 count=$[ $count + 1 ] 320 msg="$msg `get_collection_name $IMPL_COLL_OP`" 321 fi 322 echo "$count:$msg:" 323} 324 325# Return the pathname of the collections root directory 326# arg1 - root directory of aslts 327get_collections_root_dir() 328{ 329 echo "$1/src/runtime/collections" 330} 331 332# Return the pathname of the specified test collection 333# arg1 - root directory of aslts 334# arg2 - opcode of test collection 335get_collection_dir() 336{ 337 local dir 338 339 dir="`get_collections_root_dir "$1"`/`get_collection_name $2`" 340 341 echo "$dir" 342} 343 344# Get pathname of test case 345# arg1 - root directory of aslts 346# arg2 - opcode of test collection 347# arg3 - name of test case 348get_test_case_dir() 349{ 350 local x path 351 352 word_is_in_line "$OPER_TCASES" "$3" " " 353 354 355 if [ $? -ne 0 ]; then 356 path="`get_collection_dir "$1" $2`/operand/tests/$3" 357 else 358 x=`echo $RES_TCASES | grep $3` 359 if [ $? -eq 0 ]; then 360 path="`get_collection_dir "$1" $2`/result/tests/$3" 361 else 362 if [ $3 == exc_operand1 -o $3 == exc_operand2 ]; then 363 path="`get_collection_dir "$1" $2`/exc_operand/$3" 364 elif [ $3 == exc_result1 -o $3 == exc_result2 ]; then 365 path="`get_collection_dir "$1" $2`/exc_result/$3" 366 elif [ $3 == dynobj ]; then 367 path="`get_collection_dir "$1" $2`/ACPICA/tests/$3" 368 elif [ $3 == bdemo -o $3 == bdemof ]; then 369 path="`get_collection_dir "$1" $2`/ACPICA/$3" 370 elif [ $3 == extra -o $3 == extra_aslts ]; then 371 path="`get_collection_dir "$1" $2`/abbu" 372 elif [[ $3 == mt_* ]]; then 373 x=`echo $3 | sed 's/mt_//'g` 374 path="`get_collection_dir "$1" $2`/$x" 375 else 376 path="`get_collection_dir "$1" $2`/$3" 377 fi 378 fi 379 fi 380 381 echo "$path" 382} 383 384# Return the name of underlying system the tests were run on 385# 386# arg0 - pathname of Summary file 387get_name_of_system() 388{ 389 OLD_IFS=$IFS 390 IFS=" " 391 392 cat "$1" |\ 393 while [ 1 ] 394 do 395 read mark system line 396 if [ $? -ne 0 ] ; then 397 echo "?" 398 break 399 fi 400 401 if [ "$mark" == ASLTS_SYSTEM ]; then 402 echo "$system" 403 break 404 fi 405 done 406 407 IFS=$OLD_IFS 408} 409 410# Get element of line of file. 411# 412# Each line of file arg1 consists of elements separated by symbol arg2. 413# The first element of line is marker. Routine seeks for the line identified 414# by the given marker (arg3) and returns arg4-th element of that line. 415# 416# arg1 - pathname of file (line of file <marker of line>|el0|el1|...; | - any symbol) 417# arg2 - separator 418# arg3 - marker of line to fit 419# arg4 - element of line to be returned (now maximum is 4 elements - 0,1,2,3) 420get_element_of_line() 421{ 422 OLD_IFS=$IFS 423 IFS="$2" 424 425 cat "$1" |\ 426 while [ 1 ] 427 do 428 read marker s0 s1 s2 s3 line 429 if [ $? -ne 0 ] ; then 430 break 431 fi 432 if [ "$marker" == "$3" ] ; then 433 case $4 in 434 0) echo "$s0" ;; 435 1) echo "$s1" ;; 436 2) echo "$s2" ;; 437 3) echo "$s3" ;; 438 *) echo "???" 439 esac 440 fi 441 done 442 443 IFS=$OLD_IFS 444} 445 446# Split the input file, each char is transformed to one line 447split_line_to_chars() 448{ 449 local x index=1 450 451 while [ 1 ] 452 do 453 x=`echo "$1" | cut -c "$index"` 454 if [ "x$x" == x ]; then 455 break 456 fi 457 echo "$x" 458 ((index=index+1)) 459 done 460} 461 462# Transform input to a line where each char occurs only once, 463# blanks are deleted. 464# 465# Note: works very slowly. 466# 467transform_to_single_chars() 468{ 469 local x line str 470 471 str="qwertyuiopasdfghjklzxcvbnm0123456789QWERTYUIOPASDFGHJKLZXCVBNM\*" 472 473 while [ 1 ] 474 do 475 read line 476 if [ $? -ne 0 ] ; then 477 break 478 fi 479 x=`echo $line | sed 's/ //'g` 480 split_line_to_chars "$x" 481 done | sort | paste -s -d " " | sed 's/ //'g | tr -s "$str" 482} 483 484# Print out all lines of file arg1 corresponding to the 485# chars of string arg2: line == <char>: <rest of line>. 486report_lines_per_char() 487{ 488 index=1 489 490 while [ 1 ] 491 do 492 x=`echo "$2" | cut -c "$index"` 493 if [ "x$x" == x ]; then 494 break 495 fi 496 y=`get_element_of_line "$1" ":" "$x" 0` 497 if [ "x$y" != x ]; then 498 echo "$x -$y" 499 elif [ "$x" != " " ]; then 500 echo "$x - ???" 501 fi 502 ((index=index+1)) 503 done 504} 505 506# arg1 - line 507# arg2 - word 508# arg3 - delimiter 509word_is_in_line() 510{ 511 local rval=0 512 513 OLD_IFS=$IFS 514 IFS="$3" 515 516 echo "$1" | awk '{ for (i=1; i<=NF; i++) { print $i}}' |\ 517 while [ 1 ] 518 do 519 read line 520 if [ $? -ne 0 ]; then 521 return 0 522 fi 523 if [ "$line" == "$2" ]; then 524 return 1 525 fi 526 done 527 rval=$? 528 529 IFS=$OLD_IFS 530 531 return $rval 532} 533 534# Convert the centisecond unit time to string {[h:]m:s.c} 535# arg1 - centisecond unit time 536cent_units_to_cent_str() 537{ 538 local rval 539 local TIME_STRING= 540 541 RAWSECONDS=$[ $1 / 100 ] 542 RAWCENTISECS=$[ $1 - $RAWSECONDS * 100 ] 543 RAWMINUTES=$[ $RAWSECONDS / 60 ] 544 RAWSECONDS=$[ $RAWSECONDS - $RAWMINUTES * 60 ] 545 RAWHOURS=$[ $RAWMINUTES / 60 ] 546 RAWMINUTES=$[ $RAWMINUTES - $RAWHOURS * 60 ] 547 548 if [ $RAWHOURS -le 9 ]; then 549 if [ $RAWHOURS -ne 0 ]; then 550 TIME_STRING=0$RAWHOURS: 551 fi 552 else 553 TIME_STRING=$RAWHOURS: 554 fi 555 556 if [ $RAWMINUTES -le 9 ]; then 557 TIME_STRING=${TIME_STRING}0$RAWMINUTES: 558 else 559 TIME_STRING=$TIME_STRING$RAWMINUTES: 560 fi 561 562 if [ $RAWSECONDS -le 9 ]; then 563 TIME_STRING=${TIME_STRING}0$RAWSECONDS 564 else 565 TIME_STRING=$TIME_STRING$RAWSECONDS 566 fi 567 568 if [ $RAWCENTISECS -le 9 ]; then 569 TIME_STRING=${TIME_STRING}.0$RAWCENTISECS 570 else 571 TIME_STRING=${TIME_STRING}.$RAWCENTISECS 572 fi 573 574 eval "rval=$TIME_STRING" 575 576 echo "$rval" 577} 578export -f cent_units_to_cent_str 579 580# Convert time to centisecond units 581# 582# Layout of time is one of these: 583# 1) hours:mins:secs.centisecs 584# 2) mins:secs.centisecs 585# 586# arg1 - time 1 587# 588# Return: 589# 0 - success 590# otherwise - bad layout 591# 592convert_string_to_centisecond_units() 593{ 594 local n0=0 h0=0 m0=0 s0=0 csec0=0 sec0=0 total0=0 595 596 n0=`echo "$1" | awk -F: '{ print NF}'` 597 598 if [ "$n0" -eq 2 ]; then 599 m0=`echo "$1" | awk -F: '{ print $1}'` 600 x=`echo "$1" | awk -F: '{ print $2}'` 601 s0=`echo "$x" | awk -F"." '{ print $1}'` 602 csec0=`echo "$x" | awk -F"." '{ print $2}'` 603 if [ x"$csec0" == x ]; then 604 return 1 605 fi 606 elif [ "$n0" -eq 3 ]; then 607 h0=`echo "$1" | awk -F: '{ print $1}'` 608 m0=`echo "$1" | awk -F: '{ print $2}'` 609 x=`echo "$1" | awk -F: '{ print $3}'` 610 s0=`echo "$x" | awk -F"." '{ print $1}'` 611 csec0=`echo "$x" | awk -F"." '{ print $2}'` 612 if [ x"$csec0" == x ]; then 613 return 2 614 fi 615 else 616 return 3 617 fi 618 619 sec0=$[ $s0 + $m0 * 60 + $h0 * 3600 ] 620 total0=$[ $csec0 + $sec0 * 100 ] 621 622 echo "$total0" 623 624 return 0 625} 626 627# Compare two times given by strings 628# 629# Layout of time is one of these: 630# 1) hours:mins:secs.centisecs 631# 2) mins:secs.centisecs 632# 633# arg1 - time 1 634# arg2 - time 2 635# 636# Return: 637# 0 - T1 == T2 638# 1 - T1 < T2 639# 2 - T1 > T2 640# 3 - bad layout of T1 641# 4 - bad layout of T2 642# 643diff_of_str_times() 644{ 645 local total0=0 646 local total1=0 647 local rval=0 diff01 diff01str 648 649 total0=`convert_string_to_centisecond_units "$1"` 650 if [ $? -ne 0 ]; then 651 return 3 652 fi 653 654 total1=`convert_string_to_centisecond_units "$2"` 655 if [ $? -ne 0 ]; then 656 return 4 657 fi 658 659 if [ "$total0" -gt "$total1" ]; then 660 diff01=$[ $total0 - $total1 ] 661 rval=2 662 elif [ "$total0" -eq "$total1" ]; then 663 diff01=0 664 rval=0 665 else 666 diff01=$[ $total1 - $total0 ] 667 rval=1 668 fi 669 670 diff01str=`cent_units_to_cent_str $diff01` 671 672 echo "$total0|$total1|$diff01|$diff01str" 673 674 return $rval 675} 676 677# ############################## MAIN ############################### 678 679# Initialize the common variables 680 681# Constants 682 683# Bitmap: 1 - 64, 2 - opt 684export FLAG64=1 685export FLAGOPT=2 686NORM32=0 687NORM64=1 688OPT32=2 689OPT64=3 690 691# Opcodes of the test collections (according to aslts) 692 693ASL_COLL_OP=0 694FUNC_COLL_OP=1 695CPLX_COLL_OP=2 696EXCP_COLL_OP=3 697BDEMO_COLL_OP=4 698SERV_COLL_OP=5 699MT_COLL_OP=6 700MS_IDENT_COLL_OP=7 701IMPL_COLL_OP=8 702RUNTIME_COLLS_NUM=8 703COLLS_NUM=9 704 705