diff lib/Test/Nginx.pm @ 1860:58951cf933e1

Tests: added has_feature() test for SSL libraries. This makes it possible to further simplify various SSL tests. It also avoids direct testing of the $t->{_configure_args} internal field, and implements proper comparison of version numbers.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 18 May 2023 18:07:06 +0300
parents cdcd75657e52
children 0e1865aa9b33
line wrap: on
line diff
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -266,6 +266,28 @@ sub has_feature($) {
 		return 0;
 	}
 
+	if ($feature =~ /^(openssl|libressl):([0-9.]+)/) {
+		my $library = $1;
+		my $need = $2;
+
+		$self->{_configure_args} = `$NGINX -V 2>&1`
+			if !defined $self->{_configure_args};
+
+		return 0 unless
+			$self->{_configure_args} =~ /with $library ([0-9.]+)/i;
+
+		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;
+	}
+
 	return 0;
 }