issue95.t 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=95
  3. # IO::Socket::blocking method found in \@ISA
  4. # methods not found. see t/testc.sh -DCsP,-v -O0 95
  5. use strict;
  6. BEGIN {
  7. unshift @INC, 't';
  8. require TestBC;
  9. }
  10. use Test::More;
  11. use Config;
  12. eval "use IO::Socket::SSL";
  13. if ($@) {
  14. plan skip_all => "IO::Socket::SSL required for testing issue95" ;
  15. } else {
  16. plan tests => 5;
  17. }
  18. my $issue = <<'EOF';
  19. use IO::Socket::INET ();
  20. use IO::Socket::SSL ('inet4');
  21. use Net::SSLeay ();
  22. use IO ();
  23. use Socket ();
  24. my $handle = IO::Socket::SSL->new(SSL_verify_mode =>0);
  25. $handle->blocking(0);
  26. print "ok";
  27. EOF
  28. my $typed = <<'EOF';
  29. use IO::Socket::SSL();
  30. my IO::Handle $handle = IO::Socket::SSL->new(SSL_verify_mode =>0);
  31. $handle->blocking(0);
  32. print "ok";
  33. EOF
  34. my $ITHREADS = $Config{useithreads};
  35. sub diagv {
  36. diag @_ if $ENV{TEST_VERBOSE};
  37. }
  38. sub compile_check {
  39. my ($num,$b,$base,$script,$cmt) = @_;
  40. my $name = $base."_$num";
  41. unlink("$name.c", "$name.pl");
  42. open F, ">", "$name.pl";
  43. print F $script;
  44. close F;
  45. my $X = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
  46. $b .= ',-DCsp,-v';
  47. diagv "$X -Iblib/arch -Iblib/lib -MO=$b,-o$name.c $name.pl";
  48. my ($result,$out,$stderr) =
  49. run_cmd("$X -Iblib/arch -Iblib/lib -MO=$b,-o$name.c $name.pl", 20);
  50. unless (-e "$name.c") {
  51. print "not ok $num # $name B::$b failed\n";
  52. exit;
  53. }
  54. # check stderr for "blocking not found"
  55. #diag length $stderr," ",length $out;
  56. if (!$stderr and $out) {
  57. $stderr = $out;
  58. }
  59. my $notfound = $stderr =~ /blocking not found/;
  60. ok(!$notfound, $cmt.', no "blocking not found" warning');
  61. # check stderr for "save package_pv "blocking" for method_name"
  62. my $found = $stderr =~ /save package_pv "blocking" for method_name/;
  63. if ($found) {
  64. $found = $stderr !~ /save method_name "IO::Socket::blocking"/;
  65. }
  66. $cmt = "TODO" if $] >= 5.022 and $Config{useithreads};
  67. ok(!$found, $cmt.', blocking as method_name saved');
  68. }
  69. compile_check(1,'C,-O3,-UB','ccode95i',$issue,"untyped");
  70. compile_check(2,'C,-O3,-UB','ccode95i',$typed,'typed');
  71. use B::C ();
  72. # see #310: Warning: unable to close filehandle DATA properly
  73. # also: Constant subroutine HUGE_VAL redefined (5.16.3, 5.16.3-nt) #367
  74. my $qr = '^(ok|Warning: unable to close filehandle.*\nok|Constant subroutine HUGE_VAL redefined.*\nok)$';
  75. my $todo = ($B::C::VERSION lt '1.42_61') ? "TODO" : "";
  76. # bad: 1.956 - 1.984
  77. if ($IO::Socket::SSL::VERSION ge '1.956' and $IO::Socket::SSL::VERSION lt '1.984') {
  78. $todo = "TODO [cpan #95452] bad IO::Socket::SSL $IO::Socket::SSL::VERSION, ";
  79. }
  80. $todo = "TODO 5.18 \#356" if $] >= 5.018; # double free or corruption
  81. $todo = "TODO <5.8.8" if $] < 5.008008;
  82. ctest(5,$qr,'C,-O3','ccode95i',$issue, $todo.' run');