X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=dev%2Fi386%2Flibhtml-parser-perl%2Flibhtml-parser-perl-3.56%2Ft%2Fcrashme.t;fp=dev%2Fi386%2Flibhtml-parser-perl%2Flibhtml-parser-perl-3.56%2Ft%2Fcrashme.t;h=1a1e8e47c970a57890bfcc749c1c45571cc2c453;hb=8977e561d8a9eae6959218b0306c9df2056a38a9;hp=0000000000000000000000000000000000000000;hpb=df794b845212301ea0d267c919232538bfef356a;p=dh-make-perl diff --git a/dev/i386/libhtml-parser-perl/libhtml-parser-perl-3.56/t/crashme.t b/dev/i386/libhtml-parser-perl/libhtml-parser-perl-3.56/t/crashme.t new file mode 100644 index 0000000..1a1e8e4 --- /dev/null +++ b/dev/i386/libhtml-parser-perl/libhtml-parser-perl-3.56/t/crashme.t @@ -0,0 +1,43 @@ +#!/usr/bin/perl + +# This test will simply run the parser on random junk. + +my $no_tests = shift || 3; +use Test::More; +plan tests => $no_tests; + +use HTML::Parser (); + +my $file = "junk$$.html"; +die if -e $file; + +for (1..$no_tests) { + + open(JUNK, ">$file") || die; + for (1 .. rand(5000)) { + for (1 .. rand(200)) { + print JUNK pack("N", rand(2**32)); + } + print JUNK ("<", "&", ">")[rand(3)]; # make these a bit more likely + } + close(JUNK); + + #diag "Parse @{[-s $file]} bytes of junk"; + + HTML::Parser->new->parse_file($file); + pass(); + + #print_mem(); +} + +unlink($file); + + +sub print_mem +{ + # this probably only works on Linux + open(STAT, "/proc/self/status") || return; + while () { + diag $_ if /^VmSize/; + } +}