1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 22:28:47 -04:00

DBD-SQLite: added another comment to the busy test, and tweaked sleep/timeout to prevent it from failing under slower machines

This commit is contained in:
Kenichi Ishigaki 2009-08-15 09:54:24 +00:00
parent 411cd59e82
commit 692a7840b1

View file

@ -58,6 +58,17 @@ foreach my $call_func (@CALL_FUNCS) {
$dbh2->disconnect; $dbh2->disconnect;
undef($dbh2); undef($dbh2);
# NOTE: The second test is to see what happens if a lock is
# is released while waiting. When both parent and child are
# ready, the database is locked by the child. The parent
# starts waiting for a long enough time (apparently we need
# to wait much longer than we expected, as testers may use
# very slow (virtual) machines to test, but don't worry,
# it's only for the slowest environment). After a short sleep,
# the child commits and releases the lock. Eventually the parent
# notices that, and does the pended INSERT (hopefully before
# it is timed out). As both the parent and the child wait till
# both are ready, we don't need to sleep for a long time.
pipe(READER, WRITER); pipe(READER, WRITER);
my $pid = fork; my $pid = fork;
if (!defined($pid)) { if (!defined($pid)) {
@ -75,7 +86,7 @@ foreach my $call_func (@CALL_FUNCS) {
$dbh2->do("INSERT INTO Blah VALUES ( 3, 'Test3' )"); $dbh2->do("INSERT INTO Blah VALUES ( 3, 'Test3' )");
select WRITER; $| = 1; select STDOUT; select WRITER; $| = 1; select STDOUT;
print WRITER "Ready\n"; print WRITER "Ready\n";
sleep(5); sleep(2);
$dbh2->commit; $dbh2->commit;
$dbh2->disconnect; $dbh2->disconnect;
exit; exit;
@ -85,7 +96,7 @@ foreach my $call_func (@CALL_FUNCS) {
my $line = <READER>; my $line = <READER>;
chomp($line); chomp($line);
ok($line, "Ready"); ok($line, "Ready");
ok($dbh->$call_func(10000, 'busy_timeout')); ok($dbh->$call_func(100000, 'busy_timeout'));
ok($dbh->do("INSERT INTO Blah VALUES (4, 'Test4' )")); ok($dbh->do("INSERT INTO Blah VALUES (4, 'Test4' )"));
$dbh->commit; $dbh->commit;
wait; wait;