All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit dc4c6486 authored by Christopher Alfeld's avatar Christopher Alfeld

Implement tb_compare, added dbh variable for database access.

parent f3e6e620
......@@ -172,7 +172,7 @@ potentially messing your own test up).
$pid, $eid - PID and EID of test experiment.
$test - Test name.
$dir - Directory containing test files.
$dbh - Handle to DB connection.
Other notes:
......
......@@ -21,6 +21,13 @@
# Syntax:
# tbstub <db> <pid> <eid> <testname> <testdir>
use DBI;
if ($#ARGV != 4) {
print STDERR "Do not run directly!\n";
exit(1);
}
($db,$pid,$eid,$test,$dir) = @ARGV;
# The status of the test.
......@@ -36,12 +43,16 @@ sub doexit {
exit(0);
};
$dbh = DBI->connect("DBI:mysql:database=$testdb;host=localhost") ||
die "Could not connect to DB.\n";
do {
package TEST;
$eid = $::eid;
$pid = $::pid;
$test = $::test;
$dir = $::dir;
$dbh = $::dbh;
sub tb_prerun {
my ($cmd,$exitcode) = @_;
......@@ -56,8 +67,31 @@ sub tb_prerun {
}
};
sub tb_compare {
print "tb_compare not yet implemented.\n";
# results is a reference to a list of list references. I.e.
# a list of lists. Each sublist is a list of column values and
# refers to a row.
my ($query,$results) = @_;
my $sth = $dbh->prepare($query);
$sth->execute;
my @row;
my $i;
my @result;
my $rowi = 0;
while (@row = $sth->fetchrow_array) {
@result = (@$results)[$rowi];
if ($#row != $#result) {
tb_fail("Row $rowi - Length of $#row != expected $#result.");
}
for ($i=0;$i<$#row;++$i) {
if ($row[$i] ne $result[$i]) {
tb_fail("$rowi/$i - Found $row[$i], expected $result[$i].\n");
}
}
$rowi++;
}
};
sub tb_run {
my ($cmd,$exitcode) = @_;
print "$cmd $pid $eid\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment