Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libhtml-parser-perl / libhtml-parser-perl-3.56 / t / crashme.t
1 #!/usr/bin/perl
2
3 # This test will simply run the parser on random junk.
4
5 my $no_tests = shift || 3;
6 use Test::More;
7 plan tests => $no_tests;
8
9 use HTML::Parser ();
10
11 my $file = "junk$$.html";
12 die if -e $file;
13
14 for (1..$no_tests) {
15
16     open(JUNK, ">$file") || die;
17     for (1 .. rand(5000)) {
18         for (1 .. rand(200)) {
19             print JUNK pack("N", rand(2**32));
20         }
21         print JUNK ("<", "&", ">")[rand(3)];  # make these a bit more likely
22     }
23     close(JUNK);
24
25     #diag "Parse @{[-s $file]} bytes of junk";
26
27     HTML::Parser->new->parse_file($file);
28     pass();
29
30     #print_mem();
31 }
32
33 unlink($file);
34
35
36 sub print_mem
37 {
38     # this probably only works on Linux
39     open(STAT, "/proc/self/status") || return;
40     while (<STAT>) {
41         diag $_ if /^VmSize/;
42     }
43 }