[PATCH 2 of 2] Tests: adjusted TODO for OpenSSL 1.0.2h and up in h2_http2.t

Sergey Kandaurov pluknet at nginx.com
Mon Jul 10 16:23:44 UTC 2023


> On 1 Jul 2023, at 04:21, Maxim Dounin <mdounin at mdounin.ru> wrote:
> 
> # HG changeset patch
> # User Maxim Dounin <mdounin at mdounin.ru>
> # Date 1688164312 -10800
> #      Sat Jul 01 01:31:52 2023 +0300
> # Node ID 5ef10e454094ad5d231552f0fc2c386e9cc33585
> # Parent  bf9961a4507784b669650e7ef1d3cbacce8c94e1
> Tests: adjusted TODO for OpenSSL 1.0.2h and up in h2_http2.t.
> 
> OpenSSL uses correct SNI/ALPN callback order (SNI callback before ALPN
> callback) starting with OpenSSL 1.0.2h, so "sni to enabled" test
> is expected to succeed starting with OpenSSL 1.0.2h.
> 
> With this change, the "openssl:..." feature test now supports checking
> patch level encoded as letters, such as in "openssl:1.0.2h".
> 
> diff --git a/h2_http2.t b/h2_http2.t
> --- a/h2_http2.t
> +++ b/h2_http2.t
> @@ -151,9 +151,9 @@ ok(!get_ssl_socket(8444), 'default to di
> TODO: {
> local $TODO = 'broken ALPN/SNI order in LibreSSL'
> 	if $t->has_module('LibreSSL');
> -local $TODO = 'OpenSSL too old'
> +local $TODO = 'broken ALPN/SNI order in OpenSSL before 1.0.2h'
> 	if $t->has_module('OpenSSL')
> -	and not $t->has_feature('openssl:1.1.0');
> +	and not $t->has_feature('openssl:1.0.2h');
> 
> is(get_https(8444, 'http2'), 200, 'sni to enabled');
> 
> diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm
> --- a/lib/Test/Nginx.pm
> +++ b/lib/Test/Nginx.pm
> @@ -266,20 +266,22 @@ sub has_feature($) {
> 		return 0;
> 	}
> 
> -	if ($feature =~ /^(openssl|libressl):([0-9.]+)/) {
> +	if ($feature =~ /^(openssl|libressl):([0-9.]+)([a-z]*)/) {
> 		my $library = $1;
> 		my $need = $2;
> +		my $patch = $3;
> 
> 		$self->{_configure_args} = `$NGINX -V 2>&1`
> 			if !defined $self->{_configure_args};
> 
> 		return 0 unless
> -			$self->{_configure_args} =~ /with $library ([0-9.]+)/i;
> +			$self->{_configure_args}
> +			=~ /with $library ([0-9.]+)([a-z]*)/i;

Note that patch versions with capital letters may now be captured
which cannot be specified in has_feature(), should never happen though.

> 
> -		my @v = split(/\./, $1);
> +		my @v = (split(/\./, $1), unpack("C*", $2));
> 		my ($n, $v);
> 
> -		for $n (split(/\./, $need)) {
> +		for $n (split(/\./, $need), unpack("C*", $patch)) {
> 			$v = shift @v || 0;
> 			return 0 if $n > $v;
> 			return 1 if $v > $n;

Looks good.

-- 
Sergey Kandaurov


More information about the nginx-devel mailing list