[PLUG] perl and testing
Larry Brigman
larry.brigman at gmail.com
Tue Mar 27 16:50:34 UTC 2007
On 3/27/07, Eric Wilhelm <scratchcomputing at gmail.com> wrote:
> # from Larry Brigman
> # on Tuesday 27 March 2007 09:07 am:
>
> >I am trying to do some process testing automation and was looking
> >to use Test::Simple or Test::More. I am driving this testing via
> > Net:Telnet and there are places in the code that if I time out I just
> > want to end which I do with die() but the Test:: module catches this
> > and just stops, no exit.
> >I have to kill it with a ctrl-C.
>
> Post a snippet of code that demonstrates the problem?
It seems to not allow exits after emulator_start and ok() catches the
die() mode of $telnet
on timeout.
#!/bin/sh
if [ ! -f utm_x86_bridge.env ] ; then
echo "Unable to source the test environment to continue running!"
exit 1
fi
source utm_x86_bridge.env
`perl -e 1 > /dev/null 2>&1` && eval 'exec perl -x $0 $*'
#!perl -l -w
#use strict;
use Test::Simple tests => 15;
use Cwd;
use File::Compare;
use Net::Telnet;
sub emulator_start() {
ok(chdir( $QEMU_PATH), 'path to emulator shell') or
diag('cannot change path to emulator, cannot continue');
ok(open($QEMU, $QEMU_SCRIPT), 'start emulator') or
diag('no emulator script to start, cannot continue');
$EMU_START = 1;
# now wait for things to startup
print "Sleeping, waiting for emulator/kernel/userspace startup\n";
sleep $EMU_STARTUP_TIME;
}
ok($telnet = new Net::Telnet( Timeout=>10, Prompt=>$prompt,Errmode=>'my_die'),
'loading telnet obj');
$telnet->input_log('test_dump.txt');
if ($ENV{UTM_TOP} eq "") {
die "No UTM environment. Cannot continue";
}
if ($ENV{UTM_TARGET} ne "586") {
die "This script is only functionaly for x86 targets.";
}
emulator_start;
session_login;
do_mount;
ns_env;
go_test_location;
load_test_list;
#test loops
for (@TESTS) {
my_chdir( $_ );
load_sim;
load_config("$_","$_.xml");
run_test("$_.tcl");
compare_output("$_.nam","$_.nam.validated");
go_test_location;
}
#end of tests
emulator_stop;
__END__
More information about the PLUG
mailing list