#!/usr/bin/perl

use strict;

sub nvl { defined $ENV{$_[0]} ? $ENV{$_[0]} : $_[1] }

print STDERR<<"EOF";

##
## WARNING: Almost all the tests in this module distribution need to connect
## to a database in order to run.  The tests need full privileges on this
## database: the ability to create and drop tables, insert, update, and delete
## rows, create schemeas, sequences, functions, triggers, the works.
## 
## By default, the tests will try to connect to the database named "test"
## running on "localhost" using the default superuser username for each
## database type and an empty password.
## 
## If you have setup your database in a secure manner, these connection
## attempts will fail, and the tests will be skipped.  If you want to override
## these values, set the following environment variables before running tests.
## (The current values are shown in parentheses.)
## 
## Postgres:
## 
##     RDBO_PG_DSN      (@{[ nvl('RDBO_PG_DSN', 'dbi:Pg:dbname=test;host=localhost') ]})
##     RDBO_PG_USER     (@{[ nvl('RDBO_PG_USER', 'postgres') ]})
##     RDBO_PG_PASS     (@{[ nvl('RDBO_PG_PASS', '<none>') ]})
## 
## MySQL:
## 
##     RDBO_MYSQL_DSN   (@{[ nvl('RDBO_MYSQL_DSN', 'dbi:mysql:database=test;host=localhost') ]})
##     RDBO_MYSQL_USER  (@{[ nvl('RDBO_MYSQL_USER', 'root') ]})
##     RDBO_MYSQL_PASS  (@{[ nvl('RDBO_MYSQL_PASS', '<none>') ]})
##
## Informix:
## 
##     RDBO_INFORMIX_DSN   (@{[ nvl('RDBO_INFORMIX_DSN', 'dbi:Informix:test@test') ]})
##     RDBO_INFORMIX_USER  (@{[ nvl('RDBO_INFORMIX_USER', '<none>') ]})
##     RDBO_INFORMIX_PASS  (@{[ nvl('RDBO_INFORMIX_PASS', '<none>') ]})
## 
## Press return to continue (or wait 60 seconds)
EOF

my %old;

$old{'ALRM'} = $SIG{'ALRM'} || 'DEFAULT';

eval
{
  # Localize so I only have to restore in my catch block
  local $SIG{'ALRM'} = sub { die 'alarm' };
  alarm(60);
  my $res = <STDIN>;
  alarm(0);
};

if($@ =~ /alarm/)
{
  $SIG{'ALRM'} = $old{'ALRM'};
}    

print "1..1\n",
      "ok 1\n";

1;
