Debian Codegraph @

debian/patches/0003-tests-Test-EINTR.patch

raw
1 From dc9dfd51551c0b6d6864cc4ddf0352a24af762b2 Mon Sep 17 00:00:00 2001
2 From: Ian Jackson <[email protected]>
3 Date: Mon, 21 Sep 2026 19:55:57 +0100
4 Subject: [PATCH 3/3] tests: Test EINTR
5
6 I have tested this test, by experimentally reverting
7 Handle EINTR and read errors correctly
8
9 > 1..36
10 > ok 1 - constructor set family properly
11 > ok 2 - Constructor set port correctly
12 > HTTP::Server::Simple::CGI: You can connect to your server at http://localhost:49019/
13 > ok 3 - pid is numeric
14 > ok 4 - Returns a page
15 > ok 5 - constructor set family properly
16 > ok 6 - Constructor set port correctly
17 > HTTP::Server::Simple::CGI: You can connect to your server at http://localhost:49020/
18 > ok 7 - pid is numeric
19 > ok 8 - Returns a page
20 > ok 9 - constructor set family properly
21 > ok 10 - Constructor set port correctly
22 > SlowServer: You can connect to your server at http://localhost:49021/
23 > ok 11 - pid is numeric
24 > ok 12 - Returns a page
25 > ok 13 - constructor set family properly
26 > ok 14 - Constructor set port correctly
27 > SlowServer: You can connect to your server at http://localhost:49022/
28 > ok 15 - pid is numeric
29 > ok 16 - Returns a page
30 > ok 17 - family OK
31 > HTTP::Server::Simple::CGI: You can connect to your server at http://localhost:49023/
32 > ok 18 - pid is numeric
33 > ok 19 - Returns a page
34 > ok 20 - knows what a request isn't
35 > ok 21 - HTTP/1.1 request
36 > ok 22 - HTTP/0.9 request
37 > # SIGWINCH received
38 > not ok 23 - HTTP/1.1 request with EINTR
39 > # Failed test 'HTTP/1.1 request with EINTR'
40 > # at t/01live.t line 95.
41 > # 'HTTP/1.0 400 Bad request
42 > # Content-Type: text/html
43 > # Content-Length: 193
44 > #
45 > # <html>
46 > # <head>
47 > # <title>Bad Request</title>
48 > # </head>
49 > # <body>
50 > # <h1>Bad Request</h1>
51 > #
52 > # <p>Your browser sent a request which this web server could not
53 > # grok.</p>
54 > # </body>
55 > # </html>
56 > # '
57 > # doesn't match '/Congratulations/'
58 > ok 24 - Signaled 1 process successfully
59 > ok 25 - family OK
60 > HTTP::Server::Simple::CGI: You can connect to your server at http://localhost:49023/
61 > ok 26 - pid is numeric
62 > ok 27 - Returns a page
63 > ok 28 - knows what a request isn't
64 > ok 29 - HTTP/1.1 request
65 > ok 30 - HTTP/0.9 request
66 > # SIGWINCH received
67 > not ok 31 - HTTP/1.1 request with EINTR
68 > # Failed test 'HTTP/1.1 request with EINTR'
69 > # at t/01live.t line 95.
70 > # 'HTTP/1.0 400 Bad request
71 > # Content-Type: text/html
72 > # Content-Length: 193
73 > #
74 > # <html>
75 > # <head>
76 > # <title>Bad Request</title>
77 > # </head>
78 > # <body>
79 > # <h1>Bad Request</h1>
80 > #
81 > # <p>Your browser sent a request which this web server could not
82 > # grok.</p>
83 > # </body>
84 > # </html>
85 > # '
86 > # doesn't match '/Congratulations/'
87 > ok 32 - Signaled 1 process successfully
88 > ok 33 - Killed PID: 30838
89 > ok 34 - Killed PID: 30839
90 > ok 35 - Killed PID: 30840
91 > ok 36 - Killed PID: 30846
92 > # Looks like you failed 2 tests of 36.
93 ---
94 t/01live.t | 17 +++++++++++++++--
95 1 file changed, 15 insertions(+), 2 deletions(-)
96
97 diff --git a/t/01live.t b/t/01live.t
98 index 272a42e..f7af49a 100644
99 --- a/t/01live.t
100 +++ b/t/01live.t
101 @@ -21,10 +21,10 @@ my $RUN_IPV6 = eval {
102 return 1;
103 };
104 if ( $RUN_IPV6) {
105 - plan tests => 34;
106 + plan tests => 36;
107 } else {
108 diag("Skipping IPv6");
109 - plan tests => 17;
110 + plan tests => 18;
111 }
112 use HTTP::Server::Simple;
113
114 @@ -53,6 +53,7 @@ for my $class (@classes) {
115 $PORT++; # don't reuse the port incase your bogus os doesn't release in time
116 }
117
118 +$SIG{WINCH} = sub { note "SIGWINCH received"; }; # See EINTR test, below
119
120 for my $fam ( AF_INET, AF_INET6 ) {
121 next if ($fam == AF_INET6 && not $RUN_IPV6);
122 @@ -64,7 +65,7 @@ for my $fam ( AF_INET, AF_INET6 ) {
123 like($pid, '/^-?\d+$/', 'pid is numeric');
124 select(undef,undef,undef,0.2); # wait a sec
125 SKIP: {
126 - skip "No localhost for $fam", 4 unless defined $s->host;
127 + skip "No localhost for $fam", 5 unless defined $s->host;
128 my $content=fetch($fam, "GET / HTTP/1.1", "");
129 like($content, '/Congratulations/', "Returns a page");
130
131 @@ -80,6 +81,18 @@ for my $fam ( AF_INET, AF_INET6 ) {
132
133 like(fetch($fam, "GET /"), '/Congratulations/',
134 "HTTP/0.9 request");
135 +
136 + like(fetch_interactive($fam, sub {
137 + # Arrange for the server to get EINTR, by sending part of the request,
138 + # and then a SIGWINCH. (We choose SIGWINCH because it's a harmless signal
139 + # that is normally ignored, but which an application might want to handle.)
140 + # Tests for regression of https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1143215
141 + (send SOCK, "GET", 0) or die "send G: $!";
142 + sleep 1;
143 + kill('WINCH',$pid) or die "send SIGWINCH: $!";
144 + sleep 1;
145 + (send SOCK, " / HTTP/1.1\015\012\015\012", 0) or die "send ET etc.: $!";
146 + }), '/Congratulations/', "HTTP/1.1 request with EINTR");
147 }
148
149 is(kill(9,$pid),1,'Signaled 1 process successfully');
150 --
151 2.47.3
152