diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-09-28 08:10:19 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-09-28 08:10:19 +0000 |
commit | de70f8d4a8bae3f91dbb52a3cc38541afbb55e2a (patch) | |
tree | bc5538c830c385894ce7905eb90a99e67226b97c /regress | |
parent | 22e3197cbdc2d95bcbdaabe8bddf066b1982f29a (diff) |
I wrote a perfect regress test: a test that never fails. Correctly
populate the die() from code within eval to make failed tests fail.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/usr.sbin/switchd/run.pl | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/regress/usr.sbin/switchd/run.pl b/regress/usr.sbin/switchd/run.pl index 24f7b8d9c2f..fe41e277ae4 100644 --- a/regress/usr.sbin/switchd/run.pl +++ b/regress/usr.sbin/switchd/run.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $OpenBSD: run.pl,v 1.1 2016/07/19 17:04:19 reyk Exp $ +# $OpenBSD: run.pl,v 1.2 2016/09/28 08:10:18 reyk Exp $ # Copyright (c) 2016 Reyk Floeter <reyk@openbsd.org> # @@ -44,6 +44,8 @@ sub ofp_debug { my $dir = shift; my $ofp = shift; + fatal("OFP", "empty response") if (!$ofp->{version}); + printf("OFP ".$dir." version %d type %d length %d xid %d\n", $ofp->{version}, $ofp->{type}, @@ -157,8 +159,7 @@ sub packet_send { NetPacket::Ethernet::ETH_TYPE_IP, $pkt); - return (main::ofp_packet_in($self, $self->{data})); - + return (main::ofp_packet_in($self, $self->{data})); } sub packet_decode { @@ -188,6 +189,7 @@ sub process { my ($filename, $dirs, $suffix) = fileparse($path, ".pm"); (my $func = $filename) =~ s/-/_/g; my $state; + local $@; print "- $filename\n"; @@ -196,6 +198,7 @@ sub process { eval { $state = $func->init($sock); }; + die if($@); return if not $state->{pcap}; @@ -210,6 +213,7 @@ sub process { eval { $func->next($state); }; + die if($@); } Net::Pcap::close($pcap_t); |