Changeset 27033 in webkit for trunk/JavaScriptCore/tests
- Timestamp:
- Oct 25, 2007, 2:59:10 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/tests/mozilla/jsDriver.pl
r11962 r27033 41 41 42 42 my $os_type = &get_os_type; 43 my $unixish = ( ($os_type ne "WIN") && ($os_type ne "MAC"));44 my $path_sep = ($os_type eq "MAC") ? ":" : "/";43 my $unixish = ($os_type ne "WIN"); 44 my $path_sep = "/"; # This script uses unix paths internally and converts to native when needed 45 45 my $win_sep = ($os_type eq "WIN")? &get_win_sep : ""; 46 my $redirect_command = ($os_type ne "MAC") ? " 2>&1" : "";46 my $redirect_command = " 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_classpath = ""; 52 my $opt_rhino_opt = 0; 53 my $opt_rhino_ms = 0; 54 my @opt_engine_list; 55 my $opt_engine_type = ""; 51 my $opt_engine_type = "kjs"; 56 52 my $opt_engine_params = ""; 57 53 my $opt_user_output_file = 0; … … 64 60 my $opt_console_failures = 0; 65 61 my $opt_lxr_url = "./"; # "http://lxr.mozilla.org/mozilla/source/js/tests/"; 66 my $opt_exit_munge = ($os_type ne "MAC") ? 1 : 0;67 62 68 63 # command line option definition … … 72 67 "x noexitmunge>x"; 73 68 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 } 69 $opt_suite_path = "./"; 81 70 82 71 &parse_args; … … 108 97 my $start_time; 109 98 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 } 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; 146 130 } 147 131 … … 202 186 @output = grep (!/js\>/, @output); 203 187 204 if ($opt_exit_munge == 1) {205 188 # signal information in the lower 8 bits, exit code above that 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 } 189 $got_exit = ($? >> 8); 190 $exit_signal = ($? & 255); 213 191 214 192 $failure_lines = ""; … … 217 195 218 196 foreach $line (@output) { 219 220 197 # watch for testcase to proclaim what exit code it expects to 221 198 # produce (0 by default) … … 378 355 $opt_bug_url = $value; 379 356 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") { 357 }elsif ($option eq "f") { 389 358 if (!$value) { 390 359 die ("Output file cannot be null.\n"); … … 424 393 } elsif ($option eq "p") { 425 394 $opt_suite_path = $value; 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 } 395 if (!($opt_suite_path =~ /[\/\\]$/)) { 396 $opt_suite_path .= "/"; 435 397 } 436 398 … … 450 412 $opt_lxr_url = $value; 451 413 452 } elsif ($option eq "x") {453 &dd ("opt: turning off exit munging.");454 $opt_exit_munge = 0;455 456 414 } else { 457 415 &usage; … … 459 417 460 418 $lastopt = $option; 461 462 419 } 463 420 464 421 Getopt::Mixed::cleanup(); 465 466 if ($#opt_engine_list == -1) {467 die "You must select a shell to test in.\n";468 }469 470 422 } 471 423 … … 478 430 "(-b|--bugurl) Bugzilla URL.\n" . 479 431 " (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" .485 432 "(-f|--file) <file> Redirect output to file named <file>.\n" . 486 433 " (default is " . … … 512 459 my $retval; 513 460 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") { 461 if ($opt_engine_type eq "kjs") { 557 462 &dd ("getting kjs engine command."); 558 463 $retval = &get_kjs_engine_command; 559 560 464 } else { 561 465 die ("Unknown engine type selected, '$opt_engine_type'.\n"); … … 567 471 568 472 return $retval; 569 570 }571 572 #573 # get the shell command used to run rhino574 #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 xpcshell600 #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 correctly628 die ($retval . " is not a valid executable on this system.\n");629 }630 631 return $retval;632 633 473 } 634 474 … … 648 488 } 649 489 650 #651 # get the shell command used to run spidermonkey652 #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 the658 # 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 matching679 # the pattern expected to hold this type (debug or opt) of engine680 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.ref695 # (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't697 # 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 mac720 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 correctly728 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 epimetheus737 #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 correctly788 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 shell796 #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 mac836 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 correctly844 die ("$retval is not a valid executable on this system.\n");845 }846 847 return $retval;848 849 }850 851 490 sub get_os_type { 852 853 if ("\n" eq "\015") {854 return "MAC";855 }856 857 491 my $uname = `uname -a`; 858 492 … … 865 499 &dd ("get_os_type returning '$uname'."); 866 500 return $uname; 867 868 501 } 869 502 … … 905 538 &dd ((($#neg_list + 1) - $actually_skipped) . " skip tests were " . 906 539 "not actually part of the test list."); 907 908 909 540 } 910 541 911 542 return @test_list; 912 913 543 } 914 544 … … 922 552 my @retval = (); 923 553 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 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 # 937 557 if ($list_file =~ /\.js$/ || -d $opt_suite_path . $list_file) { 938 939 558 push (@retval, &expand_test_list_entry($list_file)); 940 941 } else { 942 559 } else { 943 560 open (TESTLIST, $list_file) || 944 561 die("Error opening test list file '$list_file': $!\n"); … … 953 570 954 571 close (TESTLIST); 955 956 572 } 957 573 958 574 return @retval; 959 960 575 } 961 576 … … 1016 631 1017 632 return @retval; 1018 1019 633 } 1020 634 … … 1046 660 1047 661 return @retval; 1048 1049 662 } 1050 663 … … 1055 668 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = 1056 669 &get_padded_time (localtime); 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"; 670 return "res-" . $year . $mon . $mday . $hour . $min . $sec . "-" . $opt_engine_type . ".html"; 1068 671 } 1069 672 … … 1080 683 1081 684 return ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); 1082 1083 685 } 1084 686 … … 1101 703 1102 704 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;1135 705 } 1136 706 … … 1164 734 my ($path) = @_; 1165 735 1166 if ($os_type eq "MAC") { 1167 return &unix_to_mac($path); 1168 } elsif($os_type eq "WIN") { 736 if ($os_type eq "WIN") { 1169 737 return &unix_to_win($path); 1170 738 } else { … … 1181 749 1182 750 while (@a && @b) { 1183 1184 751 my $a = shift @a; 752 my $b = shift @b; 1185 753 return $a <=> $b if $a =~ /^\d/ && $b =~ /^\d/ && $a != $b; 1186 754 return $a cmp $b if $a ne $b; … … 1197 765 my @subdirs; 1198 766 1199 if ($os_type ne "MAC") { 1200 if (!($dir =~ /\/$/)) { 1201 $dir = $dir . "/"; 1202 } 1203 } else { 1204 if (!($dir =~ /\:$/)) { 1205 $dir = $dir . ":"; 1206 } 767 if (!($dir =~ /\/$/)) { 768 $dir = $dir . "/"; 1207 769 } 1208 770 opendir (DIR, $dir) || die ("couldn't open directory $dir: $!"); … … 1293 855 1294 856 sub dd { 1295 1296 857 if ($opt_trace) { 1297 858 print ("-*- ", @_ , "\n"); 1298 859 } 1299 1300 860 } 1301 861 1302 862 sub status { 1303 1304 863 print ("-#- ", @_ , "\n"); 1305 1306 864 } 1307 865 … … 1320 878 $user_exit = 1; 1321 879 } 1322 1323 } 880 }
Note:
See TracChangeset
for help on using the changeset viewer.