testminiwget.sh: don't get stuck if the http test server does not starts

This commit is contained in:
Thomas Bernard 2017-11-02 17:53:33 +01:00
parent 6ce6a70973
commit 38a20e4849
3 changed files with 33 additions and 15 deletions

View File

@ -1,7 +1,7 @@
/* $Id: minihttptestserver.c,v 1.19 2015/11/17 09:07:17 nanard Exp $ */
/* $Id: minihttptestserver.c,v 1.21 2017/11/02 16:52:37 nanard Exp $ */
/* Project : miniUPnP
* Author : Thomas Bernard
* Copyright (c) 2011-2016 Thomas Bernard
* Copyright (c) 2011-2017 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided in this distribution.
* */
@ -24,6 +24,8 @@
#define CRAP_LENGTH (2048)
static int server(unsigned short port, const char * expected_file_name, int ipv6);
volatile sig_atomic_t quit = 0;
volatile sig_atomic_t child_to_wait_for = 0;
@ -485,17 +487,9 @@ void handle_http_connection(int c)
*/
int main(int argc, char * * argv) {
int ipv6 = 0;
int s, c, i;
int r, i;
unsigned short port = 0;
struct sockaddr_storage server_addr;
socklen_t server_addrlen;
struct sockaddr_storage client_addr;
socklen_t client_addrlen;
pid_t pid;
int child = 0;
int status;
const char * expected_file_name = NULL;
struct sigaction sa;
for(i = 1; i < argc; i++) {
if(argv[i][0] == '-') {
@ -523,6 +517,26 @@ int main(int argc, char * * argv) {
srand(time(NULL));
r = server(port, expected_file_name, ipv6);
if(r != 0) {
printf("*** ERROR ***\n");
}
return r;
}
static int server(unsigned short port, const char * expected_file_name, int ipv6)
{
int s, c;
int i;
struct sockaddr_storage server_addr;
socklen_t server_addrlen;
struct sockaddr_storage client_addr;
socklen_t client_addrlen;
pid_t pid;
int child = 0;
int status;
struct sigaction sa;
memset(&sa, 0, sizeof(struct sigaction));
/*signal(SIGCHLD, handle_signal_chld);*/

View File

@ -1,7 +1,7 @@
/* $Id: testminiwget.c,v 1.5 2016/01/24 17:24:36 nanard Exp $ */
/* $Id: testminiwget.c,v 1.6 2017/11/02 16:52:37 nanard Exp $ */
/* Project : miniupnp
* Author : Thomas Bernard
* Copyright (c) 2005-2016 Thomas Bernard
* Copyright (c) 2005-2017 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided in this distribution.
* */

View File

@ -1,7 +1,7 @@
#!/bin/sh
# $Id: testminiwget.sh,v 1.13 2015/09/03 17:57:44 nanard Exp $
# $Id: testminiwget.sh,v 1.14 2017/11/02 16:52:37 nanard Exp $
# project miniupnp : http://miniupnp.free.fr/
# (c) 2011-2015 Thomas Bernard
# (c) 2011-2017 Thomas Bernard
#
# test program for miniwget.c
# is usually invoked by "make check"
@ -44,6 +44,10 @@ while [ -z "$PORT" ]; do
sleep 1
PORT=`cat $HTTPSERVEROUT | sed 's/Listening on port \([0-9]*\)/\1/' `
done
if [ "$PORT" = "*** ERROR ***" ]; then
echo "HTTP test server error"
exit 2
fi
echo "Test HTTP server is listening on $PORT"
URL1="http://$ADDR:$PORT/index.html"