return $ENV{'OSSTEST_FLIGHT'};
}
+sub _check_testdbs ($) {
+ my ($dbh) = @_;
+
+ my $re = $ENV{OSSTEST_DB_USEREAL_IGNORETEST} // '';
+ return if $re eq '.*'; # needed by mg-schema-test-database during setup
+
+ # mg-schema-test-database creates a task
+ # xdbref/DBNAME with username ${Username}@NODENAME
+ my $sth = $dbh->prepare(<<END);
+ SELECT refkey AS dbname,
+ username, comment
+ FROM tasks
+ WHERE type = 'xdbref'
+ AND live
+ AND username LIKE (? || '@%')
+END
+ $sth->execute($c{Username});
+ my $allok = 1;
+ while (my $row = $sth->fetchrow_hashref()) {
+ next if $row->{dbname} =~ m/^$re$/o;
+ $allok = 0;
+ print STDERR <<END;
+Test DB exists: $row->{dbname} ($row->{username}, "$row->{comment}")
+END
+ }
+ die "Test dbs exist. Set OSSTEST_DB_USEREAL_IGNORETEST to regexp ?\n"
+ unless $allok;
+}
+
sub open ($) { #method
- return opendb('osstestdb');
+ my $dbh = opendb('osstestdb');
+ _check_testdbs($dbh);
+ return $dbh;
}
sub dbfl_check ($$) { #method