xref: /openbsd/regress/usr.sbin/ospfd/ospfd.pl (revision 73471bf0)
1#!/usr/bin/perl
2#	$OpenBSD: ospfd.pl,v 1.3 2014/08/18 22:58:19 bluhm Exp $
3
4# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
5# Copyright (c) 2014 Florian Riehm <mail@friehm.de>
6#
7# Permission to use, copy, modify, and distribute this software for any
8# purpose with or without fee is hereby granted, provided that the above
9# copyright notice and this permission notice appear in all copies.
10#
11# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
19use strict;
20use warnings;
21
22use Ospfd;
23use Client;
24use Hash::Merge 'merge';
25use Default '%default_args';
26
27sub usage {
28    die "usage: ospf.pl [test-args.pl]\n";
29}
30
31my $testfile;
32our %tst_args;
33if (@ARGV and -f $ARGV[-1]) {
34    $testfile = pop;
35    do $testfile
36	or die "Do test file $testfile failed: ", $@ || $!;
37}
38@ARGV == 0 or usage();
39my $args = merge(\%tst_args, \%default_args);
40
41my $ospfd = Ospfd->new(
42    %{$args->{ospfd}},
43);
44my $client = Client->new(
45    %{$args->{client}},
46);
47
48$ospfd->run;
49$ospfd->up;
50$client->run;
51$client->down;
52$ospfd->kill_child;
53$ospfd->down;
54