add E2E tests for h2olog -A
@@ -155,7 +155,62 @@ subtest "h2olog -S=0.00", sub {
grep {
$_->{type} eq "h3s-destroy"
} @logs
- ], [], "no stream-on-destroy header in logs";
+ ], [], "no h3s-destroy header in logs";
+ };
+};
+
+subtest "h2olog -A=127.0.0.2", sub {
+ my $tracer = H2ologTracer->new({
+ pid => $server->{pid},
+ args => ["-A", "127.0.0.2"],
+ });
+
+ subtest "with non-matched IP address", sub {
+ my ($headers) = run_prog("$client_prog -3 https://127.0.0.1:$quic_port/");
+ like $headers, qr{^HTTP/3 200\n}, "req: HTTP/3";
+
+ sleep(1);
+ my $trace = $tracer->get_trace();
+
+ if ($ENV{H2OLOG_DEBUG}) {
+ diag "h2olog output:\n", $trace;
+ }
+
+ my @logs = map { decode_json($_) } split /\n/, $trace;
+
+ is_deeply [
+ grep {
+ $_->{type} eq "h3s-accept"
+ } @logs
+ ], [], "no h3s-accept header in logs";
+
+ is_deeply [
+ grep {
+ $_->{type} eq "h3s-destroy"
+ } @logs
+ ], [], "no h3s-destroy header in logs";
+ };
+
+ subtest "with matched IP address", sub {
+ my ($headers) = `curl --interface 127.0.0.2 --head -sSf http://127.0.0.1:$server->{port}/`;
+ like $headers, qr{^HTTP/1\.1 200\b}, "req: HTTP/1.1";
+
+ sleep(1);
+ my $trace = $tracer->get_trace();
+
+ if ($ENV{H2OLOG_DEBUG}) {
+ diag "h2olog output:\n", $trace;
+ }
+
+ my @logs = map { decode_json($_) } split /\n/, $trace;
+
+ is_deeply scalar(grep {
+ $_->{type} eq "h1-accept"
+ } @logs), 1, "h1-accept header in logs";
+
+ is_deeply scalar(grep {
+ $_->{type} eq "h1-close"
+ } @logs), 1, "h1-close header in logs";
};
};
