~ubuntu-branches/ubuntu/precise/libdbd-firebird-perl/precise-updates

« back to all changes in this revision

Viewing changes to t/60-leaks.t

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2011-09-27 23:27:43 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110927232743-hyokctw5d6eajck2
Tags: 0.70-1
* New upstream release
 + documentation cleanup
 + support of Perl Unicode via ib_enable_utf8 attribute
 + fix $dbh->do() and $sth->execute() to properly return the number of
   affected records

* add a patch from upstream Git appending $Config{ccflags} to CCFLAGS
  (Closes: #643038 -- FTBFS with perl 5.14: CCFLAGS should include
  $Config{ccflags})
* add -classic alternatives to firebird server B-D
* add a patch from upstream fixing skipping of tests
* add libtest-exception-perl to B-D

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/local/bin/perl
2
2
#
3
 
#   $Id: 60leaks.t 291 2003-05-20 02:43:57Z edpratomo $
4
3
#
5
4
#   This is a memory leak test.
6
5
#
8
7
use strict;
9
8
use warnings;
10
9
 
11
 
print "1..0 # Skipped: Long running memory leak test\n" and exit 0
12
 
  unless ( $^O eq 'linux' && $ENV{MEMORY_TEST} );
13
 
 
14
10
my $COUNT_CONNECT = 500;    # Number of connect/disconnect iterations
15
11
my $COUNT_PREPARE = 10000;  # Number of prepare/execute/finish iterations
16
12
my $TOTALMEM      = 0;
18
14
use Test::More;
19
15
use DBI;
20
16
 
 
17
plan skip_all => "Long memory leak test (try with MEMORY_TEST on linux)\n"
 
18
  unless ( $^O eq 'linux' && $ENV{MEMORY_TEST} );
 
19
 
 
20
 
21
21
use lib 't','.';
22
22
 
23
23
require 'tests-setup.pl';
32
32
    plan skip_all => 'Connection to database failed, cannot continue testing';
33
33
}
34
34
else {
35
 
    plan tests => 315;
 
35
    plan tests => 314;
36
36
}
37
37
 
38
38
ok($dbh, 'Connected to the database');
61
61
#- Testing memory leaks in connect / disconnect
62
62
 
63
63
$ok = 0;
 
64
my $nok = 0;
64
65
for (my $i = 0;  $i < $COUNT_CONNECT;  $i++) {
65
66
    my ($dbh2, $error_str2) = connect_to_database();
66
67
    if ($error_str2) {
76
77
    }
77
78
    elsif ($i % 100  ==  99) {
78
79
        $ok = check_mem();
 
80
        $nok++ unless $ok;
79
81
        ok($ok, "c/d $i");
80
82
    }
81
83
}
82
 
ok($ok > 0, "Memory leak test in connect/disconnect");
 
84
ok($nok == 0, "Memory leak test in connect/disconnect");
83
85
 
84
86
#- Testing memory leaks in prepare / execute / finish
85
87
 
89
91
    ok($dbh, 'reConnected to the database');
90
92
}
91
93
 
92
 
$ok = 0;
 
94
$ok = 0; $nok = 0;
93
95
for (my $i = 0;  $i < $COUNT_PREPARE;  $i++) {
94
96
    my $sth = $dbh->prepare("SELECT * FROM $table");
95
97
    $sth->execute();
98
100
 
99
101
    if ($i % 100  ==  99) {
100
102
        $ok = check_mem();
 
103
        $nok++ unless $ok;
101
104
        ok($ok, "p/e/f $i");
102
105
    }
103
106
}
104
 
ok($ok > 0, "Memory leak test in prepare/execute/finish");
 
107
ok($nok == 0, "Memory leak test in prepare/execute/finish");
105
108
 
106
109
# Testing memory leaks in fetchrow_arrayref
107
110
 
118
121
                         $row->[0], $dbh->quote($row->[1])));
119
122
}
120
123
 
121
 
$ok = 0;
 
124
$ok = 0; $nok =0;
122
125
for ( my $i = 0 ; $i < $COUNT_PREPARE ; $i++ ) {
123
126
    {
124
127
        my $sth = $dbh->prepare("SELECT * FROM $table");
130
133
 
131
134
    if ( $i % 100 == 99 ) {
132
135
        $ok = check_mem();
 
136
        $nok++ unless $ok;
133
137
        ok($ok, "f_a $i");
134
138
    }
135
139
}
136
 
ok($ok > 0, "Memory leak test in fetchrow_arrayref");
 
140
ok($nok == 0, "Memory leak test in fetchrow_arrayref");
137
141
 
138
142
# Testing memory leaks in fetchrow_hashref
139
143
 
140
 
$ok = 0;
 
144
$ok = 0; $nok = 0;
141
145
for (my $i = 0;  $i < $COUNT_PREPARE;  $i++) {
142
146
    {
143
147
        my $sth = $dbh->prepare("SELECT * FROM $table");
149
153
 
150
154
    if ($i % 100  ==  99) {
151
155
        $ok = check_mem();
 
156
        $nok++ unless $ok;
152
157
        ok($ok, "f_h $i");
153
158
    }
154
159
}
155
 
ok($ok > 0, "Memory leak test in fetchrow_hashref");
 
160
ok($nok == 0, "Memory leak test in fetchrow_hashref");
156
161
 
157
162
#
158
163
#   ... and drop it.