DBD-EmpressNet
view release on metacpan or search on metacpan
#
# $Id: test.pl, Empress Software Inc., 0.45, Mon Jul 15 11:15:45 Canada/Eastern 1996
#
#BEGIN{unshift @INC, "../../lib", "./lib";}
use DBI "0.89";
use Sys::Hostname;
use Cwd;
if (open (fd, "/bin/bsh"))
{
$my_bourne_shell = "/bin/bsh";
}
elsif (open (fd, "/bin/sh"))
{
$my_bourne_shell = "/bin/sh";
}
else
{
die ("Can't find Bourne shell");
}
close fd;
printf "Bourne shell on this machine is $my_bourne_shell\n";
my $test_dbname = 'test_db';
my $conn_dbname = 'test_db';
my $test_tabname = 'test_table';
my $nconnect = 10; # no of times to loop in testing connect
my $ncreate = 10; # no of times to loop in testing create/drop table
my ($iconnect, $icreate);
$mspath = $ENV{MSPATH};
if ($mspath)
{
print "Using Empress Version located at $mspath\n";
}
else
{
print "MSPATH not set\n";
exit 1;
}
#----------------------------------------------------------------------
# Which version of DBD::Empress
#----------------------------------------------------------------------
$dsql = FALSE;
print ("Running tests in Network mode\n");
$host = hostname ();
$dir = cwd ();
$myuser = getpwuid $<;
system ("rm -rf config");
system ("mkdir config");
$conn_dbname = "SERVER=$host;Database=test_db;UID=$myuser;PWD=";
open (ODBC, ">config/srv.conf")
|| die ("open server config file failed");
print ODBC "EMPODBC_WORKINGDIR = $dir\n";
print ODBC "EMPODBC_PASSWDFILE = $dir/config/passwd\n";
print ODBC "EMPODBC_LOGFILE = $dir/odbc.log\n";
close ODBC;
open (PWORD, ">config/passwd");
print PWORD "$myuser";
print PWORD "::::::\n";
close PWORD;
$ENV {"MSODBCSRVCFGFILE"} = "$dir/config/srv.conf";
system ("$mspath/bin/empodbc", "-v1") != 256
or die ("System call to empodbc failed\nIs a server already running?");
# Now redirect errors to file
$stderr_file = "test.stderr.$$";
open (STDERR, ">$stderr_file") || die ("open STDERR output file $stderr_file failed");
# --------------------------------------------------------------------------
# TODO: This section is not generic!!!
# --------------------------------------------------------------------------
my $mkdbcmd = "$mspath/bin/empmkdb $test_dbname";
my $mktabcmd = "$mspath/bin/empcmd $test_dbname \"run from \'$test_dbname.schema\'\"";
my $mkdatacmd = "$mspath/bin/empcmd $test_dbname \"run from \'$test_dbname.data\'\"";
my $rmdbcmd = "rm -rf $test_dbname";
# --------------------------------------------------------------------------
# install the Empress driver
# --------------------------------------------------------------------------
print "Testing: DBI->install_driver( 'EmpressNet' ): ";
( $drh = DBI->install_driver( 'EmpressNet' ) )
and print( "ok\n" )
or die "not ok: $DBI::errstr\n";
# -----------------------------------------------------------------------
# set Empress low-level debugging. Set to 0 .. 4.
# -----------------------------------------------------------------------
DBI->internal->{DebugDispatch} = 0;
# --------------------------------------------------------------------------
# create the testing database
# --------------------------------------------------------------------------
# TODO: This section is not generic!!!
# remove the db if it exists
if ( -d $test_dbname ) {
print "Removing old database '$test_dbname'...";
$st = system ($rmdbcmd);
if ( -d $test_dbname ) {
print "failed... exiting.\n";
exit 1;
}
( run in 0.869 second using v1.01-cache-2.11-cpan-39bf76dae61 )