]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Re-add functionality to handle lwresd from {start,stop}.pl
authorOndřej Surý <ondrej@sury.org>
Mon, 3 Dec 2018 18:50:47 +0000 (19:50 +0100)
committerOndřej Surý <ondrej@sury.org>
Mon, 3 Dec 2018 19:45:16 +0000 (20:45 +0100)
bin/tests/system/lwresd/tests.sh
bin/tests/system/start.pl
bin/tests/system/stop.pl

index df20ee9d3f0b7a4cae9200120c9c369f01156acb..918508548902a7c197ac9a274d100b7302353f4a 100644 (file)
@@ -14,6 +14,8 @@
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
 
+common_options="-D lwresd-lwresd1 -X lwresd.lock -m record,size,mctx -T clienttest -d 99 -g -U 4 -i lwresd.pid -P 9210 -p 5300"
+
 status=0
 echo "I:waiting for nameserver to load"
 for i in 0 1 2 3 4 5 6 7 8 9
@@ -49,7 +51,7 @@ $PERL $SYSTEMTESTTOP/stop.pl lwresd lwresd1
 
 mv lwresd1/lwresd.run lwresd1/lwresd.run.resolv
 
-$PERL $SYSTEMTESTTOP/start.pl lwresd lwresd1 -- "-X lwresd.lock -m record,size,mctx -c lwresd.conf -d 99 -g"
+$PERL $SYSTEMTESTTOP/start.pl --restart lwresd lwresd1 -- "-c lwresd.conf $common_options"
 
 echo "I:using lwresd.conf"
 ret=0
@@ -68,7 +70,7 @@ $PERL $SYSTEMTESTTOP/stop.pl lwresd lwresd1
 
 mv lwresd1/lwresd.run lwresd1/lwresd.run.lwresd
 
-$PERL $SYSTEMTESTTOP/start.pl lwresd lwresd1 -- "-X lwresd.lock -m record,size,mctx -c nosearch.conf -d 99 -g"
+$PERL $SYSTEMTESTTOP/start.pl --restart lwresd lwresd1 -- "-c nosearch.conf $common_options"
 
 echo "I:using nosearch.conf"
 ret=0
index 49a6665d2ffe6164b0ef21fb2f1b073efa9e227e..38e3045fe53a41140e593fce964f3892b9c656db 100755 (executable)
@@ -87,6 +87,7 @@ if ($server_arg && ! -d "$testdir/$server_arg") {
 }
 
 my $NAMED = $ENV{'NAMED'};
+my $LWRESD = $ENV{'LWRESD'};
 my $DIG = $ENV{'DIG'};
 my $PERL = $ENV{'PERL'};
 my $PYTHON = $ENV{'PYTHON'};
@@ -95,12 +96,15 @@ my $PYTHON = $ENV{'PYTHON'};
 
 my @ns;
 my @ans;
