Mercurial > hg > nginx-tests
diff stream_js_fetch_https.t @ 1811:520fb74cce4c
Tests: improved njs version check to account multi digit versions.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Fri, 02 Dec 2022 17:46:22 -0800 |
parents | 564f74bf6e4d |
children | cdcd75657e52 |
line wrap: on
line diff
--- a/stream_js_fetch_https.t Fri Dec 02 17:46:16 2022 -0800 +++ b/stream_js_fetch_https.t Fri Dec 02 17:46:22 2022 -0800 @@ -270,8 +270,7 @@ ############################################################################### -local $TODO = 'not yet' - unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.0'; +local $TODO = 'not yet' unless has_version('0.7.0'); like(stream("127.0.0.1:$p2")->io('GOdefault.example.com'), qr/connect failed/s, 'stream non trusted CA'); @@ -289,6 +288,25 @@ ############################################################################### +sub has_version { + my $need = shift; + + http_get('/njs') =~ /^([.0-9]+)$/m; + + my @v = split(/\./, $1); + my ($n, $v); + + for $n (split(/\./, $need)) { + $v = shift @v || 0; + return 0 if $n > $v; + return 1 if $v > $n; + } + + return 1; +} + +############################################################################### + sub get_ssl_socket { my ($host, $port) = @_; my $s;