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