1#!/usr/bin/perl
2
3use strict;
4
5sub nvl { defined $ENV{$_[0]} ? $ENV{$_[0]} : $_[1] }
6
7eval { require DBI };
8eval { require DBD::Pg };
9eval { require DBD::mysql };
10eval { require DBD::SQLite };
11eval { require DBD::Informix };
12eval { require DBD::Oracle };
13eval { require JSON };
14
15print STDERR "\n##\n";
16
17foreach my $pkg (qw(DBI DBD::Pg DBD::mysql DBD::SQLite DBD::Informix DBD::Oracle JSON))
18{
19  no strict 'refs';
20  if(defined(my $version = ${$pkg . '::VERSION'}))
21  {
22    print STDERR sprintf("## %-15s $version\n", $pkg);
23  }
24}
25
26print STDERR<<"EOF";
27##
28## WARNING: Almost all the tests in this module distribution need to connect
29## to a database in order to run.  The tests need full privileges on this
30## database: the ability to create and drop tables, insert, update, and delete
31## rows, create schemas, sequences, functions, triggers, the works.
32##
33## By default, the tests will try to connect to the database named "test"
34## running on "localhost" using the default superuser username for each
35## database type and an empty password.
36##
37## If you have setup your database in a secure manner, these connection
38## attempts will fail, and the tests will be skipped.  If you want to override
39## these values, set the following environment variables before running tests.
40## (The current values are shown in parentheses.)
41##
42## PostgreSQL:
43##
44##     RDBO_PG_DSN      (@{[ nvl('RDBO_PG_DSN', 'dbi:Pg:dbname=test;host=localhost') ]})
45##     RDBO_PG_USER     (@{[ nvl('RDBO_PG_USER', 'postgres') ]})
46##     RDBO_PG_PASS     (@{[ nvl('RDBO_PG_PASS', '<none>') ]})
47##
48## MySQL:
49##
50##     RDBO_MYSQL_DSN   (@{[ nvl('RDBO_MYSQL_DSN', 'dbi:mysql:database=test;host=localhost') ]})
51##     RDBO_MYSQL_USER  (@{[ nvl('RDBO_MYSQL_USER', 'root') ]})
52##     RDBO_MYSQL_PASS  (@{[ nvl('RDBO_MYSQL_PASS', '<none>') ]})
53##
54## Oracle:
55##
56##     RDBO_ORACLE_DSN  (@{[ nvl('RDBO_ORACLE_DSN', 'dbi:Oracle:dbname=test') ]})
57##     RDBO_ORACLE_USER (@{[ nvl('RDBO_ORACLE_USER', '<none>') ]})
58##     RDBO_ORACLE_PASS (@{[ nvl('RDBO_ORACLE_PASS', '<none>') ]})
59##
60## Informix:
61##
62##     RDBO_INFORMIX_DSN   (@{[ nvl('RDBO_INFORMIX_DSN', 'dbi:Informix:test@test') ]})
63##     RDBO_INFORMIX_USER  (@{[ nvl('RDBO_INFORMIX_USER', '<none>') ]})
64##     RDBO_INFORMIX_PASS  (@{[ nvl('RDBO_INFORMIX_PASS', '<none>') ]})
65##
66## SQLite: To disable the SQLite tests, set this environment varible
67##
68##     RDBO_NO_SQLITE  (@{[ nvl('RDBO_NO_SQLITE', '<undef>') ]})
69##
70## Press return to continue (or wait 60 seconds)
71EOF
72
73eval { require DBD::SQLite };
74
75(my $version = $DBD::SQLite::VERSION || 0) =~ s/_//g;
76
77if(!$@ && ($version < 1.11 || ($version >= 1.13 && $version < 1.1902)))
78{
79print STDERR<<"EOF";
80
81***
82*** WARNING: DBD::SQLite version $DBD::SQLite::VERSION detected.  Versions 1.13 and 1.14
83*** are known to have serious bugs that prevent the test suite from working
84*** correctly.  In particular:
85***
86***     http://rt.cpan.org/Public/Bug/Display.html?id=21472
87***
88*** The SQLite tests will be skipped.  Please install DBD::SQLite 1.12
89*** or version 1.19_02 or later.
90***
91*** Press return to continue (or wait 60 seconds)
92EOF
93}
94
95unless($ENV{'AUTOMATED_TESTING'} || $ENV{'PERL_MM_USE_DEFAULT'})
96{
97  my %old;
98
99  $old{'ALRM'} = $SIG{'ALRM'} || 'DEFAULT';
100
101  eval
102  {
103    # Localize so I only have to restore in my catch block
104    local $SIG{'ALRM'} = sub { die 'alarm' };
105    alarm(60);
106    my $res = <STDIN>;
107    alarm(0);
108  };
109
110  if($@ =~ /alarm/)
111  {
112    $SIG{'ALRM'} = $old{'ALRM'};
113  }
114}
115
116print "1..1\n",
117      "ok 1\n";
118
1191;
120