#!/usr/bin/perl -w

eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
    if 0; # not running under some shell

#
# this is the test script for rrdbrowse
# usage: rbtest dir/whatever.nfo
#
# $Id: rbtest,v 1.7 2003/03/30 22:15:27 tommy Exp $
#

package RRD;
use strict;
use Data::Dumper;
use Cwd qw(abs_path);
use RRD::Info;
use RRD::Config;

my $nf = $ARGV[0];
die "Usage: $0 <nfofile>\n" if ! $nf || $nf eq "-h";

# split path and filename
$nf =~ m/(.*\/)*([a-z0-9-_.]+\.nf.?)/g;
my $dir = abs_path($1 || './');
my $nfo = $2;

print "Testing $dir/$nfo\n";

my $info = new RRD::Info("$dir/$nfo");

print "Checking Paths..\n";
$info->CheckPaths;

print "Checking data retrieval..\n";
$info->Update;

print "Checking graph creation..\n";
$info->Graph;
$info->GraphThumb;

my $r = $info->{Function}->{LastRead};
if ( defined $r ) {
  print "Results from the update: ";
  print $info->{Function}->{LastRead};
  print "\nDone\n";
}else{
  print "No results were found, recheck your config!\n";
  print "Done, with errors\n";
}

