# HG changeset patch
# User Rob Mueller <r...@fastmailteam.com>
Add valgrind support to nginx test suite

Setting TEST_NGINX_VALGRIND=1 will cause the test suite
to run nginx under valgrind and check at exit that there's
no errors present
---
 lib/Test/Nginx.pm | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm
index 7b7bdc5..f363349 100644
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -86,7 +86,12 @@ sub DESTROY {
                local $Test::Nginx::TODO;
                my $errors = $self->read_file('error.log');
                $errors = join "\n", $errors =~ /.+Sanitizer.+/gm;
-               Test::More::is($errors, '', 'no sanitizer errors');
+               my $extra = "";
+               if ($ENV{TEST_NGINX_VALGRIND}) {
+                       $extra = "/valgrind";
+                       $errors .= $self->read_file('valgrind.log');
+               }
+               Test::More::is($errors, '', "no sanitizer${extra} errors");
        }
 
        if ($ENV{TEST_NGINX_CATLOG}) {
@@ -398,7 +403,11 @@ sub run(;$) {
                my @globals = $self->{_test_globals} ?
                        () : ('-g', "pid $testdir/nginx.pid; "
                        . "error_log $testdir/error.log debug;");
-               exec($NGINX, '-p', "$testdir/", '-c', 'nginx.conf',
+               my @cmd = ($NGINX);
+               if ($ENV{TEST_NGINX_VALGRIND}) {
+                       unshift @cmd, 'valgrind', '-q', 
"--log-file=$testdir/valgrind.log";
+               }
+               exec(@cmd, '-p', "$testdir/", '-c', 'nginx.conf',
                        '-e', 'error.log', @globals)
                        or die "Unable to exec(): $!\n";
        }

-- 
nginx-devel mailing list
nginx-devel@freenginx.org
https://freenginx.org/mailman/listinfo/nginx-devel

Reply via email to