tests: run the RTSP test server on a dynamic port number

To avoid port collisions.

Closes #5272
This commit is contained in:
Daniel Stenberg 2020-04-20 14:53:50 +02:00
parent 018dd775c8
commit bae87dc0d9
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 77 additions and 21 deletions

View file

@ -2025,7 +2025,6 @@ sub runtftpserver {
#
sub runrtspserver {
my ($verbose, $ipv6) = @_;
my $port = $RTSPPORT;
my $ip = $HOSTIP;
my $proto = 'rtsp';
my $ipvnum = 4;
@ -2039,13 +2038,13 @@ sub runrtspserver {
if($ipv6) {
# if IPv6, use a different setup
$ipvnum = 6;
$port = $RTSP6PORT;
$ip = $HOST6IP;
}
$server = servername_id($proto, $ipvnum, $idnum);
$pidfile = $serverpidfile{$server};
my $portfile = $serverportfile{$server};
# don't retry if the server doesn't work
if ($doesntrun{$pidfile}) {
@ -2063,9 +2062,11 @@ sub runrtspserver {
$logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
$flags .= "--verbose " if($debugprotocol);
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
$flags .= "--pidfile \"$pidfile\" ".
"--portfile \"$portfile\" ".
"--logfile \"$logfile\" ";
$flags .= "--id $idnum " if($idnum > 1);
$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
$flags .= "--ipv$ipvnum --port 0 --srcdir \"$srcdir\"";
my $cmd = "$perl $srcdir/rtspserver.pl $flags";
my ($rtsppid, $pid2) = startnew($cmd, $pidfile, 15, 0);
@ -2079,6 +2080,8 @@ sub runrtspserver {
return (0,0);
}
my $port = pidfromfile($portfile);
# Server is up. Verify that we can speak to it.
my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port);
if(!$pid3) {
@ -2092,12 +2095,12 @@ sub runrtspserver {
$pid2 = $pid3;
if($verbose) {
logmsg "RUN: $srvrname server is now running PID $rtsppid\n";
logmsg "RUN: $srvrname server PID $rtsppid port $port\n";
}
sleep(1);
return ($rtsppid, $pid2);
return ($rtsppid, $pid2, $port);
}
@ -3154,14 +3157,10 @@ sub checksystem {
if($verbose) {
logmsg "* Ports: ";
logmsg sprintf("RTSP/%d ", $RTSPPORT);
if($stunnel) {
logmsg sprintf("FTPS/%d ", $FTPSPORT);
logmsg sprintf("HTTPS/%d ", $HTTPSPORT);
}
if($http_ipv6) {
logmsg sprintf("RTSP-IPv6/%d ", $RTSP6PORT);
}
logmsg sprintf("\n* SSH/%d ", $SSHPORT);
if($httptlssrv) {
logmsg sprintf("HTTPTLS/%d ", $HTTPTLSPORT);
@ -4718,7 +4717,7 @@ sub startservers {
stopserver('rtsp');
}
if(!$run{'rtsp'}) {
($pid, $pid2) = runrtspserver($verbose);
($pid, $pid2, $RTSPPORT) = runrtspserver($verbose);
if($pid <= 0) {
return "failed starting RTSP server";
}
@ -4732,7 +4731,7 @@ sub startservers {
stopserver('rtsp-ipv6');
}
if(!$run{'rtsp-ipv6'}) {
($pid, $pid2) = runrtspserver($verbose, "ipv6");
($pid, $pid2, $RTSP6PORT) = runrtspserver($verbose, "ipv6");
if($pid <= 0) {
return "failed starting RTSP-IPv6 server";
}
@ -5446,8 +5445,6 @@ $minport = $base; # original base port number
$HTTPSPORT = $base++; # HTTPS (stunnel) server port
$FTPSPORT = $base++; # FTPS (stunnel) server port
$SSHPORT = $base++; # SSH (SCP/SFTP) port
$RTSPPORT = $base++; # RTSP server port
$RTSP6PORT = $base++; # RTSP IPv6 server port
$HTTPTLSPORT = $base++; # HTTP TLS (non-stunnel) server port
$HTTPTLS6PORT = $base++; # HTTP TLS (non-stunnel) IPv6 server port
$HTTP2PORT = $base++; # HTTP/2 port