Skip to content

Commit 6768fdf

Browse files
committed
fix ci failures on master
1 parent 130caaf commit 6768fdf

5 files changed

Lines changed: 113 additions & 24 deletions

File tree

vlib/net/http/server_tls_test.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// vtest build: !sanitize-memory-clang
12
// Hermetic TLS-termination test for net.http.Server: spin up a local HTTPS
23
// server with an in-memory cert/key, hit it with http.fetch (validate: false),
34
// and assert the round-trip.

vlib/net/ssl/ssl_alpn_test.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// vtest build: !sanitize-memory-clang
12
module main
23

34
import net

vlib/v/builder/cc.v

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,19 +325,58 @@ fn c_error_looks_like_missing_libatomic(c_output string) bool {
325325
return c_error_missing_libatomic_marker(c_output) != ''
326326
}
327327

328+
fn normalized_linker_library_file_name(lib_name string) string {
329+
for suffix in ['.dll.a', '.lib', '.a', '.dll'] {
330+
if lib_name.ends_with(suffix) {
331+
mut normalized := lib_name[..lib_name.len - suffix.len]
332+
if normalized.starts_with('lib') {
333+
normalized = normalized[3..]
334+
}
335+
return normalized
336+
}
337+
}
338+
return lib_name
339+
}
340+
341+
fn normalized_missing_library_name(raw_name string, allow_plain_name bool) string {
342+
mut lib_name := raw_name.trim_space().trim('`\'"')
343+
for delimiter in ['`', "'", '"', ' ', ':'] {
344+
lib_name = lib_name.all_before(delimiter)
345+
}
346+
lib_name = lib_name.trim_space().trim('`\'"')
347+
if lib_name.starts_with('-l') {
348+
return normalized_linker_library_file_name(lib_name[2..])
349+
}
350+
normalized := normalized_linker_library_file_name(lib_name)
351+
if normalized != lib_name {
352+
return normalized
353+
}
354+
if allow_plain_name {
355+
return lib_name
356+
}
357+
return ''
358+
}
359+
328360
fn c_error_missing_library_name(c_output string) string {
329361
for line in c_output.split_into_lines() {
330362
if line.contains("library '") && line.contains("' not found") {
331-
return line.all_after("library '").all_before("' not found")
363+
return normalized_missing_library_name(line.all_after("library '").all_before("' not found"),
364+
true)
332365
}
366+
lower_line := line.to_lower()
333367
for marker in [
334368
'cannot find -l',
335369
'unable to find library -l',
336370
'library not found for -l',
337371
] {
338-
if line.contains(marker) {
339-
lib_name := line.all_after(marker).trim_space()
340-
return lib_name.all_before('`').all_before("'").all_before('"').all_before(' ').all_before(':')
372+
if start := lower_line.index(marker) {
373+
return normalized_missing_library_name(line[start + marker.len..], true)
374+
}
375+
}
376+
if start := lower_line.index('cannot find ') {
377+
lib_name := normalized_missing_library_name(line[start + 'cannot find '.len..], false)
378+
if lib_name != '' {
379+
return lib_name
341380
}
342381
}
343382
}

vlib/v/builder/cc_test.v

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,16 @@ fn test_c_error_missing_library_name_with_gnu_ld_output() {
755755
assert c_error_missing_library_name(c_output) == 'ssl'
756756
}
757757

758+
fn test_c_error_missing_library_name_with_mingw_ld_output() {
759+
c_output := 'C:/msys64/ucrt64/bin/ld.exe: cannot find libv_missing_lib_25499.dll.a: No such file or directory\ncollect2.exe: error: ld returned 1 exit status\n'
760+
assert c_error_missing_library_name(c_output) == 'v_missing_lib_25499'
761+
}
762+
763+
fn test_c_error_missing_library_name_with_mingw_lflag_suffix_output() {
764+
c_output := 'C:/msys64/ucrt64/bin/ld.exe: cannot find -lv_missing_lib_25499.dll.a: No such file or directory\ncollect2.exe: error: ld returned 1 exit status\n'
765+
assert c_error_missing_library_name(c_output) == 'v_missing_lib_25499'
766+
}
767+
758768
fn test_c_error_missing_library_name_with_regular_c_error() {
759769
c_output := "error: unknown type name 'my_missing_type'"
760770
assert c_error_missing_library_name(c_output) == ''

vlib/veb/tests/graceful_shutdown_test.v

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import time
55
import veb
66

77
const graceful_shutdown_host = '127.0.0.1'
8+
const graceful_shutdown_wait_timeout = 10 * time.second
89

910
struct GracefulShutdownContext {
1011
veb.Context
@@ -31,19 +32,6 @@ pub fn (mut app GracefulShutdownApp) slow(mut ctx GracefulShutdownContext) veb.R
3132
return ctx.text('slow done')
3233
}
3334

34-
pub fn (mut app GracefulShutdownApp) shutdown(mut ctx GracefulShutdownContext) veb.Result {
35-
spawn app.shutdown_now()
36-
return ctx.text('shutting down')
37-
}
38-
39-
fn (app &GracefulShutdownApp) shutdown_now() {
40-
mut server := app.server
41-
if server == unsafe { nil } {
42-
panic('veb server was not initialized')
43-
}
44-
server.shutdown(timeout: 5 * time.second) or { panic(err) }
45-
}
46-
4735
fn run_graceful_shutdown_app(mut app GracefulShutdownApp, port int) {
4836
veb.run_at[GracefulShutdownApp, GracefulShutdownContext](mut app,
4937
host: graceful_shutdown_host
@@ -58,6 +46,51 @@ fn send_slow_request(port int, responses chan http.Response) {
5846
responses <- response
5947
}
6048

49+
fn shutdown_graceful_server(server &veb.Server, done chan string) {
50+
server.shutdown(timeout: 5 * time.second) or {
51+
done <- err.msg()
52+
return
53+
}
54+
done <- ''
55+
}
56+
57+
fn wait_for_slow_request(started chan bool) ! {
58+
select {
59+
_ := <-started {
60+
return
61+
}
62+
graceful_shutdown_wait_timeout {
63+
return error('slow request did not start')
64+
}
65+
}
66+
}
67+
68+
fn wait_for_slow_response(responses chan http.Response) !http.Response {
69+
select {
70+
response := <-responses {
71+
return response
72+
}
73+
graceful_shutdown_wait_timeout {
74+
return error('slow request did not finish')
75+
}
76+
}
77+
return error('slow request did not finish')
78+
}
79+
80+
fn wait_for_shutdown(done chan string) ! {
81+
select {
82+
shutdown_error := <-done {
83+
if shutdown_error != '' {
84+
return error(shutdown_error)
85+
}
86+
return
87+
}
88+
graceful_shutdown_wait_timeout {
89+
return error('server shutdown did not finish')
90+
}
91+
}
92+
}
93+
6194
fn wait_for_server(port int) ! {
6295
url := 'http://${graceful_shutdown_host}:${port}/'
6396
for _ in 0 .. 100 {
@@ -88,25 +121,30 @@ fn test_veb_graceful_shutdown_waits_for_in_flight_requests() {
88121

89122
slow_responses := chan http.Response{cap: 1}
90123
spawn send_slow_request(int(port), slow_responses)
91-
_ := <-app.slow_started or {
92-
assert false, 'slow request did not start'
124+
wait_for_slow_request(app.slow_started) or {
125+
assert false, err.msg()
93126
return
94127
}
95128

96-
shutdown_response := http.get('http://${graceful_shutdown_host}:${port}/shutdown') or {
97-
assert false, err.msg()
129+
mut server := app.server
130+
if server == unsafe { nil } {
131+
assert false, 'veb server was not initialized'
98132
return
99133
}
100-
assert shutdown_response.status() == .ok
101-
assert shutdown_response.body == 'shutting down'
134+
shutdown_done := chan string{cap: 1}
135+
spawn shutdown_graceful_server(server, shutdown_done)
102136

103-
slow_response := <-slow_responses or {
137+
slow_response := wait_for_slow_response(slow_responses) or {
104138
assert false, err.msg()
105139
return
106140
}
107141
assert slow_response.status() == .ok
108142
assert slow_response.body == 'slow done'
109143

144+
wait_for_shutdown(shutdown_done) or {
145+
assert false, err.msg()
146+
return
147+
}
110148
server_thread.wait()
111149

112150
http.get('http://${graceful_shutdown_host}:${port}/') or {

0 commit comments

Comments
 (0)