summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2015-06-30 12:22:31 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2015-06-30 12:22:31 +0000
commit95cc56b9c3aa08e299a94a052663435c24eb1484 (patch)
tree3141f67eb04680ff87748692d39d1f84a5eb57a5
parent80d252a897910383dbba81611e33c0260703af2d (diff)
Add tests for syslog -U.
-rw-r--r--regress/usr.sbin/syslogd/args-client-bind-only4.pl35
-rw-r--r--regress/usr.sbin/syslogd/args-client-bind-only6.pl35
-rw-r--r--regress/usr.sbin/syslogd/args-client-bind-port.pl37
-rw-r--r--regress/usr.sbin/syslogd/args-client-bind.pl34
-rw-r--r--regress/usr.sbin/syslogd/args-client-bind4-port.pl33
-rw-r--r--regress/usr.sbin/syslogd/args-client-bind4.pl30
-rw-r--r--regress/usr.sbin/syslogd/args-client-bind6-port.pl33
-rw-r--r--regress/usr.sbin/syslogd/args-client-bind6.pl30
8 files changed, 267 insertions, 0 deletions
diff --git a/regress/usr.sbin/syslogd/args-client-bind-only4.pl b/regress/usr.sbin/syslogd/args-client-bind-only4.pl
new file mode 100644
index 00000000000..0dbdea939a9
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-client-bind-only4.pl
@@ -0,0 +1,35 @@
+# Syslog binds UDP socket to localhost with -4.
+# The client writes a message to a localhost IPv4 UDP socket.
+# The syslogd writes it into a file and through a pipe.
+# The syslogd passes it via UDP to the loghost.
+# The server receives the message on its UDP socket.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that the file log contains the 127.0.0.1 name.
+# Check that fstat contains a only bound IPv4 UDP socket.
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ connect => { domain => AF_INET, addr => "127.0.0.1", port => 514 },
+ },
+ syslogd => {
+ options => ["-4nU", "localhost"],
+ fstat => {
+ qr/^root .* internet/ => 0,
+ qr/^_syslogd .* internet/ => 2,
+ qr/ internet dgram udp 127.0.0.1:514$/ => 1,
+ qr/ internet6 dgram udp \[::1\]:514$/ => 0,
+ },
+ loghost => '@127.0.0.1:$connectport',
+ },
+ server => {
+ listen => { domain => AF_INET, addr => "127.0.0.1" },
+ },
+ file => {
+ loggrep => qr/ 127.0.0.1 /. get_testlog(),
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-client-bind-only6.pl b/regress/usr.sbin/syslogd/args-client-bind-only6.pl
new file mode 100644
index 00000000000..ba010f6c0be
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-client-bind-only6.pl
@@ -0,0 +1,35 @@
+# Syslog binds UDP socket to localhost with -6.
+# The client writes a message to a localhost IPv6 UDP socket.
+# The syslogd writes it into a file and through a pipe.
+# The syslogd passes it via UDP to the loghost.
+# The server receives the message on its UDP socket.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that the file log contains the ::1 name.
+# Check that fstat contains only a bound IPv6 UDP socket.
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ connect => { domain => AF_INET6, addr => "::1", port => 514 },
+ },
+ syslogd => {
+ options => ["-6nU", "localhost"],
+ fstat => {
+ qr/^root .* internet/ => 0,
+ qr/^_syslogd .* internet/ => 2,
+ qr/ internet dgram udp 127.0.0.1:514$/ => 0,
+ qr/ internet6 dgram udp \[::1\]:514$/ => 1,
+ },
+ loghost => '@[::1]:$connectport',
+ },
+ server => {
+ listen => { domain => AF_INET6, addr => "::1" },
+ },
+ file => {
+ loggrep => qr/ ::1 /. get_testlog(),
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-client-bind-port.pl b/regress/usr.sbin/syslogd/args-client-bind-port.pl
new file mode 100644
index 00000000000..f9b958c02c7
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-client-bind-port.pl
@@ -0,0 +1,37 @@
+# Syslog binds UDP socket to localhost and port.
+# The client writes a message to a localhost UDP socket.
+# The syslogd writes it into a file and through a pipe.
+# The syslogd passes it via UDP to the loghost.
+# The server receives the message on its UDP socket.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that the file log contains the localhost name.
+# Check that fstat contains a bound UDP socket.
+
+use strict;
+use warnings;
+require 'funcs.pl';
+
+my $port = find_ports(domain => AF_UNSPEC, addr => "localhost");
+
+our %args = (
+ client => {
+ connect => { domain => AF_UNSPEC, addr => "localhost", port => $port },
+ loggrep => {
+ qr/connect sock: (127.0.0.1|::1) \d+/ => 1,
+ get_testlog() => 1,
+ },
+ },
+ syslogd => {
+ options => ["-U", "localhost:$port"],
+ fstat => {
+ qr/^root .* internet/ => 0,
+ qr/^_syslogd .* internet/ => 3,
+ qr/ internet6? dgram udp (127.0.0.1|\[::1\]):$port$/ => 1,
+ },
+ },
+ file => {
+ loggrep => qr/ localhost /. get_testlog(),
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-client-bind.pl b/regress/usr.sbin/syslogd/args-client-bind.pl
new file mode 100644
index 00000000000..704b727f0d0
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-client-bind.pl
@@ -0,0 +1,34 @@
+# Syslog binds UDP socket to localhost.
+# The client writes a message to a localhost UDP socket.
+# The syslogd writes it into a file and through a pipe.
+# The syslogd passes it via UDP to the loghost.
+# The server receives the message on its UDP socket.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that the file log contains the localhost name.
+# Check that fstat contains a bound UDP socket.
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ connect => { domain => AF_UNSPEC, addr => "localhost", port => 514 },
+ loggrep => {
+ qr/connect sock: (127.0.0.1|::1) \d+/ => 1,
+ get_testlog() => 1,
+ },
+ },
+ syslogd => {
+ options => ["-U", "localhost"],
+ fstat => {
+ qr/^root .* internet/ => 0,
+ qr/^_syslogd .* internet/ => 3,
+ qr/ internet6? dgram udp (127.0.0.1|\[::1\]):514$/ => 1,
+ },
+ },
+ file => {
+ loggrep => qr/ localhost /. get_testlog(),
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-client-bind4-port.pl b/regress/usr.sbin/syslogd/args-client-bind4-port.pl
new file mode 100644
index 00000000000..4bf5c4c86e9
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-client-bind4-port.pl
@@ -0,0 +1,33 @@
+# Syslog binds UDP socket to 127.0.0.1 and port.
+# The client writes a message to a 127.0.0.1 UDP socket.
+# The syslogd writes it into a file and through a pipe.
+# The syslogd passes it via UDP to the loghost.
+# The server receives the message on its UDP socket.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that the file log contains the localhost name.
+# Check that fstat contains a bound UDP socket.
+
+use strict;
+use warnings;
+require 'funcs.pl';
+
+my $port = find_ports(domain => AF_INET, addr => "127.0.0.1");
+
+our %args = (
+ client => {
+ connect => { domain => AF_INET, addr => "127.0.0.1", port => $port },
+ },
+ syslogd => {
+ options => ["-U", "127.0.0.1:$port"],
+ fstat => {
+ qr/^root .* internet/ => 0,
+ qr/^_syslogd .* internet/ => 3,
+ qr/ internet dgram udp 127.0.0.1:$port$/ => 1,
+ },
+ },
+ file => {
+ loggrep => qr/ localhost /. get_testlog(),
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-client-bind4.pl b/regress/usr.sbin/syslogd/args-client-bind4.pl
new file mode 100644
index 00000000000..1c9e572ebc7
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-client-bind4.pl
@@ -0,0 +1,30 @@
+# Syslog binds UDP socket to 127.0.0.1.
+# The client writes a message to a 127.0.0.1 UDP socket.
+# The syslogd writes it into a file and through a pipe.
+# The syslogd passes it via UDP to the loghost.
+# The server receives the message on its UDP socket.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that the file log contains the localhost name.
+# Check that fstat contains a bound UDP socket.
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ connect => { domain => AF_INET, addr => "127.0.0.1", port => 514 },
+ },
+ syslogd => {
+ options => ["-U", "127.0.0.1"],
+ fstat => {
+ qr/^root .* internet/ => 0,
+ qr/^_syslogd .* internet/ => 3,
+ qr/ internet dgram udp 127.0.0.1:514$/ => 1,
+ },
+ },
+ file => {
+ loggrep => qr/ localhost /. get_testlog(),
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-client-bind6-port.pl b/regress/usr.sbin/syslogd/args-client-bind6-port.pl
new file mode 100644
index 00000000000..3737dd095fc
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-client-bind6-port.pl
@@ -0,0 +1,33 @@
+# Syslog binds UDP socket to ::1 and port.
+# The client writes a message to a ::1 UDP socket.
+# The syslogd writes it into a file and through a pipe.
+# The syslogd passes it via UDP to the loghost.
+# The server receives the message on its UDP socket.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that the file log contains the localhost name.
+# Check that fstat contains a bound UDP socket.
+
+use strict;
+use warnings;
+require 'funcs.pl';
+
+my $port = find_ports(domain => AF_INET6, addr => "::1");
+
+our %args = (
+ client => {
+ connect => { domain => AF_INET6, addr => "::1", port => $port },
+ },
+ syslogd => {
+ options => ["-U", "[::1]:$port"],
+ fstat => {
+ qr/^root .* internet/ => 0,
+ qr/^_syslogd .* internet/ => 3,
+ qr/ internet6 dgram udp \[::1\]:$port$/ => 1,
+ },
+ },
+ file => {
+ loggrep => qr/ localhost /. get_testlog(),
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-client-bind6.pl b/regress/usr.sbin/syslogd/args-client-bind6.pl
new file mode 100644
index 00000000000..919bf127872
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-client-bind6.pl
@@ -0,0 +1,30 @@
+# Syslog binds UDP socket to ::1.
+# The client writes a message to a ::1 UDP socket.
+# The syslogd writes it into a file and through a pipe.
+# The syslogd passes it via UDP to the loghost.
+# The server receives the message on its UDP socket.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that the file log contains the localhost name.
+# Check that fstat contains a bound UDP socket.
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ connect => { domain => AF_INET6, addr => "::1", port => 514 },
+ },
+ syslogd => {
+ options => ["-U", "[::1]"],
+ fstat => {
+ qr/^root .* internet/ => 0,
+ qr/^_syslogd .* internet/ => 3,
+ qr/ internet6 dgram udp \[::1\]:514$/ => 1,
+ },
+ },
+ file => {
+ loggrep => qr/ localhost /. get_testlog(),
+ },
+);
+
+1;