Skip to content

net.http: set IP address for HTTP server during tests#24698

Merged
spytheman merged 1 commit into
vlang:masterfrom
lcheylus:openbsd-http_server
Jun 11, 2025
Merged

net.http: set IP address for HTTP server during tests#24698
spytheman merged 1 commit into
vlang:masterfrom
lcheylus:openbsd-http_server

Conversation

@lcheylus

@lcheylus lcheylus commented Jun 11, 2025

Copy link
Copy Markdown
Contributor

On OpenBSD, TCP connect fails (return EINVAL) if attempted with 0.0.0.0 address.

In vlib/net/http/server_test.v, for tests test_server_custom_handler and test_host_header_sent_to_server, use 127.0.0.1 as IP addr for the HTTP server.

Fix #22126

Tests OK on OpenBSD/amd64 and Linux/amd64 with tcc, clang and gcc

$ ./v test vlib/net/http/server_test.v 
---- Testing... ----------------------------------------------------------------------------------------------------------------------------
 OK    1996.242 ms vlib/net/http/server_test.v
--------------------------------------------------------------------------------------------------------------------------------------------
Summary for all V _test.v files: 1 passed, 1 total. Elapsed time: 3590 ms, on 1 job. Comptime: 1585 ms. Runtime: 1996 ms.

$ ./v -cc clang test vlib/net/http/server_test.v 
---- Testing... ----------------------------------------------------------------------------------------------------------------------------
 OK    2112.866 ms vlib/net/http/server_test.v
--------------------------------------------------------------------------------------------------------------------------------------------
Summary for all V _test.v files: 1 passed, 1 total. Elapsed time: 5325 ms, on 1 job. Comptime: 3206 ms. Runtime: 2112 ms.

$ ./v -cc egcc test vlib/net/http/server_test.v 
---- Testing... ----------------------------------------------------------------------------------------------------------------------------
 OK    2044.330 ms vlib/net/http/server_test.v
--------------------------------------------------------------------------------------------------------------------------------------------
Summary for all V _test.v files: 1 passed, 1 total. Elapsed time: 6186 ms, on 1 job. Comptime: 4136 ms. Runtime: 2044 ms.

On OpenBSD, TCP connect fails (return EINVAL) if attempted with 0.0.0.0
address.

Signed-off-by: Laurent Cheylus <foxy@free.fr>
@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-23053

@JalonSolov

Copy link
Copy Markdown
Collaborator

Believe it or not, some versions of Windows do not set 127.0.0.1 in their hosts file, so this could break on them.

This change will also be a problem on systems with IP6 as the default/only scheme.

@lcheylus

lcheylus commented Jun 11, 2025

Copy link
Copy Markdown
Contributor Author

Believe it or not, some versions of Windows do not set 127.0.0.1 in their hosts file, so this could break on them.

No issue in Windows CI with my fix :)

This change will also be a problem on systems with IP6 as the default/only scheme.

This fix is only for tests of HTTP server. I doubt any serious developer would use a system with only an IPv6 stack.

So I think that my fix is not a problem. And it allows that every test runned with VTEST_JUST_ESSENTIAL are OK on OpenBSD (proposal to add a specific CI for OpenBSD soon...).

@spytheman

Copy link
Copy Markdown
Contributor

We can make the ip setting conditional on the platform, if there are problems in the future.
Imho it is a good change, since it will allow more checks (an OpenBSD CI), with a small chance of breaking the test for non CI users.

@spytheman

Copy link
Copy Markdown
Contributor

use_net_and_net_unix_together_test.v seems to be stuck on the gcc-windows job, but that is unrelated to the PR.

@spytheman spytheman merged commit 2bc5887 into vlang:master Jun 11, 2025
63 of 64 checks passed
@lcheylus lcheylus deleted the openbsd-http_server branch June 11, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failed on OpenBSD for vlib/net/http/server_test.v

3 participants