The Test::Nginx Perl module is a testing framework utilised by various
third party NGINX modules, mainly developed by OpenResty.

Signed-off-by: Zurab Kvachadze <zurabid2...@gmail.com>
---
 dev-perl/Test-Nginx/Manifest                  |  1 +
 dev-perl/Test-Nginx/Test-Nginx-0.30.ebuild    | 36 ++++++++++++++
 ...inx-0.30-preset-temp_path-directives.patch | 38 +++++++++++++++
 ...est-Nginx-0.30-set-default-error-log.patch | 48 +++++++++++++++++++
 .../Test-Nginx}/metadata.xml                  |  4 +-
 5 files changed, 126 insertions(+), 1 deletion(-)
 create mode 100644 dev-perl/Test-Nginx/Manifest
 create mode 100644 dev-perl/Test-Nginx/Test-Nginx-0.30.ebuild
 create mode 100644 
dev-perl/Test-Nginx/files/Test-Nginx-0.30-preset-temp_path-directives.patch
 create mode 100644 
dev-perl/Test-Nginx/files/Test-Nginx-0.30-set-default-error-log.patch
 copy {app-pda/usbmuxd => dev-perl/Test-Nginx}/metadata.xml (72%)

diff --git a/dev-perl/Test-Nginx/Manifest b/dev-perl/Test-Nginx/Manifest
new file mode 100644
index 000000000000..6c3ed06f65c2
--- /dev/null
+++ b/dev-perl/Test-Nginx/Manifest
@@ -0,0 +1 @@
+DIST Test-Nginx-0.30.tar.gz 131437 BLAKE2B 
3f1ac14124059ba45d6bbb0f921d2b0c58790a1150f33c23a7dbfaf8ae14118fc7fc42df249362e566c9862ea3a84a58ae75066a041f6e65d36f78a951ecd222
 SHA512 
