#!/usr/local/bin/perl
use
vars
qw($test_dsn $test_user $test_password $mdriver $dbdriver)
;
$DBI::errstr
=
''
;
$mdriver
=
""
;
my
$file
;
foreach
$file
(
"lib.pl"
,
"t/lib.pl"
) {
do
$file
;
if
($@) {
print
STDERR
"Error while executing lib.pl: $@\n"
;
exit
10;
}
if
(
$mdriver
ne
''
) {
last
;
}
}
sub
ServerError() {
print
STDERR (
"Cannot connect: "
,
$DBI::errstr
,
"\n"
,
"\tEither your server is not up and running or you have no\n"
,
"\tpermissions for acessing the DSN $test_dsn.\n"
,
"\tThis test requires a running server and write permissions.\n"
,
"\tPlease make sure your server is running and you have\n"
,
"\tpermissions, then retry.\n"
);
exit
10;
}
while
(Testing()) {
my
$dbh
;
Test(
$state
or
$dbh
= DBI->
connect
(
$test_dsn
,
$test_user
,
$test_password
))
or ServerError();
my
$table
;
Test(
$state
or
$table
= FindNewTable(
$dbh
))
or DbiError(
$dbh
->err,
$dbh
->errstr);
my
$def
;
Test(
$state
or (
$def
= TableDefinition(
$table
,
[
"id"
,
"INTEGER"
, 4, 0],
[
"name"
,
"CHAR"
, 64, 0]),
$dbh
->
do
(
$def
)))
or DbiError(
$dbh
->err,
$dbh
->errstr);
Test(
$state
or
$dbh
->
do
(
"DROP TABLE $table"
))
or DbiError(
$dbh
->err,
$dbh
->errstr);
Test(
$state
or
$dbh
->disconnect())
or DbiError(
$dbh
->err,
$dbh
->errstr);
}