if the server is already running when the script is started, it now verifies
that it actually is our test server that runs
This commit is contained in:
parent
bfb118e42a
commit
1cc8af2779
@ -80,31 +80,39 @@ for ( $waitedpid = 0;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
if($path =~ /verifiedserver/) {
|
||||||
# we always start the path with a number, this is the
|
# this is a hard-coded query-string for the test script
|
||||||
# test number that this server will use to know what
|
# to verify that this is the server actually running!
|
||||||
# contents to pass back to the client
|
print "HTTP/1.1 999 WE ROOLZ\r\n";
|
||||||
#
|
|
||||||
if($path =~ /.*\/(\d*)/) {
|
|
||||||
$testnum=$1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
print STDERR "UKNOWN TEST CASE\n";
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
open(INPUT, ">log/server.input");
|
else {
|
||||||
for(@headers) {
|
|
||||||
print INPUT $_;
|
|
||||||
}
|
|
||||||
close(INPUT);
|
|
||||||
|
|
||||||
# send a reply to the client
|
#
|
||||||
open(DATA, "<data/reply$testnum.txt");
|
# we always start the path with a number, this is the
|
||||||
while(<DATA>) {
|
# test number that this server will use to know what
|
||||||
print $_;
|
# contents to pass back to the client
|
||||||
|
#
|
||||||
|
if($path =~ /.*\/(\d*)/) {
|
||||||
|
$testnum=$1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print STDERR "UKNOWN TEST CASE\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
open(INPUT, ">log/server.input");
|
||||||
|
for(@headers) {
|
||||||
|
print INPUT $_;
|
||||||
|
}
|
||||||
|
close(INPUT);
|
||||||
|
|
||||||
|
# send a reply to the client
|
||||||
|
open(DATA, "<data/reply$testnum.txt");
|
||||||
|
while(<DATA>) {
|
||||||
|
print $_;
|
||||||
|
}
|
||||||
|
close(DATA);
|
||||||
}
|
}
|
||||||
close(DATA);
|
|
||||||
|
|
||||||
# print "Hello there, $name, it's now ", scalar localtime, "\r\n";
|
# print "Hello there, $name, it's now ", scalar localtime, "\r\n";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ stopserver() {
|
|||||||
if [ -f $PIDFILE ] ; then
|
if [ -f $PIDFILE ] ; then
|
||||||
PID=`cat $PIDFILE`
|
PID=`cat $PIDFILE`
|
||||||
kill -9 $PID
|
kill -9 $PID
|
||||||
|
rm -f $PIDFILE # server is killed
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +56,18 @@ runserver () {
|
|||||||
sleep 1 # give it a little time to start
|
sleep 1 # give it a little time to start
|
||||||
else
|
else
|
||||||
echo $STATUS
|
echo $STATUS
|
||||||
|
|
||||||
|
# verify that our server is one one running on this port:
|
||||||
|
data=`$CURL --silent -i $HOSTIP:$HOSTPORT/verifiedserver`;
|
||||||
|
|
||||||
|
if { echo $data | grep -v "WE ROOLZ" >/dev/null 2>&1; } then
|
||||||
|
echo "Another HTTP server is running on port $HOSTPORT"
|
||||||
|
echo "Edit runtests.sh to use another port and rerun the test script"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "The running HTTP server has been verified to be our test server"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user