testcore.pl 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. # -*- cperl -*-
  2. # t/testcore.t - run the core testsuite with the compilers C, CC and ByteCode
  3. # Usage:
  4. # t/testcore.t -fail known failing tests only
  5. # t/testcore.t -c run C compiler tests only (also -bc or -cc)
  6. # t/testcore.t t/CORE/op/goto.t run this test only
  7. #
  8. # Prereq:
  9. # Copy your matching CORE t dirs into t/CORE.
  10. # For now we test qw(base comp lib op run)
  11. # Then fixup the @INC setters, and various require ./test.pl calls.
  12. #
  13. # perl -pi -e 's/^(\s*\@INC = )/# $1/' t/CORE/*/*.t
  14. # perl -pi -e "s|^(\s*)chdir 't' if -d|\$1chdir 't/CORE' if -d|" t/CORE/*/*.t
  15. # perl -pi -e "s|require './|use lib "CORE"; require '|" `grep -l "require './" t/CORE/*/*.t`
  16. #
  17. # See TESTS for recent results
  18. use Cwd;
  19. use File::Copy;
  20. BEGIN {
  21. unless (-d "t/CORE" or $ENV{NO_AUTHOR}) {
  22. print "1..0 #skip t/CORE missing. Read t/testcore.t how to setup.\n";
  23. exit 0;
  24. }
  25. unshift @INC, ("t");
  26. }
  27. require "test.pl";
  28. sub vcmd {
  29. my $cmd = join "", @_;
  30. print "#",$cmd,"\n";
  31. run_cmd($cmd, 120); # timeout 2min
  32. }
  33. my $dir = getcwd();
  34. #unlink ("t/perl", "t/CORE/perl", "t/CORE/test.pl", "t/CORE/harness");
  35. #symlink "t/perl", $^X;
  36. #symlink "t/CORE/perl", $^X;
  37. #symlink "t/CORE/test.pl", "t/test.pl" unless -e "t/CORE/test.pl";
  38. #symlink "t/CORE/harness", "t/test.pl" unless -e "t/CORE/harness";
  39. `ln -sf $^X t/perl`;
  40. `ln -sf $^X t/CORE/perl`;
  41. # CORE t/test.pl would be better, but this fails only on 2 tests
  42. -e "t/CORE/test.pl" or `ln -s $dir/t/test.pl t/CORE/test.pl`;
  43. -e "t/CORE/harness" or `ln -s test.pl t/CORE/harness`; # better than nothing
  44. #`ln -s $dir/t/test.pl harness`; # base/term
  45. #`ln -s $dir/t/test.pl TEST`; # cmd/mod 8
  46. my %ALLOW_PERL_OPTIONS;
  47. for (qw(
  48. comp/cpp.t
  49. run/runenv.t
  50. )) {
  51. $ALLOW_PERL_OPTIONS{"t/CORE/$_"} = 1;
  52. }
  53. my $SKIP =
  54. { "CC" =>
  55. { "t/CORE/op/bop.t" => "hangs",
  56. "t/CORE/op/die.t" => "hangs",
  57. },
  58. "C" =>
  59. { ($] >= 5.020 ? ("t/CORE/op/eval.t" => "hangs in endless recursion since 5.20") : ()),
  60. },
  61. };
  62. # for C only, tested with 5.21.3d-nt
  63. my @fail = map { "t/CORE/$_" }
  64. (#'comp/colon.t', # ok with 5.14, 5.18, failed since 5.20 (fixed with #372)
  65. 'comp/hints.t', # fails sv_magic assert with <= 5.14, ok since 5.16
  66. #'comp/package.t', # fails only with -O0
  67. #'comp/parser.t',# ok with 5.14, failed since 5.18, updated with 1.51_02
  68. #'comp/retainedlines.t',# ok with 5.14, failed since 5.18. fixed test
  69. 'io/layers.t',
  70. # eval workaround fails with perlcc even with 5.14
  71. #'op/array.t', # ok with 5.14, 5.18, 5.20, fails with 5.21 (push on glob deprecation)
  72. 'op/attrs.t', # test 32, perlcc issue #xxx: anon sub :method not stored
  73. 'op/bop.t', # ok with 5.14, fails since 5.18
  74. 'op/closure.t', # ok with 5.14, fails test 271 since 5.18
  75. 'op/do.t', # ok with 5.14, 5.18, fails since 5.20
  76. 'op/eval.t', # hangs since 5.20.0
  77. 'op/filetest.t',# ok with 5.14, fails since 5.18
  78. 'op/goto_xs.t',
  79. # S_unshare_hek_or_pvn assert with glob assign'ed free,
  80. # >=5.18 runtime SEGV at \IO SvAMAGIC(TEMP,ROK) in rv2gv at test 51, print {*x{IO}}
  81. 'op/gv.t',
  82. 'op/length.t', # ok with 5.14, fails since 5.18 (string overload #373)
  83. 'op/local.t', # ok with 5.14, fails test 269 since 5.18
  84. 'op/magic.t', # ok with 5.14, fails since 5.18
  85. 'op/method.t', # ok with 5.14, 5.18, 5.20, fails with 5.21
  86. 'op/misc.t',
  87. 'op/pwent.t', # ok with 5.14, 5.18, fails since 5.20
  88. 'op/regmesg.t',
  89. 'op/sort.t', # ok with 5.14, fails since 5.18
  90. 'op/sprintf.t', # ok with 5.14, 5.18, 5.20, fails with 5.21
  91. 'op/subst.t',
  92. 'op/substr.t',
  93. 'op/tie.t', # ok with 5.14, fails since 5.18
  94. 'op/universal.t',
  95. 'uni/cache.t', # ok with 5.14, fails since 5.18
  96. 'uni/chr.t', # ok with 5.14, 5.18, fails since 5.20
  97. # use encoding is deprecated: #354
  98. 'uni/tr_7jis.t', # fails with 5.14, ok with 5.20
  99. 'uni/tr_sjis.t', # fails with 5.14, ok with 5.20
  100. 'uni/greek.t',
  101. 'uni/latin2.t',
  102. 'uni/write.t',
  103. );
  104. my @tests = $ARGV[0] eq '-fail'
  105. ? @fail
  106. : ((@ARGV and $ARGV[0] !~ /^-/)
  107. ? @ARGV
  108. : <t/CORE/*/*.t>);
  109. shift if $ARGV[0] eq '-fail';
  110. my $Mblib = $^O eq 'MSWin32' ? '-Iblib\arch -Iblib\lib' : "-Iblib/arch -Iblib/lib";
  111. sub run_c {
  112. my ($t, $backend) = @_;
  113. chdir $dir;
  114. my $result = $t; $result =~ s/\.t$/-c.result/;
  115. $result =~ s/-c.result$/-cc.result/ if $backend eq 'CC';
  116. my $a = $result; $a =~ s/\.result$//;
  117. unlink ($a, "$a.c", "t/$a.c", "t/CORE/$a.c", $result);
  118. # perlcc 2.06 should now work also: omit unneeded B::Stash -u<> and fixed linking
  119. # see t/c_argv.t
  120. my $backopts = $backend eq 'C' ? "-qq,C,-O3" : "-qq,CC";
  121. #$backopts .= ",-fno-warnings" if $backend =~ /^C/ and $] >= 5.013005;
  122. #$backopts .= ",-fno-fold" if $backend =~ /^C/ and $] >= 5.013009;
  123. vcmd "$^X $Mblib -MO=$backopts,-o$a.c $t";
  124. # CORE often does BEGIN chdir "t", patched to chdir "t/CORE"
  125. chdir $dir;
  126. move ("t/$a.c", "$a.c") if -e "t/$a.c";
  127. move ("t/CORE/$a.c", "$a.c") if -e "t/CORE/$a.c";
  128. my $d = "";
  129. $d = "-DALLOW_PERL_OPTIONS" if $ALLOW_PERL_OPTIONS{$t};
  130. vcmd "$^X $Mblib script/cc_harness -q $d $a.c -o $a" if -e "$a.c";
  131. vcmd "./$a | tee $result" if -e "$a";
  132. prove ($a, $result, $i, $t, $backend);
  133. $i++;
  134. }
  135. sub prove {
  136. my ($a, $result, $i, $t, $backend) = @_;
  137. if ( -e "$a" and -s $result) {
  138. system(qq[prove -Q --exec cat $result || echo -n "n";echo "ok $i - $backend $t"]);
  139. } else {
  140. print "not ok $i - $backend $t\n";
  141. }
  142. }
  143. my @runtests = qw(C CC BC);
  144. if ($ARGV[0] and $ARGV[0] =~ /^-(c|cc|bc)$/i) {
  145. @runtests = ( uc(substr($ARGV[0],1) ) );
  146. }
  147. my $numtests = scalar @tests * scalar @runtests;
  148. my %runtests = map {$_ => 1} @runtests;
  149. print "1..", $numtests, "\n";
  150. my $i = 1;
  151. for my $t (@tests) {
  152. C:
  153. if ($runtests{C}) {
  154. (print "ok $i #skip $SKIP->{C}->{$t}\n" and goto CC)
  155. if exists $SKIP->{C}->{$t};
  156. run_c($t, "C");
  157. }
  158. CC:
  159. if ($runtests{CC}) {
  160. (print "ok $i #skip $SKIP->{CC}->{$t}\n" and goto BC)
  161. if exists $SKIP->{CC}->{$t};
  162. run_c($t, "CC");
  163. }
  164. BC:
  165. if ($runtests{BC}) {
  166. (print "ok $i #skip $SKIP->{BC}->{$t}\n" and next)
  167. if exists $SKIP->{BC}->{$t};
  168. my $backend = 'Bytecode';
  169. chdir $dir;
  170. $result = $t; $result =~ s/\.t$/-bc.result/;
  171. unlink ("b.plc", "t/b.plc", "t/CORE/b.plc", $result);
  172. vcmd "$^X $Mblib -MO=-qq,Bytecode,-H,-s,-ob.plc $t";
  173. chdir $dir;
  174. move ("t/b.plc", "b.plc") if -e "t/b.plc";
  175. move ("t/CORE/b.plc", "b.plc") if -e "t/CORE/b.plc";
  176. vcmd "$^X $Mblib b.plc > $result" if -e "b.plc";
  177. prove ("b.plc", $result, $i, $t, $backend);
  178. $i++;
  179. }
  180. }
  181. END {
  182. unlink ( "t/perl", "t/CORE/perl", "harness", "TEST" );
  183. unlink ("a","a.c","t/a.c","t/CORE/a.c","aa.c","aa","t/aa.c","t/CORE/aa.c","b.plc");
  184. }