+my @lwresd;
 
 if ($server_arg) {
        if ($server_arg =~ /^ns/) {
                push(@ns, $server_arg);
        } elsif ($server_arg =~ /^ans/) {
                push(@ans, $server_arg);
+       } elsif ($server_arg =~ /^lwresd/) {
+               push(@lwresd, $server_arg);
        } else {
                print "$0: ns or ans directory expected";
                print "I:$test:failed";
@@ -113,6 +117,7 @@ if ($server_arg) {
 
        @ns = grep /^ns[0-9]*$/, @files;
        @ans = grep /^ans[0-9]*$/, @files;
+       @lwresd = grep /^lwresd[0-9]*$/, @files;
 }
 
 # Start the servers we found.
@@ -127,6 +132,10 @@ foreach my $name(@ans) {
        &start_ans_server($name);
 }
 
+foreach my $name(@lwresd) {
+       &start_lwresd_server($name, $options_arg);
+}
+
 # Subroutines
 
 sub read_ns_port {
@@ -360,6 +369,83 @@ sub start_ans_server {
        start_server($server, $command, $pid_file);
 }
 
+sub construct_lwresd_command {
+       my ( $server, $options ) = @_;
+
+       my $command;
+
+       if ($ENV{'USE_VALGRIND'}) {
+               $command = "valgrind -q --gen-suppressions=all --num-callers=48 --fullpath-after= --log-file=lwresd-$server-valgrind-%p.log ";
+
+               if ($ENV{'USE_VALGRIND'} eq 'helgrind') {
+                       $command .= "--tool=helgrind ";
+               } else {
+                       $command .= "--tool=memcheck --track-origins=yes --leak-check=full ";
+               }
+
+               $command .= "$LWRESD -m none -M external ";
+       } else {
+               $command = "$LWRESD ";
+       }
+
+       my $args_file = $testdir . "/" . $server . "/" . "lwresd.args";
+
+       if ($options) {
+               $command .= $options;
+       } elsif (-e $args_file) {
+               open(my $fh, "<", $args_file) or die "unable to read args_file \"$args_file\" ($OS_ERROR)\n";
+
+               while(my $line=<$fh>) {
+                       next if ($line =~ /^\s*$/); #discard blank lines
+                       next if ($line =~ /^\s*#/); #discard comment lines
+
+                       chomp $line;
+
+                       $line =~ s/#.*$//;
+
+                       $command .= $line;
+
+                       last;
+               }
+       } else {
+               $command .= "-C resolv.conf ";
+               $command .= "-D $test-$server ";
+               $command .= "-X lwresd.lock ";
+               $command .= "-m record,size,mctx ";
+               $command .= "-T clienttest ";
+               $command .= "-d 99 -g -U 4 ";
+               $command .= "-i lwresd.pid -P 9210 -p 5300";
+       }
+       if ($restart) {
+               $command .= " >>lwresd.run 2>&1 &";
+       } else {
+               $command .= " >lwresd.run 2>&1 &";
+       }
+
+       # get the shell to report the pid of the server ($!)
+       $command .= " echo \$!";
+
+       return $command;
+}
+
+sub start_lwresd_server {
+       my ( $server, $options ) = @_;
+
+       my $cleanup_files;
+       my $command;
+       my $pid_file;
+
+       $cleanup_files = "{lwresd.run}";
+       $command = construct_lwresd_command($server, $options);
+       $pid_file = "lwresd.pid";
+
+       if ($clean) {
+               unlink glob $cleanup_files;
+       }
+
+       start_server($server, $command, $pid_file);
+}
+
 sub verify_ns_server {
        my ( $server ) = @_;
 
index a0ebc95d7ddf9f526eb90f94f130bcfb152d290f..a96f33b8a814be486e59a1218d48896cf1765782 100644 (file)
@@ -69,12 +69,15 @@ my $RNDC = $ENV{RNDC};
 
 my @ns;
 my @ans;
+my @lwresd;
 
 if ($server_arg) {
        if ($server_arg =~ /^ns/) {
                push(@ns, $server_arg);
        } elsif ($server_arg =~ /^ans/) {
                push(@ans, $server_arg);
+       } elsif ($server_arg =~ /^lwresd/) {
+               push(@lwresd, $server_arg);
        } else {
                print "$0: ns or ans directory expected";
                print "I:$test:failed";
@@ -87,6 +90,7 @@ if ($server_arg) {
 
        @ns = grep /^ns[0-9]*$/, @files;
        @ans = grep /^ans[0-9]*$/, @files;
+       @lwresd = grep /^lwresd[0-9]*$/, @files;
 }
 
 # Stop the server(s), pass 1: rndc.
@@ -111,8 +115,14 @@ foreach my $name(@ans) {
 
 @ans = wait_for_servers(60, @ans);
 
+foreach my $name(@lwresd) {
+       stop_signal($name, "TERM");
+}
+
+@lwresd = wait_for_servers(60, @lwresd);
+
 # Pass 3: SIGABRT
-foreach my $name (@ns, @ans) {
+foreach my $name (@ns, @ans, @lwresd) {
        print "I:$test:$name didn't die when sent a SIGTERM\n";
        stop_signal($name, "ABRT");
        $errors = 1;
@@ -128,6 +138,7 @@ sub server_pid_file {
 
        return $testdir . "/" . $server . "/named.pid" if ($server =~ /^ns/);
        return $testdir . "/" . $server . "/ans.pid" if ($server =~ /^ans/);
+       return $testdir . "/" . $server . "/lwresd.pid" if ($server =~ /^lwresd/);
 
        die "Unknown server type $server\n";
 }