~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/randgen/unit/TestScripts.pm

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2009,2010 Oracle and/or its affiliates. All rights reserved.
 
2
# Use is subject to license terms.
 
3
#
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; version 2 of the License.
 
7
#
 
8
# This program is distributed in the hope that it will be useful, but
 
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
11
# General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 
16
# USA
 
17
 
 
18
# Do a simple run of scripts to see that they're sound
 
19
#
 
20
package TestScripts;
 
21
use base qw(Test::Unit::TestCase);
 
22
use lib 'lib';
 
23
use GenTest;
 
24
use Cwd;
 
25
 
 
26
sub new {
 
27
    my $self = shift()->SUPER::new(@_);
 
28
    # your state for fixture here
 
29
    return $self;
 
30
}
 
31
 
 
32
my $generator;
 
33
sub set_up {
 
34
}
 
35
 
 
36
sub tear_down {
 
37
    # clean up after test
 
38
}
 
39
 
 
40
sub test_gensql {
 
41
    my $self = shift;
 
42
 
 
43
    my $status = system("perl -MCarp=verbose gensql.pl --grammar=conf/examples/example.yy --dsn=dummy --queries=1");
 
44
 
 
45
    $self->assert_equals(0, $status);
 
46
 
 
47
    my $status = system("perl -MCarp=verbose gensql.pl --grammar=unit/testStack.yy --dsn=dummy --queries=5");
 
48
 
 
49
    $self->assert_equals(0, $status);
 
50
 
 
51
}
 
52
 
 
53
sub test_gendata {
 
54
    my $self = shift;
 
55
 
 
56
    my $status = system("perl -MCarp=verbose gendata.pl --spec=conf/examples/example.zz --dsn=dummy");
 
57
 
 
58
    $self->assert_equals(0, $status);
 
59
}
 
60
 
 
61
sub test_gendata_old {
 
62
    my $self = shift;
 
63
 
 
64
    my $status = system("perl -MCarp=verbose gendata-old.pl --dsn=dummy");
 
65
 
 
66
    $self->assert_equals(0, $status);
 
67
}
 
68
 
 
69
sub test_gentest {
 
70
    my $self = shift;
 
71
 
 
72
    my $status = system("perl -MCarp=verbose gentest.pl --dsn=dummy --grammar=conf/examples/example.yy --threads=1 --queries=1");
 
73
 
 
74
    $self->assert_equals(0, $status);
 
75
 
 
76
    $status = system("perl -MCarp=verbose gentest.pl --dsn=dummy --grammar=conf/examples/example.yy --threads=1 --queries=1 --mask=10 --mask-level=2");
 
77
 
 
78
    $self->assert_equals(0, $status);
 
79
}
 
80
 
 
81
sub test_runall {
 
82
    if ($ENV{TEST_OUT_OF_SOURCE}) {
 
83
        ## runall does not work with out of source builds
 
84
        say("test_runall skipped for out-of-source build");
 
85
        return;
 
86
    }
 
87
    my $portbase = $ENV{TEST_PORTBASE}>0?int($ENV{TEST_PORTBASE}):22120;
 
88
    my $pb = int(($portbase - 10000) / 10);
 
89
    my $self = shift;
 
90
    ## This test requires RQG_MYSQL_BASE to point to a in source Mysql database
 
91
    if ($ENV{RQG_MYSQL_BASE}) {
 
92
        $ENV{LD_LIBRARY_PATH}=join(":",map{"$ENV{RQG_MYSQL_BASE}".$_}("/libmysql/.libs","/libmysql","/lib/mysql"));
 
93
        my $status = system("perl -MCarp=verbose ./runall.pl --mtr-build-thread=$pb --grammar=conf/examples/example.yy --gendata=conf/examples/example.zz --queries=3 --threads=3 --basedir=".$ENV{RQG_MYSQL_BASE});
 
94
        $self->assert_equals(0, $status);
 
95
    }
 
96
}
 
97
 
 
98
sub test_runall_new {
 
99
    my $self = shift;
 
100
    ## This test requires RQG_MYSQL_BASE to point to a Mysql database (in source, out of source or installed)
 
101
    my $portbase = 10 + ($ENV{TEST_PORTBASE}>0?int($ENV{TEST_PORTBASE}):22120);
 
102
    my $pb = int(($portbase - 10000) / 10);
 
103
 
 
104
    
 
105
    if ($ENV{RQG_MYSQL_BASE}) {
 
106
        $ENV{LD_LIBRARY_PATH}=join(":",map{"$ENV{RQG_MYSQL_BASE}".$_}("/libmysql/.libs","/libmysql","/lib/mysql"));
 
107
        my $status = system("perl -MCarp=verbose ./runall-new.pl --mtr-build-thread=$pb --grammar=conf/examples/example.yy --gendata=conf/examples/example.zz --queries=3 --threads=3 --basedir=".$ENV{RQG_MYSQL_BASE}." --vardir=".cwd()."/unit/tmp");
 
108
        $self->assert_equals(0, $status);
 
109
    }
 
110
}
 
111
 
 
112
1;