Commit 8b214a9a authored by Christopher Alfeld's avatar Christopher Alfeld
Browse files

Nice utility for constructing tb_compare parts of tests. It works like this.

Say I want to check the contents of the virt_lans table.  I run my
experiment through tbprerun, and manually inspect virt_lans to make
sure it's correct.  Then I do something like:

dbdump tbdb_calfeld 'select vname,delay,bandwidth,lossrate,member from virt_lans where pid="testbed" and eid="test"'

dbdump should output something like:

@result = (

which I copy and paste into my test script and put immediately under
it the command:

tb_compare("select vname,delay,bandwidth,lossrate,member from virt_lans" .
	" where pid=\"testbed\" and eid=\"test",\@result);
parent 228da8b4
#!/usr/bin/perl -w
# This scripts takes a DB and a select statement and dumps the
# results of the table in a format that can easily be inserted into
# atest script for use with tb_compare.
use DBI;
if ($#ARGV != 1) {
print STDERR "Syntax: $0 <db> <query>\n";
($db,$query) = @ARGV;
$dbh = DBI->connect("DBI:mysql:database=$db;host=localhost") ||
die "Could not connect to DB.\n";
$sth = $dbh->prepare($query);
print "\@result = (\n";
while (@row = $sth->fetchrow_array) {
print "[\"" . $row[0] . "\"";
foreach $element (@row[1..$#row]) {
print ",\"$element\""
print "\],\n";
print ");\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