3a6727e567a213872f2ec6b0d782f40d867714787811911bf1637e76abcb3511c446b87e8a93106cf1473f2e49ebe375a2382658b8600a65cb8c3940cc0fa178
diff --git a/dev-perl/Test-Nginx/Test-Nginx-0.30.ebuild 
b/dev-perl/Test-Nginx/Test-Nginx-0.30.ebuild
new file mode 100644
index 000000000000..a8f136f809e6
--- /dev/null
+++ b/dev-perl/Test-Nginx/Test-Nginx-0.30.ebuild
@@ -0,0 +1,36 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DIST_AUTHOR=AGENT
+inherit perl-module
+
+DESCRIPTION="Data-driven test scaffold for NGINX and OpenResty"
+
+LICENSE="BSD"
+
+SLOT="0"
+
+# The following packages in the dev-perl category provide the required Perl
+# modules that Test-Nginx depends on:
+#     (1) libwww-perl provides LWP::UserAgent,
+#     (2) HTTP-Message provides HTTP::Response,
+#     (3) URI provides URI::Escape.
+RDEPEND="
+       dev-perl/HTTP-Message
+       dev-perl/IPC-Run
+       dev-perl/List-MoreUtils
+       dev-perl/Test-Base
+       dev-perl/Test-LongString
+       dev-perl/Text-Diff
+       dev-perl/libwww-perl
+       virtual/perl-ExtUtils-MakeMaker
+       virtual/perl-File-Temp
+       virtual/perl-Time-HiRes
+"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-0.30-preset-temp_path-directives.patch"
+       "${FILESDIR}/${PN}-0.30-set-default-error-log.patch"
+)
diff --git 
a/dev-perl/Test-Nginx/files/Test-Nginx-0.30-preset-temp_path-directives.patch 
b/dev-perl/Test-Nginx/files/Test-Nginx-0.30-preset-temp_path-directives.patch
new file mode 100644
index 000000000000..a8a66bb48d67
--- /dev/null
+++ 
b/dev-perl/Test-Nginx/files/Test-Nginx-0.30-preset-temp_path-directives.patch
@@ -0,0 +1,38 @@
+From 2ab64d371acfed9189656b3fd099c2747209c98f Mon Sep 17 00:00:00 2001
+From: Zurab Kvachadze <zurabid2...@gmail.com>
+Date: Wed, 12 Feb 2025 13:38:44 +0100
+Subject: [PATCH] Util.pm: preset *temp_path directives to subdirectoroes of
+ servroot
+
+This avoids errors when NGINX, launched as non-root, tries writing
+various temporary files into default compiled-in directoroes that is
+only writable by root.
+
+This commit sets the directives that control where the temp files are
+saved, to point to a subdirectory of the temporary testing server root,
+which is writable by the user executing NGINX.
+
+Signed-off-by: Zurab Kvachadze <zurabid2...@gmail.com>
+---
+ lib/Test/Nginx/Util.pm | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/Test/Nginx/Util.pm b/lib/Test/Nginx/Util.pm
+index 1d4aa38..1af9277 100644
+--- a/lib/Test/Nginx/Util.pm
++++ b/lib/Test/Nginx/Util.pm
+@@ -1168,6 +1168,11 @@ _EOC_
+ $main_config
+ 
+ http {
++    client_body_temp_path $ServRoot/client_body_temp;
++    proxy_temp_path $ServRoot/proxy_temp;
++    fastcgi_temp_path $ServRoot/fastcgi_temp;
++    scgi_temp_path $ServRoot/scgi_temp;
++    uwsgi_temp_path $ServRoot/uwsgi_temp;
+     access_log $AccLogFile;
+     #access_log off;
+ 
+-- 
+2.45.3
+
diff --git 
a/dev-perl/Test-Nginx/files/Test-Nginx-0.30-set-default-error-log.patch 
b/dev-perl/Test-Nginx/files/Test-Nginx-0.30-set-default-error-log.patch
new file mode 100644
index 000000000000..192ee59b4123
--- /dev/null
+++ b/dev-perl/Test-Nginx/files/Test-Nginx-0.30-set-default-error-log.patch
@@ -0,0 +1,48 @@
+From a105fc2a543d1136c6c747c1c2d1fd905ab9389f Mon Sep 17 00:00:00 2001
+From: Zurab Kvachadze <zurabid2...@gmail.com>
+Date: Thu, 13 Feb 2025 02:29:05 +0100
+Subject: [PATCH] Util.pm: specify error log on command line
+
+When no error log is specified on the command line, NGINX logs errors to
+the compiled-in error log (irrespective of whether the error log is
+specified in the configuration file), which is most often writable only
+by root. When tests are run as unprivileged user, NGINX can not write
+the log file and, therefore, fails to start.
+
+This commit makes Test::Nginx set the error log to standard error no
+configuration file is specified, or to $ServRoot/logs/error.log when the
+configuration file is specified, thus overriding the default path.
+
+Signed-off-by: Zurab Kvachadze <zurabid2...@gmail.com>
+---
+ lib/Test/Nginx/Util.pm | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/lib/Test/Nginx/Util.pm b/lib/Test/Nginx/Util.pm
+index 1af9277..41c6061 100644
+--- a/lib/Test/Nginx/Util.pm
++++ b/lib/Test/Nginx/Util.pm
+@@ -1292,7 +1292,7 @@ sub get_canon_version_for_OpenSSL (@) {
+ }
+ 
+ sub get_nginx_version () {
+-    my $out = `$NginxBinary -V 2>&1`;
++    my $out = `$NginxBinary -e stderr -V 2>&1`;
+     if (!defined $out || $? != 0) {
+         $out //= "";
+         bail_out("Failed to get the version of the Nginx in PATH: $out");
+@@ -2049,9 +2049,9 @@ start_nginx:
+             my $cmd;
+ 
+             if ($NginxVersion >= 0.007053) {
+-                $cmd = "$NginxBinary -p $ServRoot/ -c $ConfFile > /dev/null";
++                $cmd = "$NginxBinary -e $ServRoot/logs/error.log -p 
$ServRoot/ -c $ConfFile > /dev/null";
+             } else {
+-                $cmd = "$NginxBinary -c $ConfFile > /dev/null";
++                $cmd = "$NginxBinary -e $ServRoot/logs/error.log -c $ConfFile 
> /dev/null";
+             }
+ 
+             if (defined $block->suppress_stderr) {
+-- 
+2.45.3
+
diff --git a/app-pda/usbmuxd/metadata.xml b/dev-perl/Test-Nginx/metadata.xml
similarity index 72%
copy from app-pda/usbmuxd/metadata.xml
copy to dev-perl/Test-Nginx/metadata.xml
index d8e789b30263..6ca2fdd412ec 100644
--- a/app-pda/usbmuxd/metadata.xml
+++ b/dev-perl/Test-Nginx/metadata.xml
@@ -10,6 +10,8 @@
                <name>Proxy Maintainers</name>
        </maintainer>
        <upstream>
-               <remote-id type="github">libimobiledevice/usbmuxd</remote-id>
+               <remote-id type="github">openresty/test-nginx</remote-id>
+               <remote-id type="cpan">Test-Nginx</remote-id>
+               <remote-id type="cpan-module">Test::Nginx</remote-id>
        </upstream>
 </pkgmetadata>
-- 
2.45.3


Reply via email to