Changeset 27034 in webkit for trunk/JavaScriptCore/tests
- Timestamp:
- Oct 25, 2007, 4:36:25 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/tests/mozilla/jsDriver.pl
r27033 r27034 41 41 42 42 my $os_type = &get_os_type; 43 my $unixish = ( $os_type ne "WIN");44 my $path_sep = "/"; # This script uses unix paths internally and converts to native when needed43 my $unixish = (($os_type ne "WIN") && ($os_type ne "MAC")); 44 my $path_sep = ($os_type eq "MAC") ? ":" : "/"; 45 45 my $win_sep = ($os_type eq "WIN")? &get_win_sep : ""; 46 my $redirect_command = " 2>&1";46 my $redirect_command = ($os_type ne "MAC") ? " 2>&1" : ""; 47 47 48 48 # command line option defaults 49 49 my $opt_suite_path; 50 50 my $opt_trace = 0; 51 my $opt_engine_type = "kjs"; 51 my $opt_classpath = ""; 52 my $opt_rhino_opt = 0; 53 my $opt_rhino_ms = 0; 54 my @opt_engine_list; 55 my $opt_engine_type = ""; 52 56 my $opt_engine_params = ""; 53 57 my $opt_user_output_file = 0; … … 60 64 my $opt_console_failures = 0; 61 65 my $opt_lxr_url = "./"; # "http://lxr.mozilla.org/mozilla/source/js/tests/"; 66 my $opt_exit_munge = ($os_type ne "MAC") ? 1 : 0; 62 67 63 68 # command line option definition … … 67 72 "x noexitmunge>x"; 68 73 69 $opt_suite_path = "./"; 74 if ($os_type eq "MAC") { 75 $opt_suite_path = `directory`; 76 $opt_suite_path =~ s/[\n\r]//g; 77 $opt_suite_path .= ":"; 78 } else { 79 $opt_suite_path = "./"; 80 } 70 81 71 82 &parse_args; … … 97 108 my $start_time; 98 109 99 $engine_command = &get_engine_command; 100 $html = ""; 101 @failed_tests = (); 102 $failures_reported = 0; 103 $tests_completed = 0; 104 $start_time = time; 105 106 107 &execute_tests (@test_list); 108 109 my $exec_time = (time - $start_time); 110 my $exec_hours = int($exec_time / 60 / 60); 111 $exec_time -= $exec_hours * 60 * 60; 112 my $exec_mins = int($exec_time / 60); 113 $exec_time -= $exec_mins * 60; 114 my $exec_secs = ($exec_time % 60); 115 116 if ($exec_hours > 0) { 117 $exec_time_string = "$exec_hours hours, $exec_mins minutes, " . 118 "$exec_secs seconds"; 119 } elsif ($exec_mins > 0) { 120 $exec_time_string = "$exec_mins minutes, $exec_secs seconds"; 121 } else { 122 $exec_time_string = "$exec_secs seconds"; 123 } 124 125 if (!$opt_user_output_file) { 126 $opt_output_file = &get_tempfile_name; 127 } 128 129 &write_results; 110 while ($opt_engine_type = pop (@opt_engine_list)) { 111 dd ("Testing engine '$opt_engine_type'"); 112 113 $engine_command = &get_engine_command; 114 $html = ""; 115 @failed_tests = (); 116 $failures_reported = 0; 117 $tests_completed = 0; 118 $start_time = time; 119 120 121 &execute_tests (@test_list); 122 123 my $exec_time = (time - $start_time); 124 my $exec_hours = int($exec_time / 60 / 60); 125 $exec_time -= $exec_hours * 60 * 60; 126 my $exec_mins = int($exec_time / 60); 127 $exec_time -= $exec_mins * 60; 128 my $exec_secs = ($exec_time % 60); 129 130 if ($exec_hours > 0) { 131 $exec_time_string = "$exec_hours hours, $exec_mins minutes, " . 132 "$exec_secs seconds"; 133 } elsif ($exec_mins > 0) { 134 $exec_time_string = "$exec_mins minutes, $exec_secs seconds"; 135 } else { 136 $exec_time_string = "$exec_secs seconds"; 137 } 138 139 if (!$opt_user_output_file) { 140 $opt_output_file = &get_tempfile_name; 141 } 142 143 &write_results; 144 145 } 130 146 } 131 147 … … 186 202 @output = grep (!/js\>/, @output); 187 203 204 if ($opt_exit_munge == 1) { 188 205 # signal information in the lower 8 bits, exit code above that 189 $got_exit = ($? >> 8); 190 $exit_signal = ($? & 255); 206 $got_exit = ($? >> 8); 207 $exit_signal = ($? & 255); 208 } else { 209 # user says not to munge the exit code 210 $got_exit = $?; 211 $exit_signal = 0; 212 } 191 213 192 214 $failure_lines = ""; … … 195 217 196 218 foreach $line (@output) { 219 197 220 # watch for testcase to proclaim what exit code it expects to 198 221 # produce (0 by default) … … 355 378 $opt_bug_url = $value; 356 379 357 }elsif ($option eq "f") { 380 } elsif ($option eq "c") { 381 &dd ("opt: setting classpath to '$value'."); 382 $opt_classpath = $value; 383 384 } elsif (($option eq "e") || (($option eq "") && ($lastopt eq "e"))) { 385 &dd ("opt: adding engine $value."); 386 push (@opt_engine_list, $value); 387 388 } elsif ($option eq "f") { 358 389 if (!$value) { 359 390 die ("Output file cannot be null.\n"); … … 393 424 } elsif ($option eq "p") { 394 425 $opt_suite_path = $value; 395 if (!($opt_suite_path =~ /[\/\\]$/)) { 396 $opt_suite_path .= "/"; 426 427 if ($os_type eq "MAC") { 428 if (!($opt_suite_path =~ /\:$/)) { 429 $opt_suite_path .= ":"; 430 } 431 } else { 432 if (!($opt_suite_path =~ /[\/\\]$/)) { 433 $opt_suite_path .= "/"; 434 } 397 435 } 398 436 … … 412 450 $opt_lxr_url = $value; 413 451 452 } elsif ($option eq "x") { 453 &dd ("opt: turning off exit munging."); 454 $opt_exit_munge = 0; 455 414 456 } else { 415 457 &usage; … … 417 459 418 460 $lastopt = $option; 461 419 462 } 420 463 421 464 Getopt::Mixed::cleanup(); 465 466 if ($#opt_engine_list == -1) { 467 die "You must select a shell to test in.\n"; 468 } 469 422 470 } 423 471 … … 430 478 "(-b|--bugurl) Bugzilla URL.\n" . 431 479 " (default is $opt_bug_url)\n" . 480 "(-c|--classpath) Classpath (Rhino only.)\n" . 481 "(-e|--engine) <type> ... Specify the type of engine(s) to test.\n" . 482 " <type> is one or more of\n" . 483 " (kjs|smopt|smdebug|lcopt|lcdebug|xpcshell|" . 484 "rhino|rhinoi|rhinoms|rhinomsi|rhino9|rhinoms9).\n" . 432 485 "(-f|--file) <file> Redirect output to file named <file>.\n" . 433 486 " (default is " . … … 459 512 my $retval; 460 513 461 if ($opt_engine_type eq "kjs") { 514 if ($opt_engine_type eq "rhino") { 515 &dd ("getting rhino engine command."); 516 $opt_rhino_opt = 0; 517 $opt_rhino_ms = 0; 518 $retval = &get_rhino_engine_command; 519 } elsif ($opt_engine_type eq "rhinoi") { 520 &dd ("getting rhinoi engine command."); 521 $opt_rhino_opt = -1; 522 $opt_rhino_ms = 0; 523 $retval = &get_rhino_engine_command; 524 } elsif ($opt_engine_type eq "rhino9") { 525 &dd ("getting rhino engine command."); 526 $opt_rhino_opt = 9; 527 $opt_rhino_ms = 0; 528 $retval = &get_rhino_engine_command; 529 } elsif ($opt_engine_type eq "rhinoms") { 530 &dd ("getting rhinoms engine command."); 531 $opt_rhino_opt = 0; 532 $opt_rhino_ms = 1; 533 $retval = &get_rhino_engine_command; 534 } elsif ($opt_engine_type eq "rhinomsi") { 535 &dd ("getting rhinomsi engine command."); 536 $opt_rhino_opt = -1; 537 $opt_rhino_ms = 1; 538 $retval = &get_rhino_engine_command; 539 } elsif ($opt_engine_type eq "rhinoms9") { 540 &dd ("getting rhinomsi engine command."); 541 $opt_rhino_opt = 9; 542 $opt_rhino_ms = 1; 543 $retval = &get_rhino_engine_command; 544 } elsif ($opt_engine_type eq "xpcshell") { 545 &dd ("getting xpcshell engine command."); 546 $retval = &get_xpc_engine_command; 547 } elsif ($opt_engine_type =~ /^lc(opt|debug)$/) { 548 &dd ("getting liveconnect engine command."); 549 $retval = &get_lc_engine_command; 550 } elsif ($opt_engine_type =~ /^sm(opt|debug)$/) { 551 &dd ("getting spidermonkey engine command."); 552 $retval = &get_sm_engine_command; 553 } elsif ($opt_engine_type =~ /^ep(opt|debug)$/) { 554 &dd ("getting epimetheus engine command."); 555 $retval = &get_ep_engine_command; 556 } elsif ($opt_engine_type eq "kjs") { 462 557 &dd ("getting kjs engine command."); 463 558 $retval = &get_kjs_engine_command; 559 464 560 } else { 465 561 die ("Unknown engine type selected, '$opt_engine_type'.\n"); … … 471 567 472 568 return $retval; 569 570 } 571 572 # 573 # get the shell command used to run rhino 574 # 575 sub get_rhino_engine_command { 576 my $retval = $opt_java_path . ($opt_rhino_ms ? "jview " : "java "); 577 578 if ($opt_shell_path) { 579 $opt_classpath = ($opt_classpath) ? 580 $opt_classpath . ":" . $opt_shell_path : 581 $opt_shell_path; 582 } 583 584 if ($opt_classpath) { 585 $retval .= ($opt_rhino_ms ? "/cp:p" : "-classpath") . " $opt_classpath "; 586 } 587 588 $retval .= "org.mozilla.javascript.tools.shell.Main"; 589 590 if ($opt_rhino_opt) { 591 $retval .= " -opt $opt_rhino_opt"; 592 } 593 594 return $retval; 595 596 } 597 598 # 599 # get the shell command used to run xpcshell 600 # 601 sub get_xpc_engine_command { 602 my $retval; 603 my $m5_home = @ENV{"MOZILLA_FIVE_HOME"} || 604 die ("You must set MOZILLA_FIVE_HOME to use the xpcshell" , 605 (!$unixish) ? "." : ", also " . 606 "setting LD_LIBRARY_PATH to the same directory may get rid of " . 607 "any 'library not found' errors.\n"); 608 609 if (($unixish) && (!@ENV{"LD_LIBRARY_PATH"})) { 610 print STDERR "-#- WARNING: LD_LIBRARY_PATH is not set, xpcshell may " . 611 "not be able to find the required components.\n"; 612 } 613 614 if (!($m5_home =~ /[\/\\]$/)) { 615 $m5_home .= "/"; 616 } 617 618 $retval = $m5_home . "xpcshell"; 619 620 if ($os_type eq "WIN") { 621 $retval .= ".exe"; 622 } 623 624 $retval = &xp_path($retval); 625 626 if (($os_type ne "MAC") && !(-x $retval)) { 627 # mac doesn't seem to deal with -x correctly 628 die ($retval . " is not a valid executable on this system.\n"); 629 } 630 631 return $retval; 632 473 633 } 474 634 … … 488 648 } 489 649 650 # 651 # get the shell command used to run spidermonkey 652 # 653 sub get_sm_engine_command { 654 my $retval; 655 656 # Look for Makefile.ref style make first. 657 # (On Windows, spidermonkey can be made by two makefiles, each putting the 658 # executable in a diferent directory, under a different name.) 659 660 if ($opt_shell_path) { 661 # if the user provided a path to the shell, return that. 662 $retval = $opt_shell_path; 663 664 } else { 665 666 if ($os_type eq "MAC") { 667 $retval = $opt_suite_path . ":src:macbuild:JS"; 668 } else { 669 $retval = $opt_suite_path . "../src/"; 670 opendir (SRC_DIR_FILES, $retval); 671 my @src_dir_files = readdir(SRC_DIR_FILES); 672 closedir (SRC_DIR_FILES); 673 674 my ($dir, $object_dir); 675 my $pattern = ($opt_engine_type eq "smdebug") ? 676 'DBG.OBJ' : 'OPT.OBJ'; 677 678 # scan for the first directory matching 679 # the pattern expected to hold this type (debug or opt) of engine 680 foreach $dir (@src_dir_files) { 681 if ($dir =~ $pattern) { 682 $object_dir = $dir; 683 last; 684 } 685 } 686 687 if (!$object_dir && $os_type ne "WIN") { 688 die ("Could not locate an object directory in $retval " . 689 "matching the pattern *$pattern. Have you built the " . 690 "engine?\n"); 691 } 692 693 if (!(-x $retval . $object_dir . "/js.exe") && ($os_type eq "WIN")) { 694 # On windows, you can build with js.mak as well as Makefile.ref 695 # (Can you say WTF boys and girls? I knew you could.) 696 # So, if the exe the would have been built by Makefile.ref isn't 697 # here, check for the js.mak version before dying. 698 if ($opt_shell_path) { 699 $retval = $opt_shell_path; 700 if (!($retval =~ /[\/\\]$/)) { 701 $retval .= "/"; 702 } 703 } else { 704 if ($opt_engine_type eq "smopt") { 705 $retval = "../src/Release/"; 706 } else { 707 $retval = "../src/Debug/"; 708 } 709 } 710 711 $retval .= "jsshell.exe"; 712 713 } else { 714 $retval .= $object_dir . "/js"; 715 if ($os_type eq "WIN") { 716 $retval .= ".exe"; 717 } 718 } 719 } # mac/ not mac 720 721 $retval = &xp_path($retval); 722 723 } # (user provided a path) 724 725 726 if (($os_type ne "MAC") && !(-x $retval)) { 727 # mac doesn't seem to deal with -x correctly 728 die ($retval . " is not a valid executable on this system.\n"); 729 } 730 731 return $retval; 732 733 } 734 735 # 736 # get the shell command used to run epimetheus 737 # 738 sub get_ep_engine_command { 739 my $retval; 740 741 if ($opt_shell_path) { 742 # if the user provided a path to the shell, return that - 743 $retval = $opt_shell_path; 744 745 } else { 746 my $dir; 747 my $os; 748 my $debug; 749 my $opt; 750 my $exe; 751 752 $dir = $opt_suite_path . "../../js2/src/"; 753 754 if ($os_type eq "MAC") { 755 # 756 # On the Mac, the debug and opt builds lie in the same directory - 757 # 758 $os = "macbuild:"; 759 $debug = ""; 760 $opt = ""; 761 $exe = "JS2"; 762 } elsif ($os_type eq "WIN") { 763 $os = "winbuild/Epimetheus/"; 764 $debug = "Debug/"; 765 $opt = "Release/"; 766 $exe = "Epimetheus.exe"; 767 } else { 768 $os = ""; 769 $debug = ""; 770 $opt = ""; # <<<----- XXX THIS IS NOT RIGHT! CHANGE IT! 771 $exe = "epimetheus"; 772 } 773 774 775 if ($opt_engine_type eq "epdebug") { 776 $retval = $dir . $os . $debug . $exe; 777 } else { 778 $retval = $dir . $os . $opt . $exe; 779 } 780 781 $retval = &xp_path($retval); 782 783 }# (user provided a path) 784 785 786 if (($os_type ne "MAC") && !(-x $retval)) { 787 # mac doesn't seem to deal with -x correctly 788 die ($retval . " is not a valid executable on this system.\n"); 789 } 790 791 return $retval; 792 } 793 794 # 795 # get the shell command used to run the liveconnect shell 796 # 797 sub get_lc_engine_command { 798 my $retval; 799 800 if ($opt_shell_path) { 801 $retval = $opt_shell_path; 802 } else { 803 if ($os_type eq "MAC") { 804 die "Don't know how to run the lc shell on the mac yet.\n"; 805 } else { 806 $retval = $opt_suite_path . "../src/liveconnect/"; 807 opendir (SRC_DIR_FILES, $retval); 808 my @src_dir_files = readdir(SRC_DIR_FILES); 809 closedir (SRC_DIR_FILES); 810 811 my ($dir, $object_dir); 812 my $pattern = ($opt_engine_type eq "lcdebug") ? 813 'DBG.OBJ' : 'OPT.OBJ'; 814 815 foreach $dir (@src_dir_files) { 816 if ($dir =~ $pattern) { 817 $object_dir = $dir; 818 last; 819 } 820 } 821 822 if (!$object_dir) { 823 die ("Could not locate an object directory in $retval " . 824 "matching the pattern *$pattern. Have you built the " . 825 "engine?\n"); 826 } 827 828 $retval .= $object_dir . "/"; 829 830 if ($os_type eq "WIN") { 831 $retval .= "lcshell.exe"; 832 } else { 833 $retval .= "lcshell"; 834 } 835 } # mac/ not mac 836 837 $retval = &xp_path($retval); 838 839 } # (user provided a path) 840 841 842 if (($os_type ne "MAC") && !(-x $retval)) { 843 # mac doesn't seem to deal with -x correctly 844 die ("$retval is not a valid executable on this system.\n"); 845 } 846 847 return $retval; 848 849 } 850 490 851 sub get_os_type { 852 853 if ("\n" eq "\015") { 854 return "MAC"; 855 } 856 491 857 my $uname = `uname -a`; 492 858 … … 499 865 &dd ("get_os_type returning '$uname'."); 500 866 return $uname; 867 501 868 } 502 869 … … 538 905 &dd ((($#neg_list + 1) - $actually_skipped) . " skip tests were " . 539 906 "not actually part of the test list."); 907 908 540 909 } 541 910 542 911 return @test_list; 912 543 913 } 544 914 … … 552 922 my @retval = (); 553 923 554 # We will call expand_test_list_entry(), which does pattern-matching on $list_file. 555 # This will make the pattern-matching the same as it would be on Linux/Windows - 556 # 924 # 925 # Trim off the leading path separator that begins relative paths on the Mac. 926 # Each path will get concatenated with $opt_suite_path, which ends in one. 927 # 928 # Also note: 929 # 930 # We will call expand_test_list_entry(), which does pattern-matching on $list_file. 931 # This will make the pattern-matching the same as it would be on Linux/Windows - 932 # 933 if ($os_type eq "MAC") { 934 $list_file =~ s/^$path_sep//; 935 } 936 557 937 if ($list_file =~ /\.js$/ || -d $opt_suite_path . $list_file) { 938 558 939 push (@retval, &expand_test_list_entry($list_file)); 559 } else { 940 941 } else { 942 560 943 open (TESTLIST, $list_file) || 561 944 die("Error opening test list file '$list_file': $!\n"); … … 570 953 571 954 close (TESTLIST); 955 572 956 } 573 957 574 958 return @retval; 959 575 960 } 576 961 … … 631 1016 632 1017 return @retval; 1018 633 1019 } 634 1020 … … 660 1046 661 1047 return @retval; 1048 662 1049 } 663 1050 … … 668 1055 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = 669 1056 &get_padded_time (localtime); 670 return "res-" . $year . $mon . $mday . $hour . $min . $sec . "-" . $opt_engine_type . ".html"; 1057 my $rv; 1058 1059 if ($os_type ne "MAC") { 1060 $rv = "results-" . $year . "-" . $mon . "-" . $mday . "-" . $hour . 1061 $min . $sec . "-" . $opt_engine_type; 1062 } else { 1063 $rv = "res-" . $year . $mon . $mday . $hour . $min . $sec . "-" . 1064 $opt_engine_type 1065 } 1066 1067 return $rv . ".html"; 671 1068 } 672 1069 … … 683 1080 684 1081 return ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); 1082 685 1083 } 686 1084 … … 703 1101 704 1102 return @whole; 1103 1104 } 1105 1106 # 1107 # Convert unix path to mac style. 1108 # 1109 sub unix_to_mac { 1110 my ($path) = @_; 1111 my @path_elements = split ("/", $path); 1112 my $rv = ""; 1113 my $i; 1114 1115 foreach $i (0 .. $#path_elements) { 1116 if ($path_elements[$i] eq ".") { 1117 if (!($rv =~ /\:$/)) { 1118 $rv .= ":"; 1119 } 1120 } elsif ($path_elements[$i] eq "..") { 1121 if (!($rv =~ /\:$/)) { 1122 $rv .= "::"; 1123 } else { 1124 $rv .= ":"; 1125 } 1126 } elsif ($path_elements[$i] ne "") { 1127 $rv .= $path_elements[$i] . ":"; 1128 } 1129 1130 } 1131 1132 $rv =~ s/\:$//; 1133 1134 return $rv; 705 1135 } 706 1136 … … 734 1164 my ($path) = @_; 735 1165 736 if ($os_type eq "WIN") { 1166 if ($os_type eq "MAC") { 1167 return &unix_to_mac($path); 1168 } elsif($os_type eq "WIN") { 737 1169 return &unix_to_win($path); 738 1170 } else { … … 749 1181 750 1182 while (@a && @b) { 751 752 1183 my $a = shift @a; 1184 my $b = shift @b; 753 1185 return $a <=> $b if $a =~ /^\d/ && $b =~ /^\d/ && $a != $b; 754 1186 return $a cmp $b if $a ne $b; … … 765 1197 my @subdirs; 766 1198 767 if (!($dir =~ /\/$/)) { 768 $dir = $dir . "/"; 1199 if ($os_type ne "MAC") { 1200 if (!($dir =~ /\/$/)) { 1201 $dir = $dir . "/"; 1202 } 1203 } else { 1204 if (!($dir =~ /\:$/)) { 1205 $dir = $dir . ":"; 1206 } 769 1207 } 770 1208 opendir (DIR, $dir) || die ("couldn't open directory $dir: $!"); … … 855 1293 856 1294 sub dd { 1295 857 1296 if ($opt_trace) { 858 1297 print ("-*- ", @_ , "\n"); 859 1298 } 1299 860 1300 } 861 1301 862 1302 sub status { 1303 863 1304 print ("-#- ", @_ , "\n"); 1305 864 1306 } 865 1307 … … 878 1320 $user_exit = 1; 879 1321 } 880 } 1322 1323 }
Note:
See TracChangeset
for help on using the changeset viewer.