Ruby 1.8.2 (2004-06-29)
DBI 0.23
OCI 8 0.1.8 Pre 1
Windows XP Pro
We're trying to test some data in our database to verify that our triggers do what we expect them to do. So, I wrote
up this test script, but it segfaults.
"F...c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:441: [BUG] Segmentation fault
ruby 1.8.2 (2004-06-29) [i386-mswin32]
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information."
Where line 441 is: @stmt.defineByPos(i, String, datasize * 3)
The actual number of rows for the sql in each method are as follows:
test_data_exists: 1
test_blah_and_baz_only: 1
test_link: 40
test_lport: 4438
test_group: 60
Here's the actual test script:
##############################################################################
# test_network_element.rb
#
# Test the network_element table. Specifically, we're checking to ensure
# that the network_element_type and network_element_name are set properly
# based on other criterion.
##############################################################################
require "dbi"
require "dbi/dbrc"
require "test/unit"
include DBI
class TC_Network_Element < Test::Unit::TestCase
def setup
@dbrc = DBRC.new("foo","bar")
@dbh = DBI.connect(@dbrc.dsn, @dbrc.user, @dbrc.passwd)
@sth = nil # Placeholder for statement handles
end
# Ensure that we have 'TEST' records
def test_data_exists
err = "No TEST records found"
sql = "
select count(*) from network_element
where lower(network_element_type) = 'test'
"
@sth = @dbh.prepare(sql)
@sth.execute
assert_equal(true,@sth.fetch.first.to_i > 0,err)
end
# The network_element_name should only be set for a layer2_tech_type of
# ATM or Frame. Consequently, all the other network_element_names should
# be NULL or ' ' (a single space).
def test_atm_and_frame_only
err = "Found records beside ATM and Frame with network_element_name set"
sql = "
select count(*) from network_element
where layer2_tech_type not in ('ATM','Frame')
and (
network_element_name != ' '
or network_element_name is not null
)
"
@sth = @dbh.prepare(sql)
@sth.execute
assert_equal(0,@sth.fetch.first.to_i,err)
end
# Test the link name and type. Ignore 'Test'.
def test_link
link_re = /^sw=\w+?:slot=\d+?:pport=\d+?:group=\d+?:link=\d+/
sql = "
select * from network_element
where group_id > 0
and link_id > 0
and layer2_tech_type in ('ATM','Frame')
and network_element_type != 'Test'
"
@sth = @dbh.prepare(sql)
@sth.execute
while rec = @sth.fetch
ne_type = rec["NETWORK_ELEMENT_TYPE"]
assert_not_nil(link_re.match(rec["NETWORK_ELEMENT_NAME"]))
assert_equal('link',ne_type,"Wrong type: #{ne_type}")
end
end
# Test the lport name and type. Ignore 'Test'
def test_lport
name_re = /^sw=\w+?:slot=\d+?:pport=\d+?lport=\d+/
sql = "
select * from network_element
where group_id <= 0
and lport_id > 0
and layer2_tech_type in ('ATM','Frame')
and network_element_type != 'Test'
"
@sth = @dbh.prepare(sql)
@sth.execute
while rec = @sth.fetch
ne_type = rec["NETWORK_ELEMENT_TYPE"]
assert_equal('lport',ne_type,"Wrong type: #{ne_type}")
end
end
def test_group
name_re = /^sw=\w+?:slot=\d+?:pport=\d+?:group=\d+/
sql = "
select * from network_element
where group_id > 0
and link_id <= 0
and layer2_tech_type in ('ATM','Frame')
and network_element_type != 'Test'
"
@sth = @dbh.prepare(sql)
@sth.execute
while rec = @sth.fetch
ne_type = rec["NETWORK_ELEMENT_TYPE"]
assert_equal('group',ne_type,"Wrong type: #{ne_type}")
end
end
def teardown
@dbrc = nil
@sth.finish if @sth
@dbh.disconnect if @dbh.connected?
end
end
Any ideas?
Regards,
Dan |