xref: /openbsd/regress/sys/kern/sosplice/tcp/direct.pl (revision 771fbea0)
1#!/usr/bin/perl
2#	$OpenBSD: direct.pl,v 1.3 2017/10/27 16:59:14 bluhm Exp $
3
4# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
5#
6# Permission to use, copy, modify, and distribute this software for any
7# purpose with or without fee is hereby granted, provided that the above
8# copyright notice and this permission notice appear in all copies.
9#
10# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
18use strict;
19use warnings;
20use Socket;
21use Socket6;
22
23use Client;
24use Server;
25require 'funcs.pl';
26
27sub usage {
28	die "usage: direct.pl [args-test.pl]\n";
29}
30
31my $testfile;
32our %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();
39
40my $s = Server->new(
41    func		=> \&read_stream,
42    %{$args{server}},
43    listendomain	=> AF_INET,
44    listenaddr		=> "127.0.0.1",
45);
46my $c = Client->new(
47    func		=> \&write_stream,
48    %{$args{client}},
49    connectdomain	=> AF_INET,
50    connectaddr		=> "127.0.0.1",
51    connectport		=> $s->{listenport},
52);
53
54$s->run;
55$c->run->up;
56$s->up;
57
58$c->down;
59$s->down;
60
61check_logs($c, undef, $s, %args);
62