Backed out updated libcurl.

This commit is contained in:
Asher Baker
2013-03-18 00:55:59 +00:00
parent 9b65900df0
commit e84f6e4afd
1511 changed files with 161513 additions and 213368 deletions
@@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
# Copyright (C) 1998 - 2008, Daniel Stenberg, <[email protected]>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -18,6 +18,7 @@
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# $Id: Makefile.am,v 1.78 2008-11-11 21:59:25 bagder Exp $
###########################################################################
AUTOMAKE_OPTIONS = foreign nostdinc
@@ -26,83 +27,146 @@ AUTOMAKE_OPTIONS = foreign nostdinc
# being currently built and tested are searched before the library which
# might possibly already be installed in the system.
#
# $(top_builddir)/include/curl for generated curlbuild.h included from curl.h
# $(top_builddir)/include for generated curlbuild.h inc. from lib/curl_setup.h
# $(top_builddir)/include is for libcurl's generated curl/curlbuild.h file
# $(top_srcdir)/include is for libcurl's external include files
# $(top_builddir)/lib is for libcurl's generated lib/curl_config.h file
# $(top_srcdir)/lib for libcurl's lib/curl_setup.h and other "borrowed" files
# $(top_builddir)/ares is for in-tree c-ares's generated ares_build.h file
# $(top_srcdir)/ares is for in-tree c-ares's external include files
# $(top_builddir)/lib is for libcurl's generated lib/config.h file
# $(top_srcdir)/lib is for libcurl's lib/setup.h and other "borrowed" files
if USE_EMBEDDED_ARES
AM_CPPFLAGS = -I$(top_builddir)/include/curl \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib \
-I$(top_builddir)/ares \
-I$(top_srcdir)/ares
else
AM_CPPFLAGS = -I$(top_builddir)/include/curl \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib
endif
INCLUDES = -I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib
EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \
test1022.pl Makefile.inc notexists.pl
LIBDIR = $(top_builddir)/lib
CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@
EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl test1022.pl
# Prevent LIBS from being used for all link targets
LIBS = $(BLANK_AT_MAKETIME)
# files used only in some libcurl test programs
TESTUTIL = testutil.c testutil.h
if USE_EXPLICIT_LIB_DEPS
SUPPORTFILES_LIBS = $(top_builddir)/lib/libcurl.la @LIBCURL_LIBS@
TESTUTIL_LIBS = $(top_builddir)/lib/libcurl.la @LIBCURL_LIBS@
else
SUPPORTFILES_LIBS = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_LIBS@
TESTUTIL_LIBS = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@
endif
# these files are used in every single test program below
SUPPORTFILES = first.c test.h
# These are all libcurl test programs
noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \
lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \
lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \
lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \
lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \
lib539 lib557 lib558 lib559 lib560
# Dependencies (may need to be overriden)
LDADD = $(SUPPORTFILES_LIBS)
DEPENDENCIES = $(top_builddir)/lib/libcurl.la
LDADD = $(LIBDIR)/libcurl.la
DEPENDENCIES = $(LIBDIR)/libcurl.la
# Mostly for Windows build targets, when using static libcurl
if USE_CPPFLAG_CURL_STATICLIB
AM_CPPFLAGS += -DCURL_STATICLIB
endif
# Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES,
# noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS)
include Makefile.inc
lib500_SOURCES = lib500.c $(SUPPORTFILES)
# Preloading of libhostname allows host name overriding,
# this is used to make some tests machine independent.
lib501_SOURCES = lib501.c $(SUPPORTFILES)
if BUILD_LIBHOSTNAME
noinst_LTLIBRARIES = libhostname.la
else
noinst_LTLIBRARIES =
endif
lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL)
if NO_UNDEFINED
# The -no-undefined flag is crucial to build fine on some platforms
UNDEF = -no-undefined
endif
lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL)
libhostname_la_SOURCES = sethostname.c sethostname.h
lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL)
libhostname_la_LIBADD =
libhostname_la_DEPENDENCIES =
libhostname_la_LDFLAGS = -module -avoid-version $(UNDEF) -rpath /nowhere
lib505_SOURCES = lib505.c $(SUPPORTFILES)
if DOING_CURL_SYMBOL_HIDING
libhostname_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_HIDDEN_SYMBOLS
libhostname_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_CURL_SYMBOL_HIDING)
else
libhostname_la_CPPFLAGS = $(AM_CPPFLAGS)
libhostname_la_CFLAGS = $(AM_CFLAGS)
endif
lib506_SOURCES = lib506.c $(SUPPORTFILES)
lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL)
lib508_SOURCES = lib508.c $(SUPPORTFILES)
lib510_SOURCES = lib510.c $(SUPPORTFILES)
lib511_SOURCES = lib511.c $(SUPPORTFILES)
lib512_SOURCES = lib512.c $(SUPPORTFILES)
lib513_SOURCES = lib513.c $(SUPPORTFILES)
lib514_SOURCES = lib514.c $(SUPPORTFILES)
lib515_SOURCES = lib515.c $(SUPPORTFILES)
lib516_SOURCES = lib516.c $(SUPPORTFILES)
lib517_SOURCES = lib517.c $(SUPPORTFILES)
lib518_SOURCES = lib518.c $(SUPPORTFILES)
lib519_SOURCES = lib519.c $(SUPPORTFILES)
lib520_SOURCES = lib520.c $(SUPPORTFILES)
lib521_SOURCES = lib521.c $(SUPPORTFILES)
lib523_SOURCES = lib523.c $(SUPPORTFILES)
lib524_SOURCES = lib524.c $(SUPPORTFILES)
lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL)
lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
lib526_CFLAGS = -DLIB526
lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
lib527_CFLAGS = -DLIB527
lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL)
lib529_CFLAGS = -DLIB529
lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL)
lib530_CFLAGS = -DLIB530
lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
lib532_CFLAGS = -DLIB532
lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL)
lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL)
lib537_SOURCES = lib537.c $(SUPPORTFILES)
lib539_SOURCES = lib539.c $(SUPPORTFILES)
lib540_SOURCES = lib540.c $(SUPPORTFILES)
lib541_SOURCES = lib541.c $(SUPPORTFILES)
lib542_SOURCES = lib542.c $(SUPPORTFILES)
lib543_SOURCES = lib543.c $(SUPPORTFILES)
lib544_SOURCES = lib544.c $(SUPPORTFILES)
lib545_SOURCES = lib544.c $(SUPPORTFILES)
lib545_CFLAGS = -DLIB545
lib547_SOURCES = lib547.c $(SUPPORTFILES)
lib548_SOURCES = lib547.c $(SUPPORTFILES)
lib548_CFLAGS = -DLIB548
lib549_SOURCES = lib549.c $(SUPPORTFILES)
lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL)
lib552_SOURCES = lib552.c $(SUPPORTFILES)
lib553_SOURCES = lib553.c $(SUPPORTFILES)
lib554_SOURCES = lib554.c $(SUPPORTFILES)
lib556_SOURCES = lib556.c $(SUPPORTFILES)
lib557_SOURCES = lib557.c $(SUPPORTFILES)
lib558_SOURCES = lib558.c $(SUPPORTFILES)
lib558_CFLAGS = -DLIB558
lib559_SOURCES = lib558.c $(SUPPORTFILES)
lib559_CFLAGS = -DLIB559
lib560_SOURCES = lib560.c $(SUPPORTFILES)
File diff suppressed because it is too large Load Diff
@@ -1,314 +0,0 @@
# files used only in some libcurl test programs
TESTUTIL = testutil.c testutil.h
# files used only in some libcurl test programs
TSTTRACE = testtrace.c testtrace.h
# files used only in some libcurl test programs
WARNLESS = ../../lib/warnless.c ../../lib/warnless.h
# these files are used in every single test program below
SUPPORTFILES = first.c test.h
# These are all libcurl test programs
noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 lib508 \
lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 lib518 lib519 \
lib520 lib521 lib523 lib524 lib525 lib526 lib527 lib529 \
lib530 lib532 lib533 lib536 lib537 lib539 \
lib540 lib541 lib542 lib543 lib544 lib545 lib547 lib548 lib549 \
lib552 lib553 lib554 lib555 lib556 lib557 \
lib560 lib562 lib564 lib565 lib566 lib567 lib568 lib569 \
lib570 lib571 lib572 lib573 lib574 lib575 lib576 lib578 lib579 \
lib582 lib583 lib585 lib586 lib587 \
lib590 lib591 lib597 lib598 lib599 \
\
lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506
chkhostname_SOURCES = chkhostname.c ../../lib/curl_gethostname.c
chkhostname_LDADD = @CURL_NETWORK_LIBS@
chkhostname_DEPENDENCIES =
chkhostname_CPPFLAGS = $(AM_CPPFLAGS)
libntlmconnect_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
libntlmconnect_LDADD = $(TESTUTIL_LIBS)
libntlmconnect_CPPFLAGS = $(AM_CPPFLAGS)
libauthretry_SOURCES = libauthretry.c $(SUPPORTFILES)
libauthretry_CPPFLAGS = $(AM_CPPFLAGS)
lib500_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE)
lib500_LDADD = $(TESTUTIL_LIBS)
lib500_CPPFLAGS = $(AM_CPPFLAGS)
lib501_SOURCES = lib501.c $(SUPPORTFILES)
lib501_CPPFLAGS = $(AM_CPPFLAGS)
lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib502_LDADD = $(TESTUTIL_LIBS)
lib502_CPPFLAGS = $(AM_CPPFLAGS)
lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib503_LDADD = $(TESTUTIL_LIBS)
lib503_CPPFLAGS = $(AM_CPPFLAGS)
lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib504_LDADD = $(TESTUTIL_LIBS)
lib504_CPPFLAGS = $(AM_CPPFLAGS)
lib505_SOURCES = lib505.c $(SUPPORTFILES)
lib505_CPPFLAGS = $(AM_CPPFLAGS)
lib506_SOURCES = lib506.c $(SUPPORTFILES)
lib506_CPPFLAGS = $(AM_CPPFLAGS)
lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib507_LDADD = $(TESTUTIL_LIBS)
lib507_CPPFLAGS = $(AM_CPPFLAGS)
lib508_SOURCES = lib508.c $(SUPPORTFILES)
lib508_CPPFLAGS = $(AM_CPPFLAGS)
lib510_SOURCES = lib510.c $(SUPPORTFILES)
lib510_CPPFLAGS = $(AM_CPPFLAGS)
lib511_SOURCES = lib511.c $(SUPPORTFILES)
lib511_CPPFLAGS = $(AM_CPPFLAGS)
lib512_SOURCES = lib512.c $(SUPPORTFILES)
lib512_CPPFLAGS = $(AM_CPPFLAGS)
lib513_SOURCES = lib513.c $(SUPPORTFILES)
lib513_CPPFLAGS = $(AM_CPPFLAGS)
lib514_SOURCES = lib514.c $(SUPPORTFILES)
lib514_CPPFLAGS = $(AM_CPPFLAGS)
lib515_SOURCES = lib515.c $(SUPPORTFILES)
lib515_CPPFLAGS = $(AM_CPPFLAGS)
lib516_SOURCES = lib516.c $(SUPPORTFILES)
lib516_CPPFLAGS = $(AM_CPPFLAGS)
lib517_SOURCES = lib517.c $(SUPPORTFILES)
lib517_CPPFLAGS = $(AM_CPPFLAGS)
lib518_SOURCES = lib518.c $(SUPPORTFILES) $(WARNLESS)
lib518_CPPFLAGS = $(AM_CPPFLAGS)
lib519_SOURCES = lib519.c $(SUPPORTFILES)
lib519_CPPFLAGS = $(AM_CPPFLAGS)
lib520_SOURCES = lib520.c $(SUPPORTFILES)
lib520_CPPFLAGS = $(AM_CPPFLAGS)
lib521_SOURCES = lib521.c $(SUPPORTFILES)
lib521_CPPFLAGS = $(AM_CPPFLAGS)
lib523_SOURCES = lib523.c $(SUPPORTFILES)
lib523_CPPFLAGS = $(AM_CPPFLAGS)
lib524_SOURCES = lib524.c $(SUPPORTFILES)
lib524_CPPFLAGS = $(AM_CPPFLAGS)
lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib525_LDADD = $(TESTUTIL_LIBS)
lib525_CPPFLAGS = $(AM_CPPFLAGS)
lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib526_LDADD = $(TESTUTIL_LIBS)
lib526_CPPFLAGS = $(AM_CPPFLAGS) -DLIB526
lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib527_LDADD = $(TESTUTIL_LIBS)
lib527_CPPFLAGS = $(AM_CPPFLAGS) -DLIB527
lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib529_LDADD = $(TESTUTIL_LIBS)
lib529_CPPFLAGS = $(AM_CPPFLAGS) -DLIB529
lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib530_LDADD = $(TESTUTIL_LIBS)
lib530_CPPFLAGS = $(AM_CPPFLAGS) -DLIB530
lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib532_LDADD = $(TESTUTIL_LIBS)
lib532_CPPFLAGS = $(AM_CPPFLAGS) -DLIB532
lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib533_LDADD = $(TESTUTIL_LIBS)
lib533_CPPFLAGS = $(AM_CPPFLAGS)
lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib536_LDADD = $(TESTUTIL_LIBS)
lib536_CPPFLAGS = $(AM_CPPFLAGS)
lib537_SOURCES = lib537.c $(SUPPORTFILES) $(WARNLESS)
lib537_CPPFLAGS = $(AM_CPPFLAGS)
lib539_SOURCES = lib539.c $(SUPPORTFILES)
lib539_CPPFLAGS = $(AM_CPPFLAGS)
lib540_SOURCES = lib540.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib540_LDADD = $(TESTUTIL_LIBS)
lib540_CPPFLAGS = $(AM_CPPFLAGS)
lib541_SOURCES = lib541.c $(SUPPORTFILES)
lib541_CPPFLAGS = $(AM_CPPFLAGS)
lib542_SOURCES = lib542.c $(SUPPORTFILES)
lib542_CPPFLAGS = $(AM_CPPFLAGS)
lib543_SOURCES = lib543.c $(SUPPORTFILES)
lib543_CPPFLAGS = $(AM_CPPFLAGS)
lib544_SOURCES = lib544.c $(SUPPORTFILES)
lib544_CPPFLAGS = $(AM_CPPFLAGS)
lib545_SOURCES = lib544.c $(SUPPORTFILES)
lib545_CPPFLAGS = $(AM_CPPFLAGS) -DLIB545
lib547_SOURCES = lib547.c $(SUPPORTFILES)
lib547_CPPFLAGS = $(AM_CPPFLAGS)
lib548_SOURCES = lib547.c $(SUPPORTFILES)
lib548_CPPFLAGS = $(AM_CPPFLAGS) -DLIB548
lib549_SOURCES = lib549.c $(SUPPORTFILES)
lib549_CPPFLAGS = $(AM_CPPFLAGS)
lib552_SOURCES = lib552.c $(SUPPORTFILES) $(WARNLESS)
lib552_CPPFLAGS = $(AM_CPPFLAGS)
lib553_SOURCES = lib553.c $(SUPPORTFILES)
lib553_CPPFLAGS = $(AM_CPPFLAGS)
lib554_SOURCES = lib554.c $(SUPPORTFILES)
lib554_CPPFLAGS = $(AM_CPPFLAGS)
lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib555_LDADD = $(TESTUTIL_LIBS)
lib555_CPPFLAGS = $(AM_CPPFLAGS)
lib556_SOURCES = lib556.c $(SUPPORTFILES)
lib556_CPPFLAGS = $(AM_CPPFLAGS)
lib557_SOURCES = lib557.c $(SUPPORTFILES)
lib557_CPPFLAGS = $(AM_CPPFLAGS)
lib560_SOURCES = lib560.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib560_LDADD = $(TESTUTIL_LIBS)
lib560_CPPFLAGS = $(AM_CPPFLAGS)
lib562_SOURCES = lib562.c $(SUPPORTFILES)
lib562_CPPFLAGS = $(AM_CPPFLAGS)
lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib564_LDADD = $(TESTUTIL_LIBS)
lib564_CPPFLAGS = $(AM_CPPFLAGS)
lib565_SOURCES = lib510.c $(SUPPORTFILES)
lib565_CPPFLAGS = $(AM_CPPFLAGS) -DLIB565
lib566_SOURCES = lib566.c $(SUPPORTFILES)
lib566_CPPFLAGS = $(AM_CPPFLAGS)
lib567_SOURCES = lib567.c $(SUPPORTFILES)
lib567_CPPFLAGS = $(AM_CPPFLAGS)
lib568_SOURCES = lib568.c $(SUPPORTFILES)
lib568_CPPFLAGS = $(AM_CPPFLAGS)
lib569_SOURCES = lib569.c $(SUPPORTFILES)
lib569_CPPFLAGS = $(AM_CPPFLAGS)
lib570_SOURCES = lib570.c $(SUPPORTFILES)
lib570_CPPFLAGS = $(AM_CPPFLAGS)
lib571_SOURCES = lib571.c $(SUPPORTFILES) $(WARNLESS)
lib571_CPPFLAGS = $(AM_CPPFLAGS)
lib572_SOURCES = lib572.c $(SUPPORTFILES)
lib572_CPPFLAGS = $(AM_CPPFLAGS)
lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(TSTTRACE)
lib573_LDADD = $(TESTUTIL_LIBS)
lib573_CPPFLAGS = $(AM_CPPFLAGS)
lib574_SOURCES = lib574.c $(SUPPORTFILES)
lib574_CPPFLAGS = $(AM_CPPFLAGS)
lib575_SOURCES = lib575.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib575_LDADD = $(TESTUTIL_LIBS)
lib575_CPPFLAGS = $(AM_CPPFLAGS)
lib576_SOURCES = lib576.c $(SUPPORTFILES)
lib576_CPPFLAGS = $(AM_CPPFLAGS)
lib578_SOURCES = lib578.c $(SUPPORTFILES)
lib578_CPPFLAGS = $(AM_CPPFLAGS)
lib579_SOURCES = lib579.c $(SUPPORTFILES)
lib579_CPPFLAGS = $(AM_CPPFLAGS)
lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib582_LDADD = $(TESTUTIL_LIBS)
lib582_CPPFLAGS = $(AM_CPPFLAGS)
lib583_SOURCES = lib583.c $(SUPPORTFILES)
lib583_CPPFLAGS = $(AM_CPPFLAGS)
lib585_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE)
lib585_LDADD = $(TESTUTIL_LIBS)
lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585
lib586_SOURCES = lib586.c $(SUPPORTFILES)
lib586_CPPFLAGS = $(AM_CPPFLAGS)
lib587_SOURCES = lib554.c $(SUPPORTFILES)
lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587
lib590_SOURCES = lib590.c $(SUPPORTFILES)
lib590_CPPFLAGS = $(AM_CPPFLAGS)
lib591_SOURCES = lib591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib591_LDADD = $(TESTUTIL_LIBS)
lib591_CPPFLAGS = $(AM_CPPFLAGS)
lib597_SOURCES = lib597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib597_LDADD = $(TESTUTIL_LIBS)
lib597_CPPFLAGS = $(AM_CPPFLAGS)
lib598_SOURCES = lib598.c $(SUPPORTFILES)
lib598_CPPFLAGS = $(AM_CPPFLAGS)
lib599_SOURCES = lib599.c $(SUPPORTFILES)
lib599_CPPFLAGS = $(AM_CPPFLAGS)
lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL)
lib1500_LDADD = $(TESTUTIL_LIBS)
lib1500_CPPFLAGS = $(AM_CPPFLAGS)
lib1501_SOURCES = lib1501.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1501_LDADD = $(TESTUTIL_LIBS)
lib1501_CPPFLAGS = $(AM_CPPFLAGS)
lib1502_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1502_LDADD = $(TESTUTIL_LIBS)
lib1502_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1502
lib1503_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1503_LDADD = $(TESTUTIL_LIBS)
lib1503_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1503
lib1504_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1504_LDADD = $(TESTUTIL_LIBS)
lib1504_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1504
lib1505_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1505_LDADD = $(TESTUTIL_LIBS)
lib1505_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1505
lib1506_SOURCES = lib1506.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1506_LDADD = $(TESTUTIL_LIBS)
lib1506_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1506
@@ -1,47 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curl_setup.h"
#include "curl_gethostname.h"
#define HOSTNAME_MAX 1024
int main(int argc, char *argv[])
{
char buff[HOSTNAME_MAX];
if (argc != 2) {
printf("Usage: %s EXPECTED_HOSTNAME\n", argv[0]);
return 1;
}
if (Curl_gethostname(buff, HOSTNAME_MAX)) {
printf("Curl_gethostname() failed\n");
return 1;
}
/* compare the name returned by Curl_gethostname() with the expected one */
if(strncmp(buff, argv[1], HOSTNAME_MAX)) {
printf("got unexpected host name back, LD_PRELOAD failed\n");
return 1;
}
return 0;
}
+29 -78
View File
@@ -1,54 +1,33 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
* $Id: first.c,v 1.19 2008-09-20 04:26:55 yangtse Exp $
*/
#ifdef HAVE_LOCALE_H
#include <locale.h> /* for setlocale() */
#endif
#include "test.h"
#ifdef CURLDEBUG
# define MEMDEBUG_NODEFINES
# include "memdebug.h"
#endif
int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
struct timeval *tv)
int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc,
struct timeval *tv)
{
if(nfds < 0) {
SET_SOCKERRNO(EINVAL);
return -1;
}
#ifdef USE_WINSOCK
/*
* Winsock select() requires that at least one of the three fd_set
* pointers is not NULL and points to a non-empty fdset. IOW Winsock
* select() can not be used to sleep without a single fd_set.
/* Winsock doesn't like no socket set in 'rd', 'wr' or 'exc'. This is
* case when 'num_fds <= 0. So sleep.
*/
if(!nfds) {
if (num_fds <= 0) {
Sleep(1000*tv->tv_sec + tv->tv_usec/1000);
return 0;
}
#endif
return select(nfds, rd, wr, exc, tv);
return select(num_fds, rd, wr, exc, tv);
}
char *libtest_arg2=NULL;
@@ -56,59 +35,31 @@ char *libtest_arg3=NULL;
int test_argc;
char **test_argv;
struct timeval tv_test_start; /* for test timing */
#ifdef UNITTESTS
int unitfail; /* for unittests */
#endif
#ifdef CURLDEBUG
static void memory_tracking_init(void)
{
char *env;
/* if CURL_MEMDEBUG is set, this starts memory tracking message logging */
env = curl_getenv("CURL_MEMDEBUG");
if(env) {
/* use the value as file name */
char fname[CURL_MT_LOGFNAME_BUFSIZE];
if(strlen(env) >= CURL_MT_LOGFNAME_BUFSIZE)
env[CURL_MT_LOGFNAME_BUFSIZE-1] = '\0';
strcpy(fname, env);
curl_free(env);
curl_memdebug(fname);
/* this weird stuff here is to make curl_free() get called
before curl_memdebug() as otherwise memory tracking will
log a free() without an alloc! */
}
/* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */
env = curl_getenv("CURL_MEMLIMIT");
if(env) {
char *endptr;
long num = strtol(env, &endptr, 10);
if((endptr != env) && (endptr == env + strlen(env)) && (num > 0))
curl_memlimit(num);
curl_free(env);
}
}
#else
# define memory_tracking_init() Curl_nop_stmt
#endif
int main(int argc, char **argv)
{
char *URL;
memory_tracking_init();
/*
* Setup proper locale from environment. This is needed to enable locale-
* specific behaviour by the C library in order to test for undesired side
* effects that could cause in libcurl.
*/
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#ifdef CURLDEBUG
/* this sends all memory debug messages to a logfile named memdump */
char *env = curl_getenv("CURL_MEMDEBUG");
if(env) {
/* use the value as file name */
char *s = strdup(env);
curl_free(env);
curl_memdebug(s);
free(s);
/* this weird strdup() and stuff here is to make the curl_free() get
called before the memdebug() as otherwise the memdebug tracing will
with tracing a free() without an alloc! */
}
/* this enables the fail-on-alloc-number-N functionality */
env = curl_getenv("CURL_MEMLIMIT");
if(env) {
curl_memlimit(atoi(env));
curl_free(env);
}
#endif
if(argc< 2 ) {
fprintf(stderr, "Pass URL as argument please\n");
return 1;
@@ -1,95 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
CURL* curls = NULL;
CURLM* multi = NULL;
int still_running;
int i = -1;
int res = 0;
CURLMsg *msg;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
easy_init(curls);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_HEADER, 1L);
multi_add_handle(multi, curls);
multi_perform(multi, &still_running);
abort_on_test_timeout();
while(still_running) {
int num;
res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
if (res != CURLM_OK) {
printf("curl_multi_wait() returned %d\n", res);
res = -1;
goto test_cleanup;
}
if (num != 1) {
printf("curl_multi_wait() returned on %d handle(s), expected 1\n", num);
res = -1;
goto test_cleanup;
}
abort_on_test_timeout();
multi_perform(multi, &still_running);
abort_on_test_timeout();
}
msg = curl_multi_info_read(multi, &still_running);
if(msg)
/* this should now contain a result code from the easy handle,
get it */
i = msg->data.result;
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(curls);
curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */
}
@@ -1,126 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 30 * 1000
/* 500 milliseconds allowed. An extreme number but lets be really conservative
to allow old and slow machines to run this test too */
#define MAX_BLOCKED_TIME_US 500000
/* return the number of microseconds between two time stamps */
static int elapsed(struct timeval *before,
struct timeval *after)
{
ssize_t result;
result = (after->tv_sec - before->tv_sec) * 1000000 +
after->tv_usec - before->tv_usec;
if (result < 0)
result = 0;
return curlx_sztosi(result);
}
int test(char *URL)
{
CURL *handle = NULL;
CURLM *mhandle = NULL;
int res = 0;
int still_running = 0;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(handle);
easy_setopt(handle, CURLOPT_URL, URL);
easy_setopt(handle, CURLOPT_VERBOSE, 1L);
multi_init(mhandle);
multi_add_handle(mhandle, handle);
multi_perform(mhandle, &still_running);
abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -99;
struct timeval before;
struct timeval after;
int e;
timeout.tv_sec = 0;
timeout.tv_usec = 100000L; /* 100 ms */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
fprintf(stderr, "ping\n");
before = tutil_tvnow();
multi_perform(mhandle, &still_running);
abort_on_test_timeout();
after = tutil_tvnow();
e = elapsed(&before, &after);
fprintf(stderr, "pong = %d\n", e);
if(e > MAX_BLOCKED_TIME_US) {
res = 100;
break;
}
}
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(mhandle);
curl_easy_cleanup(handle);
curl_global_cleanup();
return res;
}
@@ -1,145 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* This source code is used for lib1502, lib1503, lib1504 and lib1505 with
* only #ifdefs controlling the cleanup sequence.
*
* Test case 1502 converted from bug report #3575448, identifying a memory
* leak in the CURLOPT_RESOLVE handling with the multi interface.
*/
#include "test.h"
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
CURL* easy = NULL;
CURLM* multi = NULL;
int still_running;
int res = 0;
char redirect[160];
/* DNS cache injection */
struct curl_slist *dns_cache_list;
sprintf(redirect, "google.com:%s:%s", libtest_arg2, libtest_arg3);
start_test_timing();
dns_cache_list = curl_slist_append(NULL, redirect);
if(!dns_cache_list) {
fprintf(stderr, "curl_slist_append() failed\n");
return TEST_ERR_MAJOR_BAD;
}
res_global_init(CURL_GLOBAL_ALL);
if(res) {
curl_slist_free_all(dns_cache_list);
return res;
}
easy_init(easy);
easy_setopt(easy, CURLOPT_URL, URL);
easy_setopt(easy, CURLOPT_HEADER, 1L);
easy_setopt(easy, CURLOPT_RESOLVE, dns_cache_list);
multi_init(multi);
multi_add_handle(multi, easy);
multi_perform(multi, &still_running);
abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -99;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
multi_perform(multi, &still_running);
abort_on_test_timeout();
}
test_cleanup:
#ifdef LIB1502
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(easy);
curl_global_cleanup();
#endif
#ifdef LIB1503
/* proper cleanup sequence - type PA */
curl_multi_remove_handle(multi, easy);
curl_multi_cleanup(multi);
curl_easy_cleanup(easy);
curl_global_cleanup();
#endif
#ifdef LIB1504
/* undocumented cleanup sequence - type UB */
curl_easy_cleanup(easy);
curl_multi_cleanup(multi);
curl_global_cleanup();
#endif
#ifdef LIB1505
/* proper cleanup sequence - type PB */
curl_multi_remove_handle(multi, easy);
curl_easy_cleanup(easy);
curl_multi_cleanup(multi);
curl_global_cleanup();
#endif
curl_slist_free_all(dns_cache_list);
return res;
}
@@ -1,132 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013, Linus Nielsen Feltzing <[email protected]>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define NUM_HANDLES 4
int test(char *URL)
{
int res = 0;
CURL *curl[NUM_HANDLES];
int running;
CURLM *m = NULL;
int i;
char target_url[256];
char dnsentry[256];
struct curl_slist *slist = NULL;
char *port = libtest_arg3;
char *address = libtest_arg2;
(void)URL;
/* Create fake DNS entries for serverX.example.com for all handles */
for(i=0; i < NUM_HANDLES; i++) {
sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address);
printf("%s\n", dnsentry);
slist = curl_slist_append(slist, dnsentry);
}
for(i=0; i < NUM_HANDLES; i++)
curl[i] = NULL;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(m);
multi_setopt(m, CURLMOPT_MAXCONNECTS, 3);
/* get NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) {
/* get an easy handle */
easy_init(curl[i]);
/* specify target */
sprintf(target_url, "http://server%d.example.com:%s/path/1506%04i",
i + 1, port, i + 1);
target_url[sizeof(target_url) - 1] = '\0';
easy_setopt(curl[i], CURLOPT_URL, target_url);
/* go verbose */
easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
/* include headers */
easy_setopt(curl[i], CURLOPT_HEADER, 1L);
easy_setopt(curl[i], CURLOPT_RESOLVE, slist);
}
fprintf(stderr, "Start at URL 0\n");
for(i=0; i < NUM_HANDLES; i++) {
/* add handle to multi */
multi_add_handle(m, curl[i]);
for(;;) {
struct timeval interval;
fd_set rd, wr, exc;
int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
multi_perform(m, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
multi_fdset(m, &rd, &wr, &exc, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
}
}
test_cleanup:
/* proper cleanup sequence - type PB */
for(i=0; i < NUM_HANDLES; i++) {
curl_multi_remove_handle(m, curl[i]);
curl_easy_cleanup(curl[i]);
}
curl_slist_free_all(slist);
curl_multi_cleanup(m);
curl_global_cleanup();
return res;
}
@@ -1,62 +1,17 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib500.c,v 1.9 2008-09-20 04:26:56 yangtse Exp $
*/
#include "test.h"
#include "testtrace.h"
#include "memdebug.h"
#ifdef LIB585
static int counter;
static curl_socket_t tst_opensocket(void *clientp,
curlsocktype purpose,
struct curl_sockaddr *addr)
{
(void)clientp;
(void)purpose;
printf("[OPEN] counter: %d\n", ++counter);
return socket(addr->family, addr->socktype, addr->protocol);
}
static int tst_closesocket(void *clientp, curl_socket_t sock)
{
(void)clientp;
printf("[CLOSE] counter: %d\n", counter--);
return sclose(sock);
}
static void setupcallbacks(CURL *curl)
{
curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, tst_opensocket);
curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, tst_closesocket);
counter = 0;
}
#else
#define setupcallbacks(x) Curl_nop_stmt
#endif
int test(char *URL)
{
CURLcode res;
@@ -74,19 +29,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HEADER, 1L);
libtest_debug_config.nohex = 1;
libtest_debug_config.tracetime = 1;
test_setopt(curl, CURLOPT_DEBUGDATA, &libtest_debug_config);
test_setopt(curl, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
if(libtest_arg3 && !strcmp(libtest_arg3, "activeftp"))
test_setopt(curl, CURLOPT_FTPPORT, "-");
setupcallbacks(curl);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl);
@@ -95,44 +39,11 @@ int test(char *URL)
res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ipstr);
moo = fopen(libtest_arg2, "wb");
if(moo) {
double time_namelookup;
double time_connect;
double time_pretransfer;
double time_starttransfer;
double time_total;
fprintf(moo, "IP: %s\n", ipstr);
curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &time_namelookup);
curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &time_connect);
curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_pretransfer);
curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME,
&time_starttransfer);
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &time_total);
/* since the timing will always vary we only compare relative differences
between these 5 times */
if(time_namelookup >= time_connect) {
fprintf(moo, "namelookup vs connect: %f %f\n",
time_namelookup, time_connect);
}
if(time_connect >= time_pretransfer) {
fprintf(moo, "connect vs pretransfer: %f %f\n",
time_connect, time_pretransfer);
}
if(time_pretransfer >= time_starttransfer) {
fprintf(moo, "pretransfer vs starttransfer: %f %f\n",
time_pretransfer, time_starttransfer);
}
if(time_starttransfer >= time_total) {
fprintf(moo, "starttransfer vs total: %f %f\n",
time_starttransfer, time_total);
}
fclose(moo);
}
}
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib501.c,v 1.7 2008-09-20 04:26:56 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -41,12 +30,10 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
+60 -61
View File
@@ -1,31 +1,20 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib502.c,v 1.8 2008-09-20 04:26:56 yangtse Exp $
*/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
/*
* Get a single URL without select().
@@ -33,58 +22,68 @@
int test(char *URL)
{
CURL *c = NULL;
CURLM *m = NULL;
CURL *c;
CURLM *m;
int res = 0;
int running;
int running=1;
struct timeval mp_start;
char mp_timedout = FALSE;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(c);
easy_setopt(c, CURLOPT_URL, URL);
multi_init(m);
multi_add_handle(m, c);
for(;;) {
struct timeval timeout;
fd_set fdread, fdwrite, fdexcep;
int maxfd = -99;
timeout.tv_sec = 0;
timeout.tv_usec = 100000L; /* 100 ms */
multi_perform(m, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
test_cleanup:
if ((c = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* proper cleanup sequence - type PA */
curl_easy_setopt(c, CURLOPT_URL, URL);
if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n");
curl_easy_cleanup(c);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
if ((res = (int)curl_multi_add_handle(m, c)) != CURLM_OK) {
fprintf(stderr, "curl_multi_add_handle() failed, "
"with code %d\n", res);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
mp_timedout = FALSE;
mp_start = tutil_tvnow();
while (running) {
res = (int)curl_multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
if (running <= 0) {
fprintf(stderr, "nothing left running.\n");
break;
}
}
if (mp_timedout) {
if (mp_timedout) fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
res = TEST_ERR_RUNS_FOREVER;
}
curl_multi_remove_handle(m, c);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_multi_cleanup(m);
curl_global_cleanup();
return res;
+94 -47
View File
@@ -1,31 +1,22 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib503.c,v 1.19 2008-09-20 04:26:56 yangtse Exp $
*/
#include "test.h"
#include <sys/types.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
/*
* Source code in here hugely as reported in bug report 651460 by
@@ -37,64 +28,120 @@
int test(char *URL)
{
CURL *c = NULL;
CURLM *m = NULL;
CURL *c;
CURLM *m;
int res = 0;
int running;
char done = FALSE;
struct timeval ml_start;
struct timeval mp_start;
char ml_timedout = FALSE;
char mp_timedout = FALSE;
start_test_timing();
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
global_init(CURL_GLOBAL_ALL);
if ((c = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
easy_init(c);
curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
curl_easy_setopt(c, CURLOPT_URL, URL);
curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing");
curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
curl_easy_setopt(c, CURLOPT_HEADER, 1L);
easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
easy_setopt(c, CURLOPT_URL, URL);
easy_setopt(c, CURLOPT_USERPWD, "test:ing");
easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
easy_setopt(c, CURLOPT_HEADER, 1L);
easy_setopt(c, CURLOPT_VERBOSE, 1L);
if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n");
curl_easy_cleanup(c);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
multi_init(m);
if ((res = (int)curl_multi_add_handle(m, c)) != CURLM_OK) {
fprintf(stderr, "curl_multi_add_handle() failed, "
"with code %d\n", res);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
multi_add_handle(m, c);
ml_timedout = FALSE;
ml_start = tutil_tvnow();
for(;;) {
struct timeval interval;
while(!done) {
fd_set rd, wr, exc;
int maxfd = -99;
int max_fd;
struct timeval interval;
interval.tv_sec = 1;
interval.tv_usec = 0;
multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
MAIN_LOOP_HANG_TIMEOUT) {
ml_timedout = TRUE;
break;
}
mp_timedout = FALSE;
mp_start = tutil_tvnow();
abort_on_test_timeout();
while (res == CURLM_CALL_MULTI_PERFORM) {
res = (int)curl_multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
if (running <= 0) {
done = TRUE;
break;
}
}
if (mp_timedout || done)
break;
if(!running)
break; /* done */
if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n");
break;
}
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
max_fd = 0;
multi_fdset(m, &rd, &wr, &exc, &maxfd);
if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
fprintf(stderr, "unexpected failured of fdset.\n");
res = 89;
break;
}
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
fprintf(stderr, "bad select??\n");
res = 95;
break;
}
select_test(maxfd+1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
res = CURLM_CALL_MULTI_PERFORM;
}
test_cleanup:
/* proper cleanup sequence - type PA */
if (ml_timedout || mp_timedout) {
if (ml_timedout) fprintf(stderr, "ml_timedout\n");
if (mp_timedout) fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
res = TEST_ERR_RUNS_FOREVER;
}
curl_multi_remove_handle(m, c);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_multi_cleanup(m);
curl_global_cleanup();
return res;
+95 -52
View File
@@ -1,31 +1,22 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib504.c,v 1.28 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include <sys/types.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
/*
* Source code in here hugely as reported in bug report 651464 by
@@ -36,41 +27,84 @@
*/
int test(char *URL)
{
CURL *c = NULL;
int res = 0;
CURLM *m = NULL;
CURL *c;
int ret=0;
CURLM *m;
fd_set rd, wr, exc;
CURLMcode res;
char done = FALSE;
int running;
int max_fd;
int rc;
struct timeval ml_start;
struct timeval mp_start;
char ml_timedout = FALSE;
char mp_timedout = FALSE;
start_test_timing();
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
global_init(CURL_GLOBAL_ALL);
if ((c = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
easy_init(c);
/* The point here is that there must not be anything running on the given
/* the point here being that there must not run anything on the given
proxy port */
if (libtest_arg2)
easy_setopt(c, CURLOPT_PROXY, libtest_arg2);
easy_setopt(c, CURLOPT_URL, URL);
easy_setopt(c, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(c, CURLOPT_URL, URL);
curl_easy_setopt(c, CURLOPT_VERBOSE, 1L);
multi_init(m);
if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n");
curl_easy_cleanup(c);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
multi_add_handle(m, c);
if ((res = curl_multi_add_handle(m, c)) != CURLM_OK) {
fprintf(stderr, "curl_multi_add_handle() failed, "
"with code %d\n", res);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
for(;;) {
ml_timedout = FALSE;
ml_start = tutil_tvnow();
while (!done) {
struct timeval interval;
int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
MAIN_LOOP_HANG_TIMEOUT) {
ml_timedout = TRUE;
break;
}
mp_timedout = FALSE;
mp_start = tutil_tvnow();
fprintf(stderr, "curl_multi_perform()\n");
multi_perform(m, &running);
res = CURLM_CALL_MULTI_PERFORM;
abort_on_test_timeout();
while (res == CURLM_CALL_MULTI_PERFORM) {
res = curl_multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
}
if (mp_timedout)
break;
if(!running) {
/* This is where this code is expected to reach */
@@ -78,37 +112,46 @@ int test(char *URL)
CURLMsg *msg = curl_multi_info_read(m, &numleft);
fprintf(stderr, "Expected: not running\n");
if(msg && !numleft)
res = TEST_ERR_SUCCESS; /* this is where we should be */
ret = 100; /* this is where we should be */
else
res = TEST_ERR_FAILURE; /* not correct */
break; /* done */
ret = 99; /* not correct */
break;
}
fprintf(stderr, "running == %d, res == %d\n", running, res);
if (res != CURLM_OK) {
ret = 2;
break;
}
fprintf(stderr, "running == %d\n", running);
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
max_fd = 0;
fprintf(stderr, "curl_multi_fdset()\n");
multi_fdset(m, &rd, &wr, &exc, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
fprintf(stderr, "unexpected failured of fdset.\n");
ret = 3;
break;
}
rc = select_test(max_fd+1, &rd, &wr, &exc, &interval);
fprintf(stderr, "select returned %d\n", rc);
}
test_cleanup:
/* proper cleanup sequence - type PA */
if (ml_timedout || mp_timedout) {
if (ml_timedout) fprintf(stderr, "ml_timedout\n");
if (mp_timedout) fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
ret = TEST_ERR_RUNS_FOREVER;
}
curl_multi_remove_handle(m, c);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_multi_cleanup(m);
curl_global_cleanup();
return res;
return ret;
}
+43 -41
View File
@@ -1,30 +1,33 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib505.c,v 1.15 2008-09-20 04:26:57 yangtse Exp $
*/
#include "setup.h" /* struct_stat etc. */
#include "test.h"
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "memdebug.h"
/*
@@ -53,6 +56,25 @@ int test(char *URL)
return -1;
}
/* get the file size of the local file */
hd = stat(libtest_arg2, &file_info);
if(hd == -1) {
/* can't open file, bail out */
error = ERRNO;
fprintf(stderr, "stat() failed with error: %d %s\n",
error, strerror(error));
fprintf(stderr, "WARNING: cannot open file %s\n", libtest_arg2);
return -1;
}
if(! file_info.st_size) {
fprintf(stderr, "WARNING: file %s has no size!\n", libtest_arg2);
return -4;
}
/* get a FILE * of the same file, could also be made with
fdopen() from the previous descriptor, but hey this is just
an example! */
hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) {
error = ERRNO;
@@ -62,24 +84,6 @@ int test(char *URL)
return -2; /* if this happens things are major weird */
}
/* get the file size of the local file */
hd = fstat(fileno(hd_src), &file_info);
if(hd == -1) {
/* can't open file, bail out */
error = ERRNO;
fprintf(stderr, "fstat() failed with error: %d %s\n",
error, strerror(error));
fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2);
fclose(hd_src);
return -1;
}
if(! file_info.st_size) {
fprintf(stderr, "ERROR: file %s has zero size!\n", libtest_arg2);
fclose(hd_src);
return -4;
}
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
fclose(hd_src);
@@ -114,29 +118,27 @@ int test(char *URL)
headerlist = hl;
/* enable uploading */
test_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* enable verbose */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* specify target */
test_setopt(curl,CURLOPT_URL, URL);
curl_easy_setopt(curl,CURLOPT_URL, URL);
/* pass in that last of FTP commands to run after the transfer */
test_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
/* now specify which file to upload */
test_setopt(curl, CURLOPT_INFILE, hd_src);
curl_easy_setopt(curl, CURLOPT_INFILE, hd_src);
/* and give the size of the upload (optional) */
test_setopt(curl, CURLOPT_INFILESIZE_LARGE,
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
(curl_off_t)file_info.st_size);
/* Now run off and do what you've been told! */
res = curl_easy_perform(curl);
test_cleanup:
/* clean up the FTP commands list */
curl_slist_free_all(headerlist);
+12 -22
View File
@@ -1,25 +1,17 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib506.c,v 1.22 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include <curl/mprintf.h>
@@ -140,7 +132,7 @@ static void *fire(void *ptr)
/* build request url */
static char *suburl(const char *base, int i)
{
return curl_maprintf("%s%.4d", base, i);
return curl_maprintf("%s000%c", base, 48+i);
}
@@ -232,12 +224,12 @@ int test(char *URL)
url = suburl( URL, i );
headers = sethost( NULL );
test_setopt( curl, CURLOPT_HTTPHEADER, headers );
test_setopt( curl, CURLOPT_URL, url );
curl_easy_setopt( curl, CURLOPT_HTTPHEADER, headers );
curl_easy_setopt( curl, CURLOPT_URL, url );
printf( "CURLOPT_SHARE\n" );
test_setopt( curl, CURLOPT_SHARE, share );
curl_easy_setopt( curl, CURLOPT_SHARE, share );
printf( "CURLOPT_COOKIEJAR\n" );
test_setopt( curl, CURLOPT_COOKIEJAR, JAR );
curl_easy_setopt( curl, CURLOPT_COOKIEJAR, JAR );
printf( "PERFORM\n" );
curl_easy_perform( curl );
@@ -253,8 +245,6 @@ int test(char *URL)
printf( "SHARE_CLEANUP failed, correct\n" );
}
test_cleanup:
/* clean up last handle */
printf( "CLEANUP\n" );
curl_easy_cleanup( curl );
+90 -54
View File
@@ -1,64 +1,85 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib507.c,v 1.17 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
CURL* curls = NULL;
CURLM* multi = NULL;
CURL* curls;
CURLM* multi;
int still_running;
int i = -1;
int res = 0;
CURLMsg *msg;
CURLMcode res;
struct timeval ml_start;
struct timeval mp_start;
char ml_timedout = FALSE;
char mp_timedout = FALSE;
start_test_timing();
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
global_init(CURL_GLOBAL_ALL);
if ((multi = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
multi_init(multi);
if ((curls = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_multi_cleanup(multi);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
easy_init(curls);
curl_easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_HEADER, 1L);
if ((res = curl_multi_add_handle(multi, curls)) != CURLM_OK) {
fprintf(stderr, "curl_multi_add_handle() failed, "
"with code %d\n", res);
curl_easy_cleanup(curls);
curl_multi_cleanup(multi);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
multi_add_handle(multi, curls);
mp_timedout = FALSE;
mp_start = tutil_tvnow();
multi_perform(multi, &still_running);
do {
res = curl_multi_perform(multi, &still_running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
} while (res == CURLM_CALL_MULTI_PERFORM);
abort_on_test_timeout();
ml_timedout = FALSE;
ml_start = tutil_tvnow();
while(still_running) {
while ((!ml_timedout) && (!mp_timedout) && (still_running)) {
struct timeval timeout;
int rc;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -99;
int maxfd;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
@@ -66,35 +87,50 @@ int test(char *URL)
timeout.tv_sec = 1;
timeout.tv_usec = 0;
multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
MAIN_LOOP_HANG_TIMEOUT) {
ml_timedout = TRUE;
break;
}
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
multi_perform(multi, &still_running);
abort_on_test_timeout();
curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
rc = select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
switch(rc) {
case -1:
break;
case 0:
default:
mp_timedout = FALSE;
mp_start = tutil_tvnow();
do {
res = curl_multi_perform(multi, &still_running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
} while (res == CURLM_CALL_MULTI_PERFORM);
break;
}
}
if (ml_timedout || mp_timedout) {
if (ml_timedout) fprintf(stderr, "ml_timedout\n");
if (mp_timedout) fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
i = TEST_ERR_RUNS_FOREVER;
}
else {
msg = curl_multi_info_read(multi, &still_running);
if(msg)
/* this should now contain a result code from the easy handle,
get it */
i = msg->data.result;
}
msg = curl_multi_info_read(multi, &still_running);
if(msg)
/* this should now contain a result code from the easy handle,
get it */
i = msg->data.result;
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(curls);
curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */
}
+11 -29
View File
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib508.c,v 1.8 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -69,36 +58,29 @@ int test(char *URL)
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
curl_easy_setopt(curl, CURLOPT_POST, 1L);
/* Set the expected POST size */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
/* we want to use our own read function */
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_INFILE, &pooh);
curl_easy_setopt(curl, CURLOPT_INFILE, &pooh);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
+12 -34
View File
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib510.c,v 1.7 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -60,6 +49,7 @@ int test(char *URL)
CURL *curl;
CURLcode res=CURLE_OK;
struct curl_slist *slist = NULL;
struct WriteThis pooh;
pooh.counter = 0;
@@ -83,41 +73,29 @@ int test(char *URL)
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
curl_easy_setopt(curl, CURLOPT_POST, 1L);
/* we want to use our own read function */
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_INFILE, &pooh);
curl_easy_setopt(curl, CURLOPT_INFILE, &pooh);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
/* enforce chunked transfer by setting the header */
test_setopt(curl, CURLOPT_HTTPHEADER, slist);
#ifdef LIB565
test_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST);
test_setopt(curl, CURLOPT_USERPWD, "foo:bar");
#endif
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* clean up the headers list */
if(slist)
curl_slist_free_all(slist);
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib511.c,v 1.7 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -39,15 +28,13 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_FILETIME, 1L);
test_setopt(curl, CURLOPT_NOBODY, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib512.c,v 1.6 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
+11 -24
View File
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib513.c,v 1.5 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -49,31 +38,29 @@ int test(char *URL)
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POST, 1L);
/* Set the expected POST size */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L);
/* we want to use our own read function */
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_INFILE, NULL);
curl_easy_setopt(curl, CURLOPT_INFILE, NULL);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
+11 -24
View File
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib514.c,v 1.5 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -40,7 +29,7 @@ int test(char *URL)
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_URL, URL);
/* Based on a bug report by Niels van Tongeren on June 29, 2004:
@@ -51,25 +40,23 @@ int test(char *URL)
*/
test_setopt(curl, CURLOPT_POSTFIELDS, "moo");
test_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L);
test_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "moo");
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L);
curl_easy_setopt(curl, CURLOPT_POST, 1L);
/* this is where transfer 1 would take place, but skip that and change
options right away instead */
test_setopt(curl, CURLOPT_NOBODY, 1L);
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
/* Now, we should be making a fine HEAD request */
/* Perform the request 2, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib515.c,v 1.5 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -40,17 +29,15 @@ int test(char *URL)
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
test_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L);
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
/* Now, we should be making a zero byte POST request */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib516.c,v 1.5 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -40,16 +29,14 @@ int test(char *URL)
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HTTPPOST, NULL);
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, NULL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
/* Now, we should be making a zero byte POST request */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,29 +1,18 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib517.c,v 1.6 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
static const char * const dates[]={
static const char *dates[]={
"Sun, 06 Nov 1994 08:49:37 GMT",
"Sunday, 06-Nov-94 08:49:37 GMT",
"Sun Nov 6 08:49:37 1994",
@@ -49,73 +38,6 @@ static const char * const dates[]={
"Thu, 01-Jan-1970 00:59:59 GMT",
"Thu, 01-Jan-1970 01:00:00 GMT",
/* "2094 Nov 6", See ../data/test517 for details */
"Sat, 15-Apr-17 21:01:22 GMT",
"Thu, 19-Apr-2007 16:00:00 GMT",
"Wed, 25 Apr 2007 21:02:13 GMT",
"Thu, 19/Apr\\2007 16:00:00 GMT",
"Fri, 1 Jan 2010 01:01:50 GMT",
"Wednesday, 1-Jan-2003 00:00:00 GMT",
", 1-Jan-2003 00:00:00 GMT",
" 1-Jan-2003 00:00:00 GMT",
"1-Jan-2003 00:00:00 GMT",
"Wed,18-Apr-07 22:50:12 GMT",
"WillyWonka , 18-Apr-07 22:50:12 GMT",
"WillyWonka , 18-Apr-07 22:50:12",
"WillyWonka , 18-apr-07 22:50:12",
"Mon, 18-Apr-1977 22:50:13 GMT",
"Mon, 18-Apr-77 22:50:13 GMT",
"\"Sat, 15-Apr-17\\\"21:01:22\\\"GMT\"",
"Partyday, 18- April-07 22:50:12",
"Partyday, 18 - Apri-07 22:50:12",
"Wednes, 1-Januar-2003 00:00:00 GMT",
"Sat, 15-Apr-17 21:01:22",
"Sat, 15-Apr-17 21:01:22 GMT-2",
"Sat, 15-Apr-17 21:01:22 GMT BLAH",
"Sat, 15-Apr-17 21:01:22 GMT-0400",
"Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)",
"Sat, 15-Apr-17 21:01:22 DST",
"Sat, 15-Apr-17 21:01:22 -0400",
"Sat, 15-Apr-17 21:01:22 (hello there)",
"Sat, 15-Apr-17 21:01:22 11:22:33",
"Sat, 15-Apr-17 ::00 21:01:22",
"Sat, 15-Apr-17 boink:z 21:01:22",
"Sat, 15-Apr-17 91:22:33 21:01:22",
"Thu Apr 18 22:50:12 2007 GMT",
"22:50:12 Thu Apr 18 2007 GMT",
"Thu 22:50:12 Apr 18 2007 GMT",
"Thu Apr 22:50:12 18 2007 GMT",
"Thu Apr 18 22:50:12 2007 GMT",
"Thu Apr 18 2007 22:50:12 GMT",
"Thu Apr 18 2007 GMT 22:50:12",
"Sat, 15-Apr-17 21:01:22 GMT",
"15-Sat, Apr-17 21:01:22 GMT",
"15-Sat, Apr 21:01:22 GMT 17",
"15-Sat, Apr 21:01:22 GMT 2017",
"15 Apr 21:01:22 2017",
"15 17 Apr 21:01:22",
"Apr 15 17 21:01:22",
"Apr 15 21:01:22 17",
"2017 April 15 21:01:22",
"15 April 2017 21:01:22",
"98 April 17 21:01:22",
"Thu, 012-Aug-2008 20:49:07 GMT",
#if 0
/* leaving out these strings since they differ between 32 and 64 bit
archs and the test suite has no good way to support two different outputs
like that */
"Thu, 12-Aug-31841 20:49:07 GMT",
"Thu, 12-Aug-9999999999 20:49:07 GMT",
#endif
"Thu, 999999999999-Aug-2007 20:49:07 GMT",
"Thu, 12-Aug-2007 20:61:99999999999 GMT",
"IAintNoDateFool",
"Thu Apr 18 22:50 2007 GMT", /* without seconds */
"20110623 12:34:56",
"20110632 12:34:56",
"20110623 56:34:56",
"20111323 12:34:56",
"20110623 12:34:79",
"Wed, 31 Dec 2008 23:59:60 GMT", /* leap second */
NULL
};
+16 -24
View File
@@ -1,26 +1,18 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib518.c,v 1.36 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
@@ -30,8 +22,10 @@
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "warnless.h"
#include "memdebug.h"
#ifndef FD_SETSIZE
@@ -222,7 +216,7 @@ static int rlimit(int keep_open)
/*
* verify that soft limit is higher than NUM_NEEDED,
* which is the number of file descriptors we would
* which is the number of file descriptors we would
* try to open plus SAFETY_MARGIN to not exhaust the
* file descriptor pool
*/
@@ -335,8 +329,8 @@ static int rlimit(int keep_open)
/* create a bunch of file descriptors */
for (num_open.rlim_cur = 1;
num_open.rlim_cur < num_open.rlim_max;
for (num_open.rlim_cur = 1;
num_open.rlim_cur < num_open.rlim_max;
num_open.rlim_cur++) {
fd[num_open.rlim_cur] = dup(fd[0]);
@@ -474,7 +468,7 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
/* run the test with the bunch of open file descriptors
/* run the test with the bunch of open file descriptors
and close them all once the test is over */
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
@@ -490,13 +484,11 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl);
test_cleanup:
close_file_descriptors();
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib519.c,v 1.5 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -39,21 +28,19 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_USERPWD, "monster:underbed");
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_USERPWD, "monster:underbed");
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* get first page */
res = curl_easy_perform(curl);
test_setopt(curl, CURLOPT_USERPWD, "anothermonster:inwardrobe");
curl_easy_setopt(curl, CURLOPT_USERPWD, "anothermonster:inwardrobe");
/* get second page */
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib520.c,v 1.5 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -39,14 +28,12 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_FILETIME, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib521.c,v 1.6 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -39,15 +28,13 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2));
curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib523.c,v 1.6 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -39,16 +28,14 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_PORT, 19999L);
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_PORT, 19999L);
curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib524.c,v 1.5 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -39,14 +28,12 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
+114 -77
View File
@@ -1,101 +1,90 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib525.c,v 1.19 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
int res = 0;
CURL *curl = NULL;
FILE *hd_src = NULL;
CURL *curl;
FILE *hd_src ;
int hd ;
int error;
struct_stat file_info;
CURLM *m = NULL;
int running;
char done=FALSE;
CURLM *m;
struct timeval ml_start;
struct timeval mp_start;
char ml_timedout = FALSE;
char mp_timedout = FALSE;
start_test_timing();
if(!libtest_arg2) {
#ifdef LIB529
/* test 529 */
fprintf(stderr, "Usage: lib529 [url] [uploadfile]\n");
#else
/* test 525 */
if (!libtest_arg2) {
fprintf(stderr, "Usage: lib525 [url] [uploadfile]\n");
#endif
return TEST_ERR_USAGE;
}
hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) {
error = ERRNO;
fprintf(stderr, "fopen() failed with error: %d (%s)\n",
error, strerror(error));
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2);
return TEST_ERR_FOPEN;
return -1;
}
/* get the file size of the local file */
hd = fstat(fileno(hd_src), &file_info);
if(hd == -1) {
/* can't open file, bail out */
hd = open(libtest_arg2, O_RDONLY) ;
fstat(hd, &file_info);
close(hd) ;
/* get a FILE * of the same file, could also be made with
fdopen() from the previous descriptor, but hey this is just
an example! */
hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) {
error = ERRNO;
fprintf(stderr, "fstat() failed with error: %d (%s)\n",
fprintf(stderr, "fopen() failed with error: %d %s\n",
error, strerror(error));
fprintf(stderr, "ERROR: cannot open file (%s)\n", libtest_arg2);
fclose(hd_src);
return TEST_ERR_FSTAT;
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
return TEST_ERR_MAJOR_BAD;
}
res_global_init(CURL_GLOBAL_ALL);
if(res) {
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
fclose(hd_src);
return res;
return TEST_ERR_MAJOR_BAD;
}
easy_init(curl);
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
fclose(hd_src);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* enable uploading */
easy_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */
easy_setopt(curl,CURLOPT_URL, URL);
curl_easy_setopt(curl,CURLOPT_URL, URL);
/* go verbose */
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* use active FTP */
easy_setopt(curl, CURLOPT_FTPPORT, "-");
curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
/* now specify which file to upload */
easy_setopt(curl, CURLOPT_READDATA, hd_src);
curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
/* NOTE: if you want this code to work on Windows with libcurl as a DLL, you
MUST also provide a read callback with CURLOPT_READFUNCTION. Failing to
@@ -106,60 +95,108 @@ int test(char *URL)
option you MUST make sure that the type of the passed-in argument is a
curl_off_t. If you use CURLOPT_INFILESIZE (without _LARGE) you must
make sure that to pass in a type 'long' argument. */
easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
(curl_off_t)file_info.st_size);
multi_init(m);
if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n");
curl_easy_cleanup(curl);
curl_global_cleanup();
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
multi_add_handle(m, curl);
if ((res = (int)curl_multi_add_handle(m, curl)) != CURLM_OK) {
fprintf(stderr, "curl_multi_add_handle() failed, "
"with code %d\n", res);
curl_multi_cleanup(m);
curl_easy_cleanup(curl);
curl_global_cleanup();
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
for(;;) {
struct timeval interval;
ml_timedout = FALSE;
ml_start = tutil_tvnow();
while (!done) {
fd_set rd, wr, exc;
int maxfd = -99;
int max_fd;
struct timeval interval;
interval.tv_sec = 1;
interval.tv_usec = 0;
multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
MAIN_LOOP_HANG_TIMEOUT) {
ml_timedout = TRUE;
break;
}
mp_timedout = FALSE;
mp_start = tutil_tvnow();
abort_on_test_timeout();
while (res == CURLM_CALL_MULTI_PERFORM) {
res = (int)curl_multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
if (running <= 0) {
done = TRUE;
break;
}
}
if (mp_timedout || done)
break;
if(!running)
break; /* done */
if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n");
break;
}
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
max_fd = 0;
multi_fdset(m, &rd, &wr, &exc, &maxfd);
if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
fprintf(stderr, "unexpected failured of fdset.\n");
res = 189;
break;
}
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
fprintf(stderr, "bad select??\n");
res = 195;
break;
}
select_test(maxfd+1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
res = CURLM_CALL_MULTI_PERFORM;
}
test_cleanup:
if (ml_timedout || mp_timedout) {
if (ml_timedout) fprintf(stderr, "ml_timedout\n");
if (mp_timedout) fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
res = TEST_ERR_RUNS_FOREVER;
}
#ifdef LIB529
/* test 529 */
/* proper cleanup sequence - type PA */
curl_multi_remove_handle(m, curl);
curl_multi_cleanup(m);
curl_easy_cleanup(curl);
curl_global_cleanup();
#else
/* test 525 */
/* proper cleanup sequence - type PB */
curl_multi_remove_handle(m, curl);
curl_easy_cleanup(curl);
curl_multi_cleanup(m);
curl_global_cleanup();
#endif
/* close the local file */
fclose(hd_src);
fclose(hd_src); /* close the local file */
curl_global_cleanup();
return res;
}
+129 -100
View File
@@ -1,24 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib526.c,v 1.15 2008-09-20 04:26:57 yangtse Exp $
*/
/*
* This code sets up multiple easy handles that transfer a single file from
* the same URL, in a serial manner after each other. Due to the connection
@@ -40,13 +29,15 @@
#include "test.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
#define NUM_HANDLES 4
@@ -55,130 +46,168 @@ int test(char *URL)
int res = 0;
CURL *curl[NUM_HANDLES];
int running;
CURLM *m = NULL;
int current = 0;
int i;
char done=FALSE;
CURLM *m;
int current=0;
int i, j;
struct timeval ml_start;
struct timeval mp_start;
char ml_timedout = FALSE;
char mp_timedout = FALSE;
for(i=0; i < NUM_HANDLES; i++)
curl[i] = NULL;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* get NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) {
easy_init(curl[i]);
/* specify target */
easy_setopt(curl[i], CURLOPT_URL, URL);
curl[i] = curl_easy_init();
if(!curl[i]) {
fprintf(stderr, "curl_easy_init() failed "
"on handle #%d\n", i);
for (j=i-1; j >= 0; j--) {
curl_easy_cleanup(curl[j]);
}
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD + i;
}
curl_easy_setopt(curl[i], CURLOPT_URL, URL);
/* go verbose */
easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
}
multi_init(m);
if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n");
for(i=0; i < NUM_HANDLES; i++) {
curl_easy_cleanup(curl[i]);
}
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
multi_add_handle(m, curl[current]);
if ((res = (int)curl_multi_add_handle(m, curl[current])) != CURLM_OK) {
fprintf(stderr, "curl_multi_add_handle() failed, "
"with code %d\n", res);
curl_multi_cleanup(m);
for(i=0; i < NUM_HANDLES; i++) {
curl_easy_cleanup(curl[i]);
}
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
ml_timedout = FALSE;
ml_start = tutil_tvnow();
fprintf(stderr, "Start at URL 0\n");
for(;;) {
struct timeval interval;
while (!done) {
fd_set rd, wr, exc;
int maxfd = -99;
int max_fd;
struct timeval interval;
interval.tv_sec = 1;
interval.tv_usec = 0;
multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
MAIN_LOOP_HANG_TIMEOUT) {
ml_timedout = TRUE;
break;
}
mp_timedout = FALSE;
mp_start = tutil_tvnow();
abort_on_test_timeout();
if(!running) {
while (res == CURLM_CALL_MULTI_PERFORM) {
res = (int)curl_multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
if (running <= 0) {
#ifdef LIB527
/* NOTE: this code does not remove the handle from the multi handle
here, which would be the nice, sane and documented way of working.
This however tests that the API survives this abuse gracefully. */
curl_easy_cleanup(curl[current]);
curl[current] = NULL;
/* NOTE: this code does not remove the handle from the multi handle
here, which would be the nice, sane and documented way of working.
This however tests that the API survives this abuse gracefully. */
curl_easy_cleanup(curl[current]);
#endif
if(++current < NUM_HANDLES) {
fprintf(stderr, "Advancing to URL %d\n", current);
if(++current < NUM_HANDLES) {
fprintf(stderr, "Advancing to URL %d\n", current);
#ifdef LIB532
/* first remove the only handle we use */
curl_multi_remove_handle(m, curl[0]);
/* first remove the only handle we use */
curl_multi_remove_handle(m, curl[0]);
/* make us re-use the same handle all the time, and try resetting
the handle first too */
curl_easy_reset(curl[0]);
easy_setopt(curl[0], CURLOPT_URL, URL);
/* go verbose */
easy_setopt(curl[0], CURLOPT_VERBOSE, 1L);
/* make us re-use the same handle all the time, and try resetting
the handle first too */
curl_easy_reset(curl[0]);
curl_easy_setopt(curl[0], CURLOPT_URL, URL);
curl_easy_setopt(curl[0], CURLOPT_VERBOSE, 1L);
/* re-add it */
multi_add_handle(m, curl[0]);
/* re-add it */
res = (int)curl_multi_add_handle(m, curl[0]);
#else
multi_add_handle(m, curl[current]);
res = (int)curl_multi_add_handle(m, curl[current]);
#endif
if(res) {
fprintf(stderr, "add handle failed: %d.\n", res);
res = 243;
break;
}
}
else
done = TRUE; /* bail out */
break;
}
else {
break; /* done */
}
}
if (mp_timedout || done)
break;
if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n");
break;
}
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
max_fd = 0;
multi_fdset(m, &rd, &wr, &exc, &maxfd);
if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
fprintf(stderr, "unexpected failured of fdset.\n");
res = 189;
break;
}
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
fprintf(stderr, "bad select??\n");
res = 195;
break;
}
select_test(maxfd+1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
res = CURLM_CALL_MULTI_PERFORM;
}
test_cleanup:
#if defined(LIB526)
/* test 526 and 528 */
/* proper cleanup sequence - type PB */
if (ml_timedout || mp_timedout) {
if (ml_timedout) fprintf(stderr, "ml_timedout\n");
if (mp_timedout) fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
res = TEST_ERR_RUNS_FOREVER;
}
#ifndef LIB527
/* get NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) {
#ifdef LIB526
curl_multi_remove_handle(m, curl[i]);
#endif
curl_easy_cleanup(curl[i]);
}
curl_multi_cleanup(m);
curl_global_cleanup();
#elif defined(LIB527)
/* test 527 */
/* Upon non-failure test flow the easy's have already been cleanup'ed. In
case there is a failure we arrive here with easy's that have not been
cleanup'ed yet, in this case we have to cleanup them or otherwise these
will be leaked, let's use undocumented cleanup sequence - type UB */
if(res)
for(i=0; i < NUM_HANDLES; i++)
curl_easy_cleanup(curl[i]);
curl_multi_cleanup(m);
curl_global_cleanup();
#elif defined(LIB532)
/* test 532 */
/* undocumented cleanup sequence - type UB */
for(i=0; i < NUM_HANDLES; i++)
curl_easy_cleanup(curl[i]);
curl_multi_cleanup(m);
curl_global_cleanup();
#endif
curl_multi_cleanup(m);
curl_global_cleanup();
return res;
}
+114 -49
View File
@@ -1,31 +1,30 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib530.c,v 1.18 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
#define NUM_HANDLES 4
@@ -34,71 +33,137 @@ int test(char *URL)
int res = 0;
CURL *curl[NUM_HANDLES];
int running;
CURLM *m = NULL;
int i;
char done=FALSE;
CURLM *m;
int i, j;
struct timeval ml_start;
struct timeval mp_start;
char ml_timedout = FALSE;
char mp_timedout = FALSE;
char target_url[256];
for(i=0; i < NUM_HANDLES; i++)
curl[i] = NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(m);
if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* get NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) {
/* get an easy handle */
easy_init(curl[i]);
/* specify target */
curl[i] = curl_easy_init();
if(!curl[i]) {
fprintf(stderr, "curl_easy_init() failed "
"on handle #%d\n", i);
for (j=i-1; j >= 0; j--) {
curl_multi_remove_handle(m, curl[j]);
curl_easy_cleanup(curl[j]);
}
curl_multi_cleanup(m);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD + i;
}
sprintf(target_url, "%s%04i", URL, i + 1);
target_url[sizeof(target_url) - 1] = '\0';
easy_setopt(curl[i], CURLOPT_URL, target_url);
curl_easy_setopt(curl[i], CURLOPT_URL, target_url);
/* go verbose */
easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
/* include headers */
easy_setopt(curl[i], CURLOPT_HEADER, 1L);
curl_easy_setopt(curl[i], CURLOPT_HEADER, 1L);
/* add handle to multi */
multi_add_handle(m, curl[i]);
if ((res = (int)curl_multi_add_handle(m, curl[i])) != CURLM_OK) {
fprintf(stderr, "curl_multi_add_handle() failed, "
"on handle #%d with code %d\n", i, res);
curl_easy_cleanup(curl[i]);
for (j=i-1; j >= 0; j--) {
curl_multi_remove_handle(m, curl[j]);
curl_easy_cleanup(curl[j]);
}
curl_multi_cleanup(m);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD + i;
}
}
multi_setopt(m, CURLMOPT_PIPELINING, 1L);
curl_multi_setopt(m, CURLMOPT_PIPELINING, 1L);
ml_timedout = FALSE;
ml_start = tutil_tvnow();
fprintf(stderr, "Start at URL 0\n");
for(;;) {
struct timeval interval;
while (!done) {
fd_set rd, wr, exc;
int maxfd = -99;
int max_fd;
struct timeval interval;
interval.tv_sec = 1;
interval.tv_usec = 0;
multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
MAIN_LOOP_HANG_TIMEOUT) {
ml_timedout = TRUE;
break;
}
mp_timedout = FALSE;
mp_start = tutil_tvnow();
abort_on_test_timeout();
while (res == CURLM_CALL_MULTI_PERFORM) {
res = (int)curl_multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
if (running <= 0) {
done = TRUE; /* bail out */
break;
}
}
if (mp_timedout || done)
break;
if(!running)
break; /* done */
if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n");
break;
}
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
max_fd = 0;
multi_fdset(m, &rd, &wr, &exc, &maxfd);
if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
fprintf(stderr, "unexpected failured of fdset.\n");
res = 189;
break;
}
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
fprintf(stderr, "bad select??\n");
res = 195;
break;
}
select_test(maxfd+1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
res = CURLM_CALL_MULTI_PERFORM;
}
test_cleanup:
/* proper cleanup sequence - type PB */
if (ml_timedout || mp_timedout) {
if (ml_timedout) fprintf(stderr, "ml_timedout\n");
if (mp_timedout) fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
res = TEST_ERR_RUNS_FOREVER;
}
/* cleanup NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) {
curl_multi_remove_handle(m, curl[i]);
curl_easy_cleanup(curl[i]);
+110 -58
View File
@@ -1,108 +1,160 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib533.c,v 1.16 2008-09-20 04:26:57 yangtse Exp $
*/
/* used for test case 533, 534 and 535 */
#include "test.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
int res = 0;
CURL *curl = NULL;
CURL *curl;
int running;
CURLM *m = NULL;
char done=FALSE;
CURLM *m;
int current=0;
struct timeval ml_start;
struct timeval mp_start;
char ml_timedout = FALSE;
char mp_timedout = FALSE;
start_test_timing();
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
global_init(CURL_GLOBAL_ALL);
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
easy_init(curl);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n");
curl_easy_cleanup(curl);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
multi_init(m);
if ((res = (int)curl_multi_add_handle(m, curl)) != CURLM_OK) {
fprintf(stderr, "curl_multi_add_handle() failed, "
"with code %d\n", res);
curl_multi_cleanup(m);
curl_easy_cleanup(curl);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
multi_add_handle(m, curl);
ml_timedout = FALSE;
ml_start = tutil_tvnow();
fprintf(stderr, "Start at URL 0\n");
for(;;) {
struct timeval interval;
while (!done) {
fd_set rd, wr, exc;
int maxfd = -99;
int max_fd;
struct timeval interval;
interval.tv_sec = 1;
interval.tv_usec = 0;
multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
MAIN_LOOP_HANG_TIMEOUT) {
ml_timedout = TRUE;
break;
}
mp_timedout = FALSE;
mp_start = tutil_tvnow();
abort_on_test_timeout();
if(!running) {
if(!current++) {
fprintf(stderr, "Advancing to URL 1\n");
/* remove the handle we use */
curl_multi_remove_handle(m, curl);
/* make us re-use the same handle all the time, and try resetting
the handle first too */
curl_easy_reset(curl);
easy_setopt(curl, CURLOPT_URL, libtest_arg2);
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
/* re-add it */
multi_add_handle(m, curl);
while (res == CURLM_CALL_MULTI_PERFORM) {
res = (int)curl_multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
else
break; /* done */
if (running <= 0) {
if(!current++) {
fprintf(stderr, "Advancing to URL 1\n");
/* remove the handle we use */
curl_multi_remove_handle(m, curl);
/* make us re-use the same handle all the time, and try resetting
the handle first too */
curl_easy_reset(curl);
curl_easy_setopt(curl, CURLOPT_URL, libtest_arg2);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
/* re-add it */
res = (int)curl_multi_add_handle(m, curl);
if(res) {
fprintf(stderr, "add handle failed: %d.\n", res);
res = 243;
break;
}
}
else
done = TRUE; /* bail out */
break;
}
}
if (mp_timedout || done)
break;
if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n");
break;
}
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
max_fd = 0;
multi_fdset(m, &rd, &wr, &exc, &maxfd);
if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
fprintf(stderr, "unexpected failured of fdset.\n");
res = 189;
break;
}
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
fprintf(stderr, "bad select??\n");
res = 195;
break;
}
select_test(maxfd+1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
res = CURLM_CALL_MULTI_PERFORM;
}
test_cleanup:
/* undocumented cleanup sequence - type UB */
if (ml_timedout || mp_timedout) {
if (ml_timedout) fprintf(stderr, "ml_timedout\n");
if (mp_timedout) fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
res = TEST_ERR_RUNS_FOREVER;
}
curl_easy_cleanup(curl);
curl_multi_cleanup(m);
+81 -93
View File
@@ -1,137 +1,125 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib536.c,v 1.14 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
static int perform(CURLM *multi)
static CURLMcode perform(CURLM * multi)
{
int handles;
int handles, maxfd;
CURLMcode code;
fd_set fdread, fdwrite, fdexcep;
int res = 0;
struct timeval mp_start;
char mp_timedout = FALSE;
for(;;) {
struct timeval interval;
int maxfd = -99;
mp_timedout = FALSE;
mp_start = tutil_tvnow();
interval.tv_sec = 0;
interval.tv_usec = 100000L; /* 100 ms */
for (;;) {
code = curl_multi_perform(multi, &handles);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
if (handles <= 0)
return CURLM_OK;
res_multi_perform(multi, &handles);
if(res)
return res;
res_test_timedout();
if(res)
return res;
if(!handles)
break; /* done */
switch (code) {
case CURLM_OK:
break;
case CURLM_CALL_MULTI_PERFORM:
continue;
default:
return code;
}
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
res_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
if(res)
return res;
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
res_select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval);
if(res)
return res;
res_test_timedout();
if(res)
return res;
curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
if (maxfd < 0)
return (CURLMcode) ~CURLM_OK;
if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, 0) == -1)
return (CURLMcode) ~CURLM_OK;
}
return 0; /* success */
/* We only reach this point if (mp_timedout) */
if (mp_timedout) fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
return (CURLMcode) ~CURLM_OK;
}
int test(char *URL)
{
CURLM *multi = NULL;
CURL *easy = NULL;
CURLM *multi;
CURL *easy;
int res = 0;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
easy_init(easy);
multi_setopt(multi, CURLMOPT_PIPELINING, 1L);
easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite);
easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
easy_setopt(easy, CURLOPT_URL, URL);
res_multi_add_handle(multi, easy);
if(res) {
printf("curl_multi_add_handle() 1 failed\n");
goto test_cleanup;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
res = perform(multi);
if(res) {
printf("retrieve 1 failed\n");
goto test_cleanup;
if ((multi = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
curl_multi_remove_handle(multi, easy);
if ((easy = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_multi_cleanup(multi);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1L);
curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
curl_easy_setopt(easy, CURLOPT_URL, URL);
if (curl_multi_add_handle(multi, easy) != CURLM_OK) {
printf("curl_multi_add_handle() failed\n");
res = TEST_ERR_MAJOR_BAD;
} else {
if (perform(multi) != CURLM_OK)
printf("retrieve 1 failed\n");
curl_multi_remove_handle(multi, easy);
}
curl_easy_reset(easy);
easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
easy_setopt(easy, CURLOPT_URL, libtest_arg2);
curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
curl_easy_setopt(easy, CURLOPT_URL, libtest_arg2);
res_multi_add_handle(multi, easy);
if(res) {
if (curl_multi_add_handle(multi, easy) != CURLM_OK) {
printf("curl_multi_add_handle() 2 failed\n");
goto test_cleanup;
res = TEST_ERR_MAJOR_BAD;
} else {
if (perform(multi) != CURLM_OK)
printf("retrieve 2 failed\n");
curl_multi_remove_handle(multi, easy);
}
res = perform(multi);
if(res) {
printf("retrieve 2 failed\n");
goto test_cleanup;
}
curl_multi_remove_handle(multi, easy);
test_cleanup:
/* undocumented cleanup sequence - type UB */
curl_easy_cleanup(easy);
curl_multi_cleanup(multi);
curl_global_cleanup();
+17 -25
View File
@@ -1,26 +1,18 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2013, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib537.c,v 1.21 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
@@ -30,8 +22,10 @@
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "warnless.h"
#include "memdebug.h"
#if !defined(HAVE_POLL_FINE) && \
@@ -41,7 +35,7 @@
#error "this test requires FD_SETSIZE"
#endif
#define SAFETY_MARGIN (11)
#define SAFETY_MARGIN (10)
#if defined(WIN32) || defined(_WIN32) || defined(MSDOS)
#define DEV_NULL "NUL"
@@ -210,7 +204,7 @@ static int rlimit(int keep_open)
/*
* test 537 is all about testing libcurl functionality
* when the system has nearly exhausted the number of
* available file descriptors. Test 537 will try to run
* available file descriptors. Test 537 will try to run
* with a very small number of file descriptors available.
* This implies that any file descriptor which is open
* when the test runs will have a number in the high range
@@ -329,8 +323,8 @@ static int rlimit(int keep_open)
/* create a bunch of file descriptors */
for (num_open.rlim_cur = 1;
num_open.rlim_cur < num_open.rlim_max;
for (num_open.rlim_cur = 1;
num_open.rlim_cur < num_open.rlim_max;
num_open.rlim_cur++) {
fd[num_open.rlim_cur] = dup(fd[0]);
@@ -477,7 +471,7 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
/* run the test with the bunch of open file descriptors
/* run the test with the bunch of open file descriptors
and close them all once the test is over */
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
@@ -493,13 +487,11 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl);
test_cleanup:
close_file_descriptors();
curl_easy_cleanup(curl);
curl_global_cleanup();
+19 -33
View File
@@ -1,24 +1,13 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* $Id: lib539.c,v 1.3 2008-09-22 17:20:29 danf Exp $
*/
#include "test.h"
#include "memdebug.h"
@@ -27,8 +16,8 @@ int test(char *URL)
{
CURLcode res;
CURL *curl;
char *newURL = NULL;
struct curl_slist *slist = NULL;
char *newURL;
struct curl_slist *slist;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
@@ -44,9 +33,9 @@ int test(char *URL)
/*
* Begin with cURL set to use a single CWD to the URL's directory.
*/
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD);
res = curl_easy_perform(curl);
@@ -74,17 +63,14 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, newURL);
test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD);
test_setopt(curl, CURLOPT_QUOTE, slist);
curl_easy_setopt(curl, CURLOPT_URL, newURL);
curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD);
curl_easy_setopt(curl, CURLOPT_QUOTE, slist);
res = curl_easy_perform(curl);
test_cleanup:
curl_slist_free_all(slist);
if(newURL)
free(newURL);
free(newURL);
curl_easy_cleanup(curl);
curl_global_cleanup();
+45 -157
View File
@@ -1,25 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
* $Id: lib540.c,v 1.7 2008-09-20 04:26:57 yangtse Exp $
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* This is the 'proxyauth.c' test app posted by Shmulik Regev on the libcurl
* This is the 'proxyauth.c' test app posted by Shmulik Regev on the libcurl
* mailing list on 10 Jul 2007, converted to a test case.
*
* argv1 = URL
@@ -30,172 +18,97 @@
#include "test.h"
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define PROXY libtest_arg2
#define PROXYUSERPWD libtest_arg3
#define HOST test_argv[4]
#define NUM_HANDLES 2
CURL *eh[NUM_HANDLES];
static int init(int num, CURLM *cm, const char* url, const char* userpwd,
static void init(CURLM *cm, const char* url, const char* userpwd,
struct curl_slist *headers)
{
int res = 0;
CURL *eh = curl_easy_init();
res_easy_init(eh[num]);
if(res)
goto init_failed;
curl_easy_setopt(eh, CURLOPT_URL, url);
curl_easy_setopt(eh, CURLOPT_PROXY, PROXY);
curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd);
curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(eh, CURLOPT_HEADER, 1L);
curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */
res_easy_setopt(eh[num], CURLOPT_URL, url);
if(res)
goto init_failed;
res_easy_setopt(eh[num], CURLOPT_PROXY, PROXY);
if(res)
goto init_failed;
res_easy_setopt(eh[num], CURLOPT_PROXYUSERPWD, userpwd);
if(res)
goto init_failed;
res_easy_setopt(eh[num], CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
if(res)
goto init_failed;
res_easy_setopt(eh[num], CURLOPT_VERBOSE, 1L);
if(res)
goto init_failed;
res_easy_setopt(eh[num], CURLOPT_HEADER, 1L);
if(res)
goto init_failed;
res_easy_setopt(eh[num], CURLOPT_HTTPHEADER, headers); /* custom Host: */
if(res)
goto init_failed;
res_multi_add_handle(cm, eh[num]);
if(res)
goto init_failed;
return 0; /* success */
init_failed:
curl_easy_cleanup(eh[num]);
eh[num] = NULL;
return res; /* failure */
curl_multi_add_handle(cm, eh);
}
static int loop(int num, CURLM *cm, const char* url, const char* userpwd,
static int loop(CURLM *cm, const char* url, const char* userpwd,
struct curl_slist *headers)
{
CURLMsg *msg;
long L;
int Q, U = -1;
int M, Q, U = -1;
fd_set R, W, E;
struct timeval T;
int res = 0;
res = init(num, cm, url, userpwd, headers);
if(res)
return res;
init(cm, url, userpwd, headers);
while (U) {
int M = -99;
res_multi_perform(cm, &U);
if(res)
return res;
res_test_timedout();
if(res)
return res;
while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(cm, &U));
if (U) {
FD_ZERO(&R);
FD_ZERO(&W);
FD_ZERO(&E);
res_multi_fdset(cm, &R, &W, &E, &M);
if(res)
return res;
if (curl_multi_fdset(cm, &R, &W, &E, &M)) {
fprintf(stderr, "E: curl_multi_fdset\n");
return EXIT_FAILURE;
}
/* At this point, M is guaranteed to be greater or equal than -1. */
/* In a real-world program you OF COURSE check the return that maxfd is
bigger than -1 so that the call to select() below makes sense! */
res_multi_timeout(cm, &L);
if(res)
return res;
/* At this point, L is guaranteed to be greater or equal than -1. */
if (curl_multi_timeout(cm, &L)) {
fprintf(stderr, "E: curl_multi_timeout\n");
return EXIT_FAILURE;
}
if(L != -1) {
int itimeout = (L > (long)INT_MAX) ? INT_MAX : (int)L;
T.tv_sec = itimeout/1000;
T.tv_usec = (itimeout%1000)*1000;
T.tv_sec = L/1000;
T.tv_usec = (L%1000)*1000;
}
else {
T.tv_sec = 5;
T.tv_usec = 0;
}
res_select_test(M+1, &R, &W, &E, &T);
if(res)
return res;
if (0 > select(M+1, &R, &W, &E, &T)) {
fprintf(stderr, "E: select\n");
return EXIT_FAILURE;
}
}
while((msg = curl_multi_info_read(cm, &Q)) != NULL) {
if(msg->msg == CURLMSG_DONE) {
int i;
while ((msg = curl_multi_info_read(cm, &Q))) {
if (msg->msg == CURLMSG_DONE) {
CURL *e = msg->easy_handle;
fprintf(stderr, "R: %d - %s\n", (int)msg->data.result,
curl_easy_strerror(msg->data.result));
curl_multi_remove_handle(cm, e);
curl_easy_cleanup(e);
for(i=0; i < NUM_HANDLES; i++) {
if(eh[i] == e) {
eh[i] = NULL;
break;
}
}
}
else
else {
fprintf(stderr, "E: CURLMsg (%d)\n", (int)msg->msg);
}
}
res_test_timedout();
if(res)
return res;
}
return 0; /* success */
return 1;
}
int test(char *URL)
{
CURLM *cm = NULL;
CURLM *cm;
struct curl_slist *headers = NULL;
char buffer[246]; /* naively fixed-size */
int res = 0;
int i;
for(i=0; i < NUM_HANDLES; i++)
eh[i] = NULL;
start_test_timing();
if(test_argc < 4)
return 99;
@@ -204,45 +117,20 @@ int test(char *URL)
/* now add a custom Host: header */
headers = curl_slist_append(headers, buffer);
if(!headers) {
fprintf(stderr, "curl_slist_append() failed\n");
return TEST_ERR_MAJOR_BAD;
}
res_global_init(CURL_GLOBAL_ALL);
if(res) {
curl_slist_free_all(headers);
return res;
}
curl_global_init(CURL_GLOBAL_ALL);
res_multi_init(cm);
if(res) {
curl_global_cleanup();
curl_slist_free_all(headers);
return res;
}
res = loop(0, cm, URL, PROXYUSERPWD, headers);
if(res)
goto test_cleanup;
cm = curl_multi_init();
loop(cm, URL, PROXYUSERPWD, headers);
fprintf(stderr, "lib540: now we do the request again\n");
res = loop(1, cm, URL, PROXYUSERPWD, headers);
test_cleanup:
/* proper cleanup sequence - type PB */
for(i=0; i < NUM_HANDLES; i++) {
curl_multi_remove_handle(cm, eh[i]);
curl_easy_cleanup(eh[i]);
}
loop(cm, URL, PROXYUSERPWD, headers);
curl_multi_cleanup(cm);
curl_global_cleanup();
curl_slist_free_all(headers);
return res;
return EXIT_SUCCESS;
}
+41 -39
View File
@@ -1,30 +1,33 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib541.c,v 1.4 2008-09-20 04:26:57 yangtse Exp $
*/
#include "setup.h" /* struct_stat etc. */
#include "test.h"
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "memdebug.h"
/*
@@ -45,6 +48,25 @@ int test(char *URL)
return -1;
}
/* get the file size of the local file */
hd = stat(libtest_arg2, &file_info);
if(hd == -1) {
/* can't open file, bail out */
error = ERRNO;
fprintf(stderr, "stat() failed with error: %d %s\n",
error, strerror(error));
fprintf(stderr, "WARNING: cannot open file %s\n", libtest_arg2);
return -1;
}
if(! file_info.st_size) {
fprintf(stderr, "WARNING: file %s has no size!\n", libtest_arg2);
return -4;
}
/* get a FILE * of the same file, could also be made with
fdopen() from the previous descriptor, but hey this is just
an example! */
hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) {
error = ERRNO;
@@ -54,24 +76,6 @@ int test(char *URL)
return -2; /* if this happens things are major weird */
}
/* get the file size of the local file */
hd = fstat(fileno(hd_src), &file_info);
if(hd == -1) {
/* can't open file, bail out */
error = ERRNO;
fprintf(stderr, "fstat() failed with error: %d %s\n",
error, strerror(error));
fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2);
fclose(hd_src);
return -1;
}
if(! file_info.st_size) {
fprintf(stderr, "ERROR: file %s has zero size!\n", libtest_arg2);
fclose(hd_src);
return -4;
}
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
fclose(hd_src);
@@ -87,16 +91,16 @@ int test(char *URL)
}
/* enable uploading */
test_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* enable verbose */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* specify target */
test_setopt(curl,CURLOPT_URL, URL);
curl_easy_setopt(curl,CURLOPT_URL, URL);
/* now specify which file to upload */
test_setopt(curl, CURLOPT_INFILE, hd_src);
curl_easy_setopt(curl, CURLOPT_INFILE, hd_src);
/* Now run off and do what you've been told! */
res = curl_easy_perform(curl);
@@ -105,8 +109,6 @@ int test(char *URL)
is at end of file */
res = curl_easy_perform(curl);
test_cleanup:
/* close the local file */
fclose(hd_src);
+22 -21
View File
@@ -1,30 +1,33 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib542.c,v 1.4 2008-09-20 04:26:57 yangtse Exp $
*/
#include "setup.h" /* struct_stat etc. */
#include "test.h"
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "memdebug.h"
/*
@@ -49,22 +52,20 @@ int test(char *URL)
}
/* enable verbose */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* enable NOBODY */
test_setopt(curl, CURLOPT_NOBODY, 1L);
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
/* disable HEADER */
test_setopt(curl, CURLOPT_HEADER, 0L);
curl_easy_setopt(curl, CURLOPT_HEADER, 0L);
/* specify target */
test_setopt(curl,CURLOPT_URL, URL);
curl_easy_setopt(curl,CURLOPT_URL, URL);
/* Now run off and do what you've been told! */
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,26 +1,16 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
* $Id: lib543.c,v 1.2 2008-09-20 04:26:57 yangtse Exp $
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* Based on Alex Fishman's bug report on September 30, 2007 */
* Based on Alex Fishman's bug report on September 30, 2007
*/
#include "setup.h"
#include "test.h"
#include "memdebug.h"
@@ -31,26 +21,13 @@ int test(char *URL)
0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa,
0x1d, 0x57, 0xe1};
CURL *easy;
int asize;
char *s;
CURL* easy = curl_easy_init();
char* s = curl_easy_escape(easy, (char*)a, sizeof(a));
(void)URL;
if ((easy = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
asize = (int)sizeof(a);
s = curl_easy_escape(easy, (char*)a, asize);
if(s)
printf("%s\n", s);
if(s)
curl_free(s);
printf("%s\n", s);
curl_free(s);
curl_easy_cleanup(easy);
return 0;
@@ -1,37 +1,19 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib544.c,v 1.3 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
static char teststring[] =
#ifdef CURL_DOES_CONVERSIONS
/* ASCII representation with escape sequences for non-ASCII platforms */
"\x54\x68\x69\x73\x00\x20\x69\x73\x20\x74\x65\x73\x74\x20\x62\x69\x6e\x61"
"\x72\x79\x20\x64\x61\x74\x61\x20\x77\x69\x74\x68\x20\x61\x6e\x20\x65\x6d"
"\x62\x65\x64\x64\x65\x64\x20\x4e\x55\x4c\x20\x62\x79\x74\x65\x0a";
#else
"This\0 is test binary data with an embedded NUL byte\n";
#endif
int test(char *URL)
@@ -51,16 +33,16 @@ int test(char *URL)
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_URL, URL);
#ifdef LIB545
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring - 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring - 1);
#endif
test_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring);
curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring);
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
/* Update the original data to detect non-copy. */
strcpy(teststring, "FAIL");
@@ -68,8 +50,6 @@ int test(char *URL)
/* Now, this is a POST request with binary 0 embedded in POST data. */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
+17 -38
View File
@@ -1,25 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
* $Id: lib547.c,v 1.6 2008-09-20 04:26:57 yangtse Exp $
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* argv1 = URL
* argv1 = URL
* argv2 = proxy
* argv3 = proxyuser:password
*/
@@ -28,14 +16,7 @@
#include "memdebug.h"
#ifdef CURL_DOES_CONVERSIONS
/* ASCII representation with escape sequences for non-ASCII platforms */
# define UPLOADTHIS "\x74\x68\x69\x73\x20\x69\x73\x20\x74\x68\x65\x20\x62" \
"\x6c\x75\x72\x62\x20\x77\x65\x20\x77\x61\x6e\x74\x20" \
"\x74\x6f\x20\x75\x70\x6c\x6f\x61\x64\x0a"
#else
# define UPLOADTHIS "this is the blurb we want to upload\n"
#endif
#define UPLOADTHIS "this is the blurb we want to upload\n"
#ifndef LIB548
static size_t readcallback(void *ptr,
@@ -96,31 +77,29 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
#ifdef LIB548
/* set the data to POST with a mere pointer to a zero-terminated string */
test_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS);
#else
/* 547 style, which means reading the POST data from a callback */
test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
test_setopt(curl, CURLOPT_IOCTLDATA, &counter);
test_setopt(curl, CURLOPT_READFUNCTION, readcallback);
test_setopt(curl, CURLOPT_READDATA, &counter);
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback);
curl_easy_setopt(curl, CURLOPT_READDATA, &counter);
/* We CANNOT do the POST fine without setting the size (or choose chunked)! */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS));
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS));
#endif
test_setopt(curl, CURLOPT_POST, 1L);
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
test_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
test_setopt(curl, CURLOPT_PROXYAUTH,
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
curl_easy_setopt(curl, CURLOPT_PROXYAUTH,
(long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
@@ -1,25 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
* $Id: lib549.c,v 1.3 2008-09-20 04:26:57 yangtse Exp $
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* argv1 = URL
* argv1 = URL
* argv2 = proxy
* argv3 = non-zero means ASCII transfer
*/
@@ -44,19 +32,16 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
if(libtest_arg3) {
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
if(libtest_arg3)
/* enable ascii/text mode */
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
}
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
+40 -63
View File
@@ -1,31 +1,18 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
* $Id: lib552.c,v 1.7 2008-09-20 04:26:57 yangtse Exp $
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* argv1 = URL
* argv1 = URL
* argv2 = proxy with embedded user+password
*/
#include "test.h"
#include "warnless.h"
#include "memdebug.h"
struct data {
@@ -137,8 +124,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{
int amount = curlx_uztosi(size * nmemb);
printf("%.*s", amount, (char *)ptr);
printf("%.*s", (int)(size * nmemb), (char *)ptr);
(void)stream;
return size * nmemb;
}
@@ -169,52 +155,43 @@ int test(char *URL)
config.trace_ascii = 1; /* enable ascii tracing */
if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config);
/* the DEBUGFUNCTION has no effect until we enable VERBOSE */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* setup repeated data string */
for (i=0; i < sizeof(databuf); ++i)
databuf[i] = fill[i % sizeof fill];
/* Post */
curl_easy_setopt(curl, CURLOPT_POST, 1L);
/* Setup read callback */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf));
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* Write callback */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
/* Ioctl function */
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(curl, CURLOPT_URL, URL);
/* Accept any auth. But for this bug configure proxy with DIGEST, basic might work too, not NTLM */
curl_easy_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
res = curl_easy_perform(curl);
fprintf(stderr, "curl_easy_perform = %d\n", (int)res);
/* always cleanup */
curl_easy_cleanup(curl);
}
test_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
test_setopt(curl, CURLOPT_DEBUGDATA, &config);
/* the DEBUGFUNCTION has no effect until we enable VERBOSE */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* setup repeated data string */
for (i=0; i < sizeof(databuf); ++i)
databuf[i] = fill[i % sizeof fill];
/* Post */
test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
/* Setup read callback */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf));
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* Write callback */
test_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
/* Ioctl function */
test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
test_setopt(curl, CURLOPT_URL, URL);
/* Accept any auth. But for this bug configure proxy with DIGEST, basic might work too, not NTLM */
test_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
res = curl_easy_perform(curl);
fprintf(stderr, "curl_easy_perform = %d\n", (int)res);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
+31 -58
View File
@@ -1,26 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
* $Id: lib553.c,v 1.5 2008-10-01 17:34:25 danf Exp $
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* This test case and code is based on the bug recipe Joe Malicki provided for
* This test case and code is based on the bug recipe Joe Malicki provided for
* bug report #1871269, fixed on Jan 14 2008 before the 7.18.0 release.
*/
@@ -62,52 +49,38 @@ int test(char *URL)
int i;
struct curl_slist *headerlist=NULL, *hl;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
for (i = 0; i < NUM_HEADERS; i++) {
int len = sprintf(buf, "Header%d: ", i);
memset(&buf[len], 'A', SIZE_HEADERS);
buf[len + SIZE_HEADERS]=0; /* zero terminate */
hl = curl_slist_append(headerlist, buf);
if(curl) {
for (i = 0; i < NUM_HEADERS; i++) {
int len = sprintf(buf, "Header%d: ", i);
memset(&buf[len], 'A', SIZE_HEADERS);
buf[len + SIZE_HEADERS]=0; /* zero terminate */
hl = curl_slist_append(headerlist, buf);
if (!hl)
goto errout;
headerlist = hl;
}
hl = curl_slist_append(headerlist, "Expect: ");
if (!hl)
goto test_cleanup;
goto errout;
headerlist = hl;
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
res = curl_easy_perform(curl);
errout:
curl_easy_cleanup(curl);
curl_slist_free_all(headerlist);
}
hl = curl_slist_append(headerlist, "Expect: ");
if (!hl)
goto test_cleanup;
headerlist = hl;
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_slist_free_all(headerlist);
curl_global_cleanup();
return (int)res;
+16 -84
View File
@@ -1,37 +1,18 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib554.c,v 1.5 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
static char data[]=
#ifdef CURL_DOES_CONVERSIONS
/* ASCII representation with escape sequences for non-ASCII platforms */
"\x74\x68\x69\x73\x20\x69\x73\x20\x77\x68\x61\x74\x20\x77\x65\x20\x70"
"\x6f\x73\x74\x20\x74\x6f\x20\x74\x68\x65\x20\x73\x69\x6c\x6c\x79\x20"
"\x77\x65\x62\x20\x73\x65\x72\x76\x65\x72\x0a";
#else
"this is what we post to the silly web server\n";
#endif
static char data[]="this is what we post to the silly web server\n";
struct WriteThis {
char *readptr;
@@ -40,14 +21,6 @@ struct WriteThis {
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
{
#ifdef LIB587
(void)ptr;
(void)size;
(void)nmemb;
(void)userp;
return CURL_READFUNC_ABORT;
#else
struct WriteThis *pooh = (struct WriteThis *)userp;
if(size*nmemb < 1)
@@ -61,7 +34,6 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
}
return 0; /* no more data left to deliver */
#endif
}
int test(char *URL)
@@ -73,7 +45,6 @@ int test(char *URL)
struct curl_httppost *formpost=NULL;
struct curl_httppost *lastptr=NULL;
struct WriteThis pooh;
struct WriteThis pooh2;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
@@ -88,42 +59,18 @@ int test(char *URL)
&lastptr,
CURLFORM_COPYNAME, "sendfile",
CURLFORM_STREAM, &pooh,
CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft,
CURLFORM_CONTENTSLENGTH, pooh.sizeleft,
CURLFORM_FILENAME, "postit2.c",
CURLFORM_END);
if(formrc)
printf("curl_formadd(1) = %d\n", (int)formrc);
/* Now add the same data with another name and make it not look like
a file upload but still using the callback */
pooh2.readptr = data;
pooh2.sizeleft = strlen(data);
/* Fill in the file upload field */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "callbackdata",
CURLFORM_STREAM, &pooh2,
CURLFORM_CONTENTSLENGTH, (long)pooh2.sizeleft,
CURLFORM_END);
if(formrc)
printf("curl_formadd(1) = %d\n", (int)formrc);
/* Fill in the filename field */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filename",
#ifdef CURL_DOES_CONVERSIONS
/* ASCII representation with escape
sequences for non-ASCII platforms */
CURLFORM_COPYCONTENTS,
"\x70\x6f\x73\x74\x69\x74\x32\x2e\x63",
#else
CURLFORM_COPYCONTENTS, "postit2.c",
#endif
CURLFORM_END);
if(formrc)
@@ -133,28 +80,12 @@ int test(char *URL)
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "submit",
#ifdef CURL_DOES_CONVERSIONS
/* ASCII representation with escape
sequences for non-ASCII platforms */
CURLFORM_COPYCONTENTS, "\x73\x65\x6e\x64",
#else
CURLFORM_COPYCONTENTS, "send",
#endif
CURLFORM_END);
if(formrc)
printf("curl_formadd(3) = %d\n", (int)formrc);
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, "somename",
CURLFORM_BUFFER, "somefile.txt",
CURLFORM_BUFFERPTR, "blah blah",
CURLFORM_BUFFERLENGTH, (long)9,
CURLFORM_END);
if(formrc)
printf("curl_formadd(4) = %d\n", (int)formrc);
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_formfree(formpost);
@@ -163,31 +94,32 @@ int test(char *URL)
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POST, 1L);
/* Set the expected POST size */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
/* we want to use our own read function */
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* pointer to pass to our read function */
curl_easy_setopt(curl, CURLOPT_READDATA, &pooh);
/* send a multi-part formpost */
test_setopt(curl, CURLOPT_HTTPPOST, formpost);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
+75 -86
View File
@@ -1,26 +1,13 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
* $Id: lib555.c,v 1.4 2008-09-20 04:26:57 yangtse Exp $
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* This test case is supposed to be identical to 547 except that this uses the
* This test case is supposed to be identical to 547 except that this uses the
* multi interface and 547 is easy interface.
*
* argv1 = URL
@@ -30,10 +17,9 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
#define UPLOADTHIS "this is the blurb we want to upload\n"
@@ -75,83 +61,86 @@ static curlioerr ioctlcallback(CURL *handle,
int test(char *URL)
{
int res = 0;
CURL *curl = NULL;
int res;
CURL *curl;
int counter=0;
CURLM *m = NULL;
CURLM *m;
int running=1;
struct timeval mp_start;
char mp_timedout = FALSE;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
easy_setopt(curl, CURLOPT_HEADER, 1L);
/* read the POST data from a callback */
easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
easy_setopt(curl, CURLOPT_IOCTLDATA, &counter);
easy_setopt(curl, CURLOPT_READFUNCTION, readcallback);
easy_setopt(curl, CURLOPT_READDATA, &counter);
/* We CANNOT do the POST fine without setting the size (or choose chunked)! */
easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS));
easy_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII. */
easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
easy_setopt(curl, CURLOPT_PROXYAUTH,
(long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
multi_init(m);
multi_add_handle(m, curl);
while (running) {
struct timeval timeout;
fd_set fdread, fdwrite, fdexcep;
int maxfd = -99;
timeout.tv_sec = 0;
timeout.tv_usec = 100000L; /* 100 ms */
multi_perform(m, &running);
abort_on_test_timeout();
#ifdef TPF
sleep(1); /* avoid ctl-10 dump */
#endif
if(!running)
break; /* done */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
test_cleanup:
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* proper cleanup sequence - type PA */
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
/* read the POST data from a callback */
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback);
curl_easy_setopt(curl, CURLOPT_READDATA, &counter);
/* We CANNOT do the POST fine without setting the size (or choose chunked)! */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS));
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
curl_easy_setopt(curl, CURLOPT_PROXYAUTH,
(long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n");
curl_easy_cleanup(curl);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
if ((res = (int)curl_multi_add_handle(m, curl)) != CURLM_OK) {
fprintf(stderr, "curl_multi_add_handle() failed, "
"with code %d\n", res);
curl_multi_cleanup(m);
curl_easy_cleanup(curl);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
mp_timedout = FALSE;
mp_start = tutil_tvnow();
while (running) {
res = (int)curl_multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
if (running <= 0) {
fprintf(stderr, "nothing left running.\n");
break;
}
}
if (mp_timedout) {
if (mp_timedout) fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
res = TEST_ERR_RUNS_FOREVER;
}
curl_multi_remove_handle(m, curl);
curl_multi_cleanup(m);
curl_easy_cleanup(curl);
curl_multi_cleanup(m);
curl_global_cleanup();
return res;
+11 -48
View File
@@ -1,39 +1,17 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib556.c,v 1.4 2008-09-20 04:26:57 yangtse Exp $
*/
#include "test.h"
#include "memdebug.h"
/* For Windows, mainly (may be moved in a config file?) */
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif
int test(char *URL)
{
CURLcode res;
@@ -50,24 +28,15 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
res = curl_easy_perform(curl);
if(!res) {
/* we are connected, now get a HTTP document the raw way */
const char *request =
#ifdef CURL_DOES_CONVERSIONS
/* ASCII representation with escape sequences for non-ASCII platforms */
"\x47\x45\x54\x20\x2f\x35\x35\x36\x20\x48\x54\x54\x50\x2f\x31\x2e"
"\x32\x0d\x0a\x48\x6f\x73\x74\x3a\x20\x6e\x69\x6e\x6a\x61\x0d\x0a"
"\x0d\x0a";
#else
"GET /556 HTTP/1.2\r\n"
const char *request = "GET /556 HTTP/1.2\r\n"
"Host: ninja\r\n\r\n";
#endif
size_t iolen;
char buf[1024];
@@ -75,28 +44,22 @@ int test(char *URL)
if(!res) {
/* we assume that sending always work */
size_t total=0;
int total=0;
do {
/* busy-read like crazy */
res = curl_easy_recv(curl, buf, 1024, &iolen);
#ifdef TPF
sleep(1); /* avoid ctl-10 dump */
#endif
if(iolen) {
if(iolen)
/* send received stuff to stdout */
if(!write(STDOUT_FILENO, buf, iolen))
break;
}
write(STDOUT_FILENO, buf, iolen);
total += iolen;
} while(((res == CURLE_OK) || (res == CURLE_AGAIN)) && (total < 129));
}
}
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
+8 -319
View File
@@ -1,24 +1,12 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: lib557.c,v 1.7 2008-09-21 03:48:25 yangtse Exp $
*/
/*
* The purpose of this test is to minimally exercise libcurl's internal
@@ -49,8 +37,6 @@
#define BUFSZ 256
#define USHORT_TESTS_ARRSZ 1 + 100
#define SSHORT_TESTS_ARRSZ 1 + 100
#define UINT_TESTS_ARRSZ 1 + 100
#define SINT_TESTS_ARRSZ 1 + 100
#define ULONG_TESTS_ARRSZ 1 + 100
@@ -58,20 +44,6 @@
#define COFFT_TESTS_ARRSZ 1 + 100
struct unsshort_st {
unsigned short num; /* unsigned short */
const char *expected; /* expected string */
char result[BUFSZ]; /* result string */
};
struct sigshort_st {
short num; /* signed short */
const char *expected; /* expected string */
char result[BUFSZ]; /* result string */
};
struct unsint_st {
unsigned int num; /* unsigned int */
const char *expected; /* expected string */
@@ -107,290 +79,11 @@ struct curloff_st {
};
static struct unsshort_st us_test[USHORT_TESTS_ARRSZ];
static struct sigshort_st ss_test[SSHORT_TESTS_ARRSZ];
static struct unsint_st ui_test[UINT_TESTS_ARRSZ];
static struct sigint_st si_test[SINT_TESTS_ARRSZ];
static struct unslong_st ul_test[ULONG_TESTS_ARRSZ];
static struct siglong_st sl_test[SLONG_TESTS_ARRSZ];
static struct curloff_st co_test[COFFT_TESTS_ARRSZ];
static int test_unsigned_short_formatting(void)
{
int i, j;
int num_ushort_tests;
int failed = 0;
#if (SIZEOF_SHORT == 1)
i=1; us_test[i].num = 0xFFU; us_test[i].expected = "256";
i++; us_test[i].num = 0xF0U; us_test[i].expected = "240";
i++; us_test[i].num = 0x0FU; us_test[i].expected = "15";
i++; us_test[i].num = 0xE0U; us_test[i].expected = "224";
i++; us_test[i].num = 0x0EU; us_test[i].expected = "14";
i++; us_test[i].num = 0xC0U; us_test[i].expected = "192";
i++; us_test[i].num = 0x0CU; us_test[i].expected = "12";
i++; us_test[i].num = 0x01U; us_test[i].expected = "1";
i++; us_test[i].num = 0x00U; us_test[i].expected = "0";
num_ushort_tests = i;
#elif (SIZEOF_SHORT == 2)
i=1; us_test[i].num = 0xFFFFU; us_test[i].expected = "65535";
i++; us_test[i].num = 0xFF00U; us_test[i].expected = "65280";
i++; us_test[i].num = 0x00FFU; us_test[i].expected = "255";
i++; us_test[i].num = 0xF000U; us_test[i].expected = "61440";
i++; us_test[i].num = 0x0F00U; us_test[i].expected = "3840";
i++; us_test[i].num = 0x00F0U; us_test[i].expected = "240";
i++; us_test[i].num = 0x000FU; us_test[i].expected = "15";
i++; us_test[i].num = 0xC000U; us_test[i].expected = "49152";
i++; us_test[i].num = 0x0C00U; us_test[i].expected = "3072";
i++; us_test[i].num = 0x00C0U; us_test[i].expected = "192";
i++; us_test[i].num = 0x000CU; us_test[i].expected = "12";
i++; us_test[i].num = 0x0001U; us_test[i].expected = "1";
i++; us_test[i].num = 0x0000U; us_test[i].expected = "0";
num_ushort_tests = i;
#elif (SIZEOF_SHORT == 4)
i=1; us_test[i].num = 0xFFFFFFFFU; us_test[i].expected = "4294967295";
i++; us_test[i].num = 0xFFFF0000U; us_test[i].expected = "4294901760";
i++; us_test[i].num = 0x0000FFFFU; us_test[i].expected = "65535";
i++; us_test[i].num = 0xFF000000U; us_test[i].expected = "4278190080";
i++; us_test[i].num = 0x00FF0000U; us_test[i].expected = "16711680";
i++; us_test[i].num = 0x0000FF00U; us_test[i].expected = "65280";
i++; us_test[i].num = 0x000000FFU; us_test[i].expected = "255";
i++; us_test[i].num = 0xF0000000U; us_test[i].expected = "4026531840";
i++; us_test[i].num = 0x0F000000U; us_test[i].expected = "251658240";
i++; us_test[i].num = 0x00F00000U; us_test[i].expected = "15728640";
i++; us_test[i].num = 0x000F0000U; us_test[i].expected = "983040";
i++; us_test[i].num = 0x0000F000U; us_test[i].expected = "61440";
i++; us_test[i].num = 0x00000F00U; us_test[i].expected = "3840";
i++; us_test[i].num = 0x000000F0U; us_test[i].expected = "240";
i++; us_test[i].num = 0x0000000FU; us_test[i].expected = "15";
i++; us_test[i].num = 0xC0000000U; us_test[i].expected = "3221225472";
i++; us_test[i].num = 0x0C000000U; us_test[i].expected = "201326592";
i++; us_test[i].num = 0x00C00000U; us_test[i].expected = "12582912";
i++; us_test[i].num = 0x000C0000U; us_test[i].expected = "786432";
i++; us_test[i].num = 0x0000C000U; us_test[i].expected = "49152";
i++; us_test[i].num = 0x00000C00U; us_test[i].expected = "3072";
i++; us_test[i].num = 0x000000C0U; us_test[i].expected = "192";
i++; us_test[i].num = 0x0000000CU; us_test[i].expected = "12";
i++; us_test[i].num = 0x00000001U; us_test[i].expected = "1";
i++; us_test[i].num = 0x00000000U; us_test[i].expected = "0";
num_ushort_tests = i;
#endif
for(i=1; i<=num_ushort_tests; i++) {
for(j=0; j<BUFSZ; j++)
us_test[i].result[j] = 'X';
us_test[i].result[BUFSZ-1] = '\0';
(void)curl_msprintf(us_test[i].result, "%hu", us_test[i].num);
if(memcmp(us_test[i].result,
us_test[i].expected,
strlen(us_test[i].expected))) {
printf("unsigned short test #%.2d: Failed (Expected: %s Got: %s)\n",
i, us_test[i].expected, us_test[i].result);
failed++;
}
}
if(!failed)
printf("All curl_mprintf() unsigned short tests OK!\n");
else
printf("Some curl_mprintf() unsigned short tests Failed!\n");
return failed;
}
static int test_signed_short_formatting(void)
{
int i, j;
int num_sshort_tests;
int failed = 0;
#if (SIZEOF_SHORT == 1)
i=1; ss_test[i].num = 0x7F; ss_test[i].expected = "127";
i++; ss_test[i].num = 0x70; ss_test[i].expected = "112";
i++; ss_test[i].num = 0x07; ss_test[i].expected = "7";
i++; ss_test[i].num = 0x50; ss_test[i].expected = "80";
i++; ss_test[i].num = 0x05; ss_test[i].expected = "5";
i++; ss_test[i].num = 0x01; ss_test[i].expected = "1";
i++; ss_test[i].num = 0x00; ss_test[i].expected = "0";
i++; ss_test[i].num = -0x7F -1; ss_test[i].expected = "-128";
i++; ss_test[i].num = -0x70 -1; ss_test[i].expected = "-113";
i++; ss_test[i].num = -0x07 -1; ss_test[i].expected = "-8";
i++; ss_test[i].num = -0x50 -1; ss_test[i].expected = "-81";
i++; ss_test[i].num = -0x05 -1; ss_test[i].expected = "-6";
i++; ss_test[i].num = 0x00 -1; ss_test[i].expected = "-1";
num_sshort_tests = i;
#elif (SIZEOF_SHORT == 2)
i=1; ss_test[i].num = 0x7FFF; ss_test[i].expected = "32767";
i++; ss_test[i].num = 0x7FFE; ss_test[i].expected = "32766";
i++; ss_test[i].num = 0x7FFD; ss_test[i].expected = "32765";
i++; ss_test[i].num = 0x7F00; ss_test[i].expected = "32512";
i++; ss_test[i].num = 0x07F0; ss_test[i].expected = "2032";
i++; ss_test[i].num = 0x007F; ss_test[i].expected = "127";
i++; ss_test[i].num = 0x7000; ss_test[i].expected = "28672";
i++; ss_test[i].num = 0x0700; ss_test[i].expected = "1792";
i++; ss_test[i].num = 0x0070; ss_test[i].expected = "112";
i++; ss_test[i].num = 0x0007; ss_test[i].expected = "7";
i++; ss_test[i].num = 0x5000; ss_test[i].expected = "20480";
i++; ss_test[i].num = 0x0500; ss_test[i].expected = "1280";
i++; ss_test[i].num = 0x0050; ss_test[i].expected = "80";
i++; ss_test[i].num = 0x0005; ss_test[i].expected = "5";
i++; ss_test[i].num = 0x0001; ss_test[i].expected = "1";
i++; ss_test[i].num = 0x0000; ss_test[i].expected = "0";
i++; ss_test[i].num = -0x7FFF -1; ss_test[i].expected = "-32768";
i++; ss_test[i].num = -0x7FFE -1; ss_test[i].expected = "-32767";
i++; ss_test[i].num = -0x7FFD -1; ss_test[i].expected = "-32766";
i++; ss_test[i].num = -0x7F00 -1; ss_test[i].expected = "-32513";
i++; ss_test[i].num = -0x07F0 -1; ss_test[i].expected = "-2033";
i++; ss_test[i].num = -0x007F -1; ss_test[i].expected = "-128";
i++; ss_test[i].num = -0x7000 -1; ss_test[i].expected = "-28673";
i++; ss_test[i].num = -0x0700 -1; ss_test[i].expected = "-1793";
i++; ss_test[i].num = -0x0070 -1; ss_test[i].expected = "-113";
i++; ss_test[i].num = -0x0007 -1; ss_test[i].expected = "-8";
i++; ss_test[i].num = -0x5000 -1; ss_test[i].expected = "-20481";
i++; ss_test[i].num = -0x0500 -1; ss_test[i].expected = "-1281";
i++; ss_test[i].num = -0x0050 -1; ss_test[i].expected = "-81";
i++; ss_test[i].num = -0x0005 -1; ss_test[i].expected = "-6";
i++; ss_test[i].num = 0x0000 -1; ss_test[i].expected = "-1";
num_sshort_tests = i;
#elif (SIZEOF_SHORT == 4)
i=1; ss_test[i].num = 0x7FFFFFFF; ss_test[i].expected = "2147483647";
i++; ss_test[i].num = 0x7FFFFFFE; ss_test[i].expected = "2147483646";
i++; ss_test[i].num = 0x7FFFFFFD; ss_test[i].expected = "2147483645";
i++; ss_test[i].num = 0x7FFF0000; ss_test[i].expected = "2147418112";
i++; ss_test[i].num = 0x00007FFF; ss_test[i].expected = "32767";
i++; ss_test[i].num = 0x7F000000; ss_test[i].expected = "2130706432";
i++; ss_test[i].num = 0x007F0000; ss_test[i].expected = "8323072";
i++; ss_test[i].num = 0x00007F00; ss_test[i].expected = "32512";
i++; ss_test[i].num = 0x0000007F; ss_test[i].expected = "127";
i++; ss_test[i].num = 0x70000000; ss_test[i].expected = "1879048192";
i++; ss_test[i].num = 0x07000000; ss_test[i].expected = "117440512";
i++; ss_test[i].num = 0x00700000; ss_test[i].expected = "7340032";
i++; ss_test[i].num = 0x00070000; ss_test[i].expected = "458752";
i++; ss_test[i].num = 0x00007000; ss_test[i].expected = "28672";
i++; ss_test[i].num = 0x00000700; ss_test[i].expected = "1792";
i++; ss_test[i].num = 0x00000070; ss_test[i].expected = "112";
i++; ss_test[i].num = 0x00000007; ss_test[i].expected = "7";
i++; ss_test[i].num = 0x50000000; ss_test[i].expected = "1342177280";
i++; ss_test[i].num = 0x05000000; ss_test[i].expected = "83886080";
i++; ss_test[i].num = 0x00500000; ss_test[i].expected = "5242880";
i++; ss_test[i].num = 0x00050000; ss_test[i].expected = "327680";
i++; ss_test[i].num = 0x00005000; ss_test[i].expected = "20480";
i++; ss_test[i].num = 0x00000500; ss_test[i].expected = "1280";
i++; ss_test[i].num = 0x00000050; ss_test[i].expected = "80";
i++; ss_test[i].num = 0x00000005; ss_test[i].expected = "5";
i++; ss_test[i].num = 0x00000001; ss_test[i].expected = "1";
i++; ss_test[i].num = 0x00000000; ss_test[i].expected = "0";
i++; ss_test[i].num = -0x7FFFFFFF -1; ss_test[i].expected = "-2147483648";
i++; ss_test[i].num = -0x7FFFFFFE -1; ss_test[i].expected = "-2147483647";
i++; ss_test[i].num = -0x7FFFFFFD -1; ss_test[i].expected = "-2147483646";
i++; ss_test[i].num = -0x7FFF0000 -1; ss_test[i].expected = "-2147418113";
i++; ss_test[i].num = -0x00007FFF -1; ss_test[i].expected = "-32768";
i++; ss_test[i].num = -0x7F000000 -1; ss_test[i].expected = "-2130706433";
i++; ss_test[i].num = -0x007F0000 -1; ss_test[i].expected = "-8323073";
i++; ss_test[i].num = -0x00007F00 -1; ss_test[i].expected = "-32513";
i++; ss_test[i].num = -0x0000007F -1; ss_test[i].expected = "-128";
i++; ss_test[i].num = -0x70000000 -1; ss_test[i].expected = "-1879048193";
i++; ss_test[i].num = -0x07000000 -1; ss_test[i].expected = "-117440513";
i++; ss_test[i].num = -0x00700000 -1; ss_test[i].expected = "-7340033";
i++; ss_test[i].num = -0x00070000 -1; ss_test[i].expected = "-458753";
i++; ss_test[i].num = -0x00007000 -1; ss_test[i].expected = "-28673";
i++; ss_test[i].num = -0x00000700 -1; ss_test[i].expected = "-1793";
i++; ss_test[i].num = -0x00000070 -1; ss_test[i].expected = "-113";
i++; ss_test[i].num = -0x00000007 -1; ss_test[i].expected = "-8";
i++; ss_test[i].num = -0x50000000 -1; ss_test[i].expected = "-1342177281";
i++; ss_test[i].num = -0x05000000 -1; ss_test[i].expected = "-83886081";
i++; ss_test[i].num = -0x00500000 -1; ss_test[i].expected = "-5242881";
i++; ss_test[i].num = -0x00050000 -1; ss_test[i].expected = "-327681";
i++; ss_test[i].num = -0x00005000 -1; ss_test[i].expected = "-20481";
i++; ss_test[i].num = -0x00000500 -1; ss_test[i].expected = "-1281";
i++; ss_test[i].num = -0x00000050 -1; ss_test[i].expected = "-81";
i++; ss_test[i].num = -0x00000005 -1; ss_test[i].expected = "-6";
i++; ss_test[i].num = 0x00000000 -1; ss_test[i].expected = "-1";
num_sshort_tests = i;
#endif
for(i=1; i<=num_sshort_tests; i++) {
for(j=0; j<BUFSZ; j++)
ss_test[i].result[j] = 'X';
ss_test[i].result[BUFSZ-1] = '\0';
(void)curl_msprintf(ss_test[i].result, "%hd", ss_test[i].num);
if(memcmp(ss_test[i].result,
ss_test[i].expected,
strlen(ss_test[i].expected))) {
printf("signed short test #%.2d: Failed (Expected: %s Got: %s)\n",
i, ss_test[i].expected, ss_test[i].result);
failed++;
}
}
if(!failed)
printf("All curl_mprintf() signed short tests OK!\n");
else
printf("Some curl_mprintf() signed short tests Failed!\n");
return failed;
}
static struct unsint_st ui_test[UINT_TESTS_ARRSZ];
static struct sigint_st si_test[SINT_TESTS_ARRSZ];
static struct unslong_st ul_test[ULONG_TESTS_ARRSZ];
static struct siglong_st sl_test[SLONG_TESTS_ARRSZ];
static struct curloff_st co_test[COFFT_TESTS_ARRSZ];
static int test_unsigned_int_formatting(void)
@@ -1380,10 +1073,6 @@ int test(char *URL)
int errors = 0;
(void)URL; /* not used */
errors += test_unsigned_short_formatting();
errors += test_signed_short_formatting();
errors += test_unsigned_int_formatting();
errors += test_signed_int_formatting();
@@ -0,0 +1,181 @@
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* $Id: lib558.c,v 1.9 2008-11-07 12:22:43 yangtse Exp $
*/
#include "test.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#define ENABLE_CURLX_PRINTF
#include "curlx.h"
#include "hash.h"
#include "hostip.h"
#include "memory.h"
#include "memdebug.h"
/* This source file is used for test # 558 and 559 */
/*
* This hacky test bypasses the library external API,
* using internal only libcurl functions. So don't be
* surprised if we cannot run it when the library has
* been built with hidden symbols, exporting only the
* ones in the public API.
*/
#if !defined(CURL_HIDDEN_SYMBOLS)
#ifdef LIB559
static Curl_addrinfo *fake_ai(void)
{
Curl_addrinfo *ai;
int ss_size;
ss_size = sizeof (struct sockaddr_in);
if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL)
return NULL;
if((ai->ai_canonname = strdup("dummy")) == NULL) {
free(ai);
return NULL;
}
if((ai->ai_addr = calloc(1, ss_size)) == NULL) {
free(ai->ai_canonname);
free(ai);
return NULL;
}
ai->ai_family = AF_INET;
ai->ai_addrlen = ss_size;
return ai;
}
#endif /* LIB559 */
int test(char *URL)
{
CURL *easyh = NULL;
struct curl_hash *hp = NULL;
int result = 0;
if(!strcmp(URL, "check")) {
/* test harness script verifying if this test can run */
return 0; /* sure, run this! */
}
easyh = curl_easy_init();
if(!easyh) {
fprintf(stdout, "easy handle init failed\n");
result = TEST_ERR_MAJOR_BAD;
goto cleanup;
}
fprintf(stdout, "easy handle init OK\n");
fprintf(stdout, "creating hash...\n");
hp = Curl_mk_dnscache();
if(!hp) {
fprintf(stdout, "hash creation failed\n");
result = TEST_ERR_MAJOR_BAD;
goto cleanup;
}
fprintf(stdout, "hash creation OK\n");
/**/
#ifdef LIB559
{
char *data_key;
struct Curl_dns_entry *data_node;
struct Curl_dns_entry *nodep;
size_t key_len;
data_key = aprintf("%s:%d", "dummy", 0);
if(!data_key) {
fprintf(stdout, "data key creation failed\n");
result = TEST_ERR_MAJOR_BAD;
goto cleanup;
}
key_len = strlen(data_key);
data_node = calloc(1, sizeof(struct Curl_dns_entry));
if(!data_node) {
fprintf(stdout, "data node creation failed\n");
result = TEST_ERR_MAJOR_BAD;
free(data_key);
goto cleanup;
}
data_node->addr = fake_ai();
if(!data_node->addr) {
fprintf(stdout, "actual data creation failed\n");
result = TEST_ERR_MAJOR_BAD;
free(data_node);
free(data_key);
goto cleanup;
}
nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node);
if(!nodep) {
fprintf(stdout, "insertion into hash failed\n");
result = TEST_ERR_MAJOR_BAD;
Curl_freeaddrinfo(data_node->addr);
free(data_node);
free(data_key);
goto cleanup;
}
free(data_key);
}
#endif /* LIB559 */
/**/
cleanup:
fprintf(stdout, "destroying hash...\n");
Curl_hash_destroy(hp);
fprintf(stdout, "hash destruction OK\n");
fprintf(stdout, "destroying easy handle...\n");
curl_easy_cleanup(easyh);
fprintf(stdout, "easy handle destruction OK\n");
curl_global_cleanup();
return result;
}
#else /* !defined(CURL_HIDDEN_SYMBOLS) */
int test(char *URL)
{
(void)URL;
fprintf(stdout, "libcurl built with hidden symbols");
return 1; /* skip test */
}
#endif /* !defined(CURL_HIDDEN_SYMBOLS) */
+41 -56
View File
@@ -1,32 +1,15 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
* $Id: lib560.c,v 1.2 2008-11-12 22:26:06 danf Exp $
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
*/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
/*
* Simply download a HTTPS file!
*
@@ -39,44 +22,43 @@
*/
int test(char *URL)
{
CURL *http_handle = NULL;
CURLM *multi_handle = NULL;
int res = 0;
CURL *http_handle;
CURLM *multi_handle;
int still_running; /* keep number of running handles */
start_test_timing();
/*
** curl_global_init called indirectly from curl_easy_init.
*/
easy_init(http_handle);
http_handle = curl_easy_init();
if (!http_handle)
return TEST_ERR_MAJOR_BAD;
/* set options */
easy_setopt(http_handle, CURLOPT_URL, URL);
easy_setopt(http_handle, CURLOPT_HEADER, 1L);
easy_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
easy_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(http_handle, CURLOPT_URL, URL);
curl_easy_setopt(http_handle, CURLOPT_HEADER, 1L);
curl_easy_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
/* init a multi stack */
multi_init(multi_handle);
multi_handle = curl_multi_init();
if (!multi_handle) {
curl_easy_cleanup(http_handle);
return TEST_ERR_MAJOR_BAD;
}
/* add the individual transfers */
multi_add_handle(multi_handle, http_handle);
curl_multi_add_handle(multi_handle, http_handle);
/* we start some action by calling perform right away */
multi_perform(multi_handle, &still_running);
abort_on_test_timeout();
while(CURLM_CALL_MULTI_PERFORM ==
curl_multi_perform(multi_handle, &still_running));
while(still_running) {
struct timeval timeout;
int rc; /* select() return code */
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -99;
int maxfd;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
@@ -87,27 +69,30 @@ int test(char *URL)
timeout.tv_usec = 0;
/* get file descriptors from the transfers */
multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
/* In a real-world program you OF COURSE check the return code of the
function calls, *and* you make sure that maxfd is bigger than -1 so
that the call to select() below makes sense! */
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
/* timeout or readable/writable sockets */
multi_perform(multi_handle, &still_running);
abort_on_test_timeout();
switch(rc) {
case -1:
/* select error */
break;
case 0:
default:
/* timeout or readable/writable sockets */
while(CURLM_CALL_MULTI_PERFORM ==
curl_multi_perform(multi_handle, &still_running));
break;
}
}
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi_handle);
curl_easy_cleanup(http_handle);
curl_global_cleanup();
return res;
curl_easy_cleanup(http_handle);
return 0;
}
@@ -1,73 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include "memdebug.h"
/*
* From "KNOWN_BUGS" April 2009:
59. If the CURLOPT_PORT option is used on an FTP URL like
"ftp://example.com/file;type=A" the ";type=A" is stripped off.
*/
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* get a curl handle */
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* enable verbose */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* set port number */
test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
/* specify target */
test_setopt(curl,CURLOPT_URL, URL);
/* Now run off and do what you've been told! */
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
@@ -1,93 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
int res = 0;
CURL *curl = NULL;
int running;
CURLM *m = NULL;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
multi_init(m);
multi_add_handle(m, curl);
fprintf(stderr, "Start at URL 0\n");
for(;;) {
struct timeval interval;
fd_set rd, wr, exc;
int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
multi_perform(m, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
multi_fdset(m, &rd, &wr, &exc, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
}
test_cleanup:
/* undocumented cleanup sequence - type UB */
curl_easy_cleanup(curl);
curl_multi_cleanup(m);
curl_global_cleanup();
return res;
}
@@ -1,67 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode res;
CURL *curl;
double content_length = 3;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl);
if(!res) {
FILE *moo;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
&content_length);
moo = fopen(libtest_arg2, "wb");
if(moo) {
fprintf(moo, "CL: %.0f\n", content_length);
fclose(moo);
}
}
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
@@ -1,69 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/*
* Test a simple OPTIONS request with a custom header
*/
int test(char *URL)
{
CURLcode res;
CURL *curl;
struct curl_slist *custom_headers=NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* Dump data to stdout for protocol verification */
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL);
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
test_setopt(curl, CURLOPT_USERAGENT, "test567");
custom_headers = curl_slist_append(custom_headers, "Test-Number: 567");
test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
res = curl_easy_perform(curl);
test_cleanup:
if(custom_headers)
curl_slist_free_all(custom_headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
@@ -1,175 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <curl/mprintf.h>
#include "memdebug.h"
/* build request url */
static char *suburl(const char *base, int i)
{
return curl_maprintf("%s%.4d", base, i);
}
/*
* Test the Client->Server ANNOUNCE functionality (PUT style)
*/
int test(char *URL)
{
int res;
CURL *curl;
int sdp;
FILE *sdpf = NULL;
struct_stat file_info;
char *stream_uri = NULL;
int request=1;
struct curl_slist *custom_headers=NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
test_setopt(curl, CURLOPT_URL, URL);
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
sdp = open("log/file568.txt", O_RDONLY);
fstat(sdp, &file_info);
close(sdp);
sdpf = fopen("log/file568.txt", "rb");
if(sdpf == NULL) {
fprintf(stderr, "can't open log/file568.txt\n");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
test_setopt(curl, CURLOPT_READDATA, sdpf);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
/* Do the ANNOUNCE */
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
test_setopt(curl, CURLOPT_UPLOAD, 0L);
fclose(sdpf);
sdpf = NULL;
/* Make sure we can do a normal request now */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
/* Now do a POST style one */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
custom_headers = curl_slist_append(custom_headers,
"Content-Type: posty goodness");
if(!custom_headers) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
test_setopt(curl, CURLOPT_POSTFIELDS, "postyfield=postystuff&project=curl\n");
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
test_setopt(curl, CURLOPT_RTSPHEADER, NULL);
curl_slist_free_all(custom_headers);
custom_headers = NULL;
/* Make sure we can do a normal request now */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
res = curl_easy_perform(curl);
test_cleanup:
if(sdpf)
fclose(sdpf);
if(stream_uri)
free(stream_uri);
if(custom_headers)
curl_slist_free_all(custom_headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
@@ -1,129 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include <curl/mprintf.h>
#include "memdebug.h"
/* build request url */
static char *suburl(const char *base, int i)
{
return curl_maprintf("%s%.4d", base, i);
}
/*
* Test Session ID capture
*/
int test(char *URL)
{
int res;
CURL *curl;
char *stream_uri = NULL;
char *rtsp_session_id;
int request=1;
int i;
FILE *idfile = NULL;
idfile = fopen(libtest_arg2, "wb");
if(idfile == NULL) {
fprintf(stderr, "couldn't open the Session ID File\n");
return TEST_ERR_MAJOR_BAD;
}
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
fclose(idfile);
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
fclose(idfile);
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
res = curl_easy_perform(curl);
if(res != (int)CURLE_BAD_FUNCTION_ARGUMENT) {
fprintf(stderr, "This should have failed. "
"Cannot setup without a Transport: header");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
/* Go through the various Session IDs */
for(i = 0; i < 3; i++) {
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Fake/NotReal/JustATest;foo=baz");
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id);
fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id);
rtsp_session_id = NULL;
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN);
res = curl_easy_perform(curl);
/* Clear for the next go-round */
test_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL);
}
test_cleanup:
if(idfile)
fclose(idfile);
if(stream_uri)
free(stream_uri);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
@@ -1,117 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include <curl/mprintf.h>
#include "memdebug.h"
/* build request url */
static char *suburl(const char *base, int i)
{
return curl_maprintf("%s%.4d", base, i);
}
int test(char *URL)
{
int res;
CURL *curl;
int request=1;
char *stream_uri = NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
res = curl_easy_perform(curl);
if(res != (int)CURLE_RTSP_CSEQ_ERROR) {
fprintf(stderr, "Failed to detect CSeq mismatch");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999);
test_setopt(curl, CURLOPT_RTSP_TRANSPORT,
"RAW/RAW/UDP;unicast;client_port=3056-3057");
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
res = curl_easy_perform(curl);
if(res != CURLE_RTSP_SESSION_ERROR) {
fprintf(stderr, "Failed to detect a Session ID mismatch");
}
test_cleanup:
if(stream_uri)
free(stream_uri);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
@@ -1,212 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#include <curl/mprintf.h>
#include "warnless.h"
#include "memdebug.h"
#define RTP_PKT_CHANNEL(p) ((int)((unsigned char)((p)[1])))
#define RTP_PKT_LENGTH(p) ((((int)((unsigned char)((p)[2]))) << 8) | \
((int)((unsigned char)((p)[3]))))
#define RTP_DATA_SIZE 12
static const char *RTP_DATA = "$_1234\n\0asdf";
static int rtp_packet_count = 0;
static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream) {
char *data = (char *)ptr;
int channel = RTP_PKT_CHANNEL(data);
int message_size;
int coded_size = RTP_PKT_LENGTH(data);
size_t failure = (size * nmemb) ? 0 : 1;
int i;
(void)stream;
message_size = curlx_uztosi(size * nmemb) - 4;
printf("RTP: message size %d, channel %d\n", message_size, channel);
if(message_size != coded_size) {
printf("RTP embedded size (%d) does not match the write size (%d).\n",
coded_size, message_size);
return failure;
}
data += 4;
for(i = 0; i < message_size; i+= RTP_DATA_SIZE) {
if(message_size - i > RTP_DATA_SIZE) {
if(memcmp(RTP_DATA, data + i, RTP_DATA_SIZE) != 0) {
printf("RTP PAYLOAD CORRUPTED [%s]\n", data + i);
return failure;
}
} else {
if (memcmp(RTP_DATA, data + i, message_size - i) != 0) {
printf("RTP PAYLOAD END CORRUPTED (%d), [%s]\n",
message_size - i, data + i);
return failure;
}
}
}
rtp_packet_count++;
fprintf(stderr, "packet count is %d\n", rtp_packet_count);
return size * nmemb;
}
/* build request url */
static char *suburl(const char *base, int i)
{
return curl_maprintf("%s%.4d", base, i);
}
int test(char *URL)
{
int res;
CURL *curl;
char *stream_uri = NULL;
int request=1;
FILE *protofile = NULL;
protofile = fopen(libtest_arg2, "wb");
if(protofile == NULL) {
fprintf(stderr, "Couldn't open the protocol dump file\n");
return TEST_ERR_MAJOR_BAD;
}
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
fclose(protofile);
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
fclose(protofile);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
test_setopt(curl, CURLOPT_TIMEOUT, 3);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_WRITEDATA, protofile);
test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "RTP/AVP/TCP;interleaved=0-1");
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
/* This PLAY starts the interleave */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
/* The DESCRIBE request will try to consume data after the Content */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
fprintf(stderr, "PLAY COMPLETE\n");
/* Use Receive to get the rest of the data */
while(!res && rtp_packet_count < 13) {
fprintf(stderr, "LOOPY LOOP!\n");
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_RECEIVE);
res = curl_easy_perform(curl);
}
test_cleanup:
if(stream_uri)
free(stream_uri);
if(protofile)
fclose(protofile);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
@@ -1,181 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <curl/mprintf.h>
#include "memdebug.h"
/* build request url */
static char *suburl(const char *base, int i)
{
return curl_maprintf("%s%.4d", base, i);
}
/*
* Test GET_PARAMETER: PUT, HEARTBEAT, and POST
*/
int test(char *URL)
{
int res;
CURL *curl;
int params;
FILE *paramsf = NULL;
struct_stat file_info;
char *stream_uri = NULL;
int request=1;
struct curl_slist *custom_headers=NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_URL, URL);
/* SETUP */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Planes/Trains/Automobiles");
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
/* PUT style GET_PARAMETERS */
params = open("log/file572.txt", O_RDONLY);
fstat(params, &file_info);
close(params);
paramsf = fopen("log/file572.txt", "rb");
if(paramsf == NULL) {
fprintf(stderr, "can't open log/file572.txt\n");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
test_setopt(curl, CURLOPT_READDATA, paramsf);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
test_setopt(curl, CURLOPT_UPLOAD, 0L);
fclose(paramsf);
paramsf = NULL;
/* Heartbeat GET_PARAMETERS */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
/* POST GET_PARAMETERS */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
test_setopt(curl, CURLOPT_POSTFIELDS, "packets_received\njitter\n");
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
/* Make sure we can do a normal request now */
if((stream_uri = suburl(URL, request++)) == NULL) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
res = curl_easy_perform(curl);
test_cleanup:
if(paramsf)
fclose(paramsf);
if(stream_uri)
free(stream_uri);
if(custom_headers)
curl_slist_free_all(custom_headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
@@ -1,113 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testtrace.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
/*
* Get a single URL without select().
*/
int test(char *URL)
{
CURL *c = NULL;
CURLM *m = NULL;
int res = 0;
int running = 1;
double connect_time = 0.0;
double dbl_epsilon;
dbl_epsilon = 1.0;
do {
dbl_epsilon /= 2.0;
} while ((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0);
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(c);
easy_setopt(c, CURLOPT_HEADER, 1L);
easy_setopt(c, CURLOPT_URL, URL);
libtest_debug_config.nohex = 1;
libtest_debug_config.tracetime = 1;
easy_setopt(c, CURLOPT_DEBUGDATA, &libtest_debug_config);
easy_setopt(c, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
easy_setopt(c, CURLOPT_VERBOSE, 1L);
multi_init(m);
multi_add_handle(m, c);
while (running) {
struct timeval timeout;
fd_set fdread, fdwrite, fdexcep;
int maxfd = -99;
timeout.tv_sec = 0;
timeout.tv_usec = 100000L; /* 100 ms */
multi_perform(m, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
}
curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time);
if (connect_time < dbl_epsilon) {
fprintf(stderr, "connect time is < epsilon\n");
res = TEST_ERR_MAJOR_BAD;
}
test_cleanup:
/* proper cleanup sequence - type PA */
curl_multi_remove_handle(m, c);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
return res;
}
@@ -1,68 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static int new_fnmatch(const char *pattern, const char *string)
{
(void)pattern;
(void)string;
return CURL_FNMATCHFUNC_MATCH;
}
int test(char *URL)
{
int res;
CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
test_setopt(curl, CURLOPT_FNMATCH_FUNCTION, new_fnmatch);
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "curl_easy_perform() failed %d\n", res);
goto test_cleanup;
}
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "curl_easy_perform() failed %d\n", res);
goto test_cleanup;
}
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
@@ -1,114 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
/* 3x download!
* 1. normal
* 2. dup handle
* 3. with multi interface
*/
int test(char *URL)
{
CURL *handle = NULL;
CURL *duphandle = NULL;
CURLM *mhandle = NULL;
int res = 0;
int still_running = 0;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(handle);
easy_setopt(handle, CURLOPT_URL, URL);
easy_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
easy_setopt(handle, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(handle);
if(res)
goto test_cleanup;
res = curl_easy_perform(handle);
if(res)
goto test_cleanup;
duphandle = curl_easy_duphandle(handle);
if(!duphandle)
goto test_cleanup;
curl_easy_cleanup(handle);
handle = duphandle;
multi_init(mhandle);
multi_add_handle(mhandle, handle);
multi_perform(mhandle, &still_running);
abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -99;
timeout.tv_sec = 0;
timeout.tv_usec = 100000L; /* 100 ms */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
multi_perform(mhandle, &still_running);
abort_on_test_timeout();
}
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(mhandle);
curl_easy_cleanup(handle);
curl_global_cleanup();
return res;
}
@@ -1,124 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "memdebug.h"
typedef struct {
int remains;
int print_content;
} chunk_data_t;
static
long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains);
static
long chunk_end(void *ptr);
static
long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains)
{
chunk_data_t *ch_d = ptr;
ch_d->remains = remains;
printf("=============================================================\n");
printf("Remains: %d\n", remains);
printf("Filename: %s\n", finfo->filename);
if(finfo->strings.perm) {
printf("Permissions: %s", finfo->strings.perm);
if(finfo->flags & CURLFINFOFLAG_KNOWN_PERM)
printf(" (parsed => %o)", finfo->perm);
printf("\n");
}
printf("Size: %ldB\n", (long)finfo->size);
if(finfo->strings.user)
printf("User: %s\n", finfo->strings.user);
if(finfo->strings.group)
printf("Group: %s\n", finfo->strings.group);
if(finfo->strings.time)
printf("Time: %s\n", finfo->strings.time);
printf("Filetype: ");
switch(finfo->filetype) {
case CURLFILETYPE_FILE:
printf("regular file\n");
break;
case CURLFILETYPE_DIRECTORY:
printf("directory\n");
break;
case CURLFILETYPE_SYMLINK:
printf("symlink\n");
printf("Target: %s\n", finfo->strings.target);
break;
default:
printf("other type\n");
break;
}
if(finfo->filetype == CURLFILETYPE_FILE) {
ch_d->print_content = 1;
printf("Content:\n-------------------------------------------------------------\n");
}
if(strcmp(finfo->filename, "someothertext.txt") == 0) {
printf("# THIS CONTENT WAS SKIPPED IN CHUNK_BGN CALLBACK #\n");
return CURL_CHUNK_BGN_FUNC_SKIP;
}
return CURL_CHUNK_BGN_FUNC_OK;
}
static
long chunk_end(void *ptr)
{
chunk_data_t *ch_d = ptr;
if(ch_d->print_content) {
ch_d->print_content = 0;
printf("-------------------------------------------------------------\n");
}
if(ch_d->remains == 1)
printf("=============================================================\n");
return CURL_CHUNK_END_FUNC_OK;
}
int test(char *URL)
{
CURL *handle = NULL;
CURLcode res = CURLE_OK;
chunk_data_t chunk_data = {0,0};
curl_global_init(CURL_GLOBAL_ALL);
handle = curl_easy_init();
if(!handle) {
res = CURLE_OUT_OF_MEMORY;
goto test_cleanup;
}
test_setopt(handle, CURLOPT_URL, URL);
test_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
test_setopt(handle, CURLOPT_CHUNK_BGN_FUNCTION, chunk_bgn);
test_setopt(handle, CURLOPT_CHUNK_END_FUNCTION, chunk_end);
test_setopt(handle, CURLOPT_CHUNK_DATA, &chunk_data);
res = curl_easy_perform(handle);
test_cleanup:
if(handle)
curl_easy_cleanup(handle);
curl_global_cleanup();
return res;
}
@@ -1,102 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/* The size of data should be kept below MAX_INITIAL_POST_SIZE! */
static char data[]="this is a short string.\n";
static size_t data_size = sizeof(data) / sizeof(char);
static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
FILE *moo = fopen(libtest_arg2, "wb");
(void)clientp; /* UNUSED */
(void)dltotal; /* UNUSED */
(void)dlnow; /* UNUSED */
if(moo) {
if ((size_t)ultotal == data_size && (size_t)ulnow == data_size)
fprintf(moo, "PASSED, UL data matched data size\n");
else
fprintf(moo, "Progress callback called with UL %f out of %f\n", ulnow, ultotal);
fclose(moo);
}
return 0;
}
int test(char *URL)
{
CURL *curl;
CURLcode res=CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
/* Set the expected POST size */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, data_size);
test_setopt(curl, CURLOPT_POSTFIELDS, data);
/* we want to use our own progress function */
test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
/* pointer to pass to our read function */
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
@@ -1,161 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static const char * const post[]={
"one",
"two",
"three",
"and a final longer crap: four",
NULL
};
struct WriteThis {
int counter;
};
static int progress_callback(void *clientp, double dltotal, double dlnow,
double ultotal, double ulnow)
{
FILE *moo;
static int prev_ultotal = -1;
static int prev_ulnow = -1;
(void)clientp; /* UNUSED */
(void)dltotal; /* UNUSED */
(void)dlnow; /* UNUSED */
/* to avoid depending on timing, which will cause this progress function to
get called a different number of times depending on circumstances, we
only log these lines if the numbers are different from the previous
invoke */
if((prev_ultotal != (int)ultotal) ||
(prev_ulnow != (int)ulnow)) {
moo = fopen(libtest_arg2, "ab");
if(moo) {
fprintf(moo, "Progress callback called with UL %d out of %d\n",
(int)ulnow, (int)ultotal);
fclose(moo);
}
prev_ulnow = (int) ulnow;
prev_ultotal = (int) ultotal;
}
return 0;
}
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
{
struct WriteThis *pooh = (struct WriteThis *)userp;
const char *data;
if(size*nmemb < 1)
return 0;
data = post[pooh->counter];
if(data) {
size_t len = strlen(data);
memcpy(ptr, data, len);
pooh->counter++; /* advance pointer */
return len;
}
return 0; /* no more data left to deliver */
}
int test(char *URL)
{
CURL *curl;
CURLcode res=CURLE_OK;
struct curl_slist *slist = NULL;
struct WriteThis pooh;
pooh.counter = 0;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
slist = curl_slist_append(slist, "Transfer-Encoding: chunked");
if (slist == NULL) {
fprintf(stderr, "curl_slist_append() failed\n");
curl_easy_cleanup(curl);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
/* we want to use our own read function */
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_INFILE, &pooh);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
/* enforce chunked transfer by setting the header */
test_setopt(curl, CURLOPT_HTTPHEADER, slist);
test_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST);
test_setopt(curl, CURLOPT_USERPWD, "foo:bar");
/* we want to use our own progress function */
test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* clean up the headers list */
if(slist)
curl_slist_free_all(slist);
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
@@ -1,366 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
struct Sockets
{
curl_socket_t *sockets;
int count; /* number of sockets actually stored in array */
int max_count; /* max number of sockets that fit in allocated array */
};
struct ReadWriteSockets
{
struct Sockets read, write;
};
/**
* Remove a file descriptor from a sockets array.
*/
static void removeFd(struct Sockets* sockets, curl_socket_t fd, int mention)
{
int i;
if(mention)
fprintf(stderr, "Remove socket fd %d\n", (int) fd);
for (i = 0; i < sockets->count; ++i) {
if (sockets->sockets[i] == fd) {
if (i < sockets->count - 1)
memmove(&sockets->sockets[i], &sockets->sockets[i + 1],
sizeof(curl_socket_t) * (sockets->count - (i + 1)));
--sockets->count;
}
}
}
/**
* Add a file descriptor to a sockets array.
*/
static void addFd(struct Sockets* sockets, curl_socket_t fd, const char *what)
{
/**
* To ensure we only have each file descriptor once, we remove it then add
* it again.
*/
fprintf(stderr, "Add socket fd %d for %s\n", (int) fd, what);
removeFd(sockets, fd, 0);
/*
* Allocate array storage when required.
*/
if(!sockets->sockets) {
sockets->sockets = malloc(sizeof(curl_socket_t) * 20U);
if(!sockets->sockets)
return;
sockets->max_count = 20;
}
else if(sockets->count + 1 > sockets->max_count) {
curl_socket_t *oldptr = sockets->sockets;
sockets->sockets = realloc(oldptr, sizeof(curl_socket_t) *
(sockets->max_count + 20));
if(!sockets->sockets) {
/* cleanup in test_cleanup */
sockets->sockets = oldptr;
return;
}
sockets->max_count += 20;
}
/*
* Add file descriptor to array.
*/
sockets->sockets[sockets->count] = fd;
++sockets->count;
}
/**
* Callback invoked by curl to poll reading / writing of a socket.
*/
static int curlSocketCallback(CURL *easy, curl_socket_t s, int action,
void *userp, void *socketp)
{
struct ReadWriteSockets* sockets = userp;
(void)easy; /* unused */
(void)socketp; /* unused */
if (action == CURL_POLL_IN || action == CURL_POLL_INOUT)
addFd(&sockets->read, s, "read");
if (action == CURL_POLL_OUT || action == CURL_POLL_INOUT)
addFd(&sockets->write, s, "write");
if(action == CURL_POLL_REMOVE) {
removeFd(&sockets->read, s, 1);
removeFd(&sockets->write, s, 0);
}
return 0;
}
/**
* Callback invoked by curl to set a timeout.
*/
static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp)
{
struct timeval* timeout = userp;
(void)multi; /* unused */
if (timeout_ms != -1) {
*timeout = tutil_tvnow();
timeout->tv_usec += timeout_ms * 1000;
}
else {
timeout->tv_sec = -1;
}
return 0;
}
/**
* Check for curl completion.
*/
static int checkForCompletion(CURLM* curl, int* success)
{
int numMessages;
CURLMsg* message;
int result = 0;
*success = 0;
while ((message = curl_multi_info_read(curl, &numMessages)) != NULL) {
if (message->msg == CURLMSG_DONE) {
result = 1;
if (message->data.result == CURLE_OK)
*success = 1;
else
*success = 0;
}
else {
fprintf(stderr, "Got an unexpected message from curl: %i\n",
(int)message->msg);
result = 1;
*success = 0;
}
}
return result;
}
static int getMicroSecondTimeout(struct timeval* timeout)
{
struct timeval now;
ssize_t result;
now = tutil_tvnow();
result = (timeout->tv_sec - now.tv_sec) * 1000000 +
timeout->tv_usec - now.tv_usec;
if (result < 0)
result = 0;
return curlx_sztosi(result);
}
/**
* Update a fd_set with all of the sockets in use.
*/
static void updateFdSet(struct Sockets* sockets, fd_set* fdset,
curl_socket_t *maxFd)
{
int i;
for (i = 0; i < sockets->count; ++i) {
FD_SET(sockets->sockets[i], fdset);
if (*maxFd < sockets->sockets[i] + 1) {
*maxFd = sockets->sockets[i] + 1;
}
}
}
static void notifyCurl(CURLM *curl, curl_socket_t s, int evBitmask,
const char *info)
{
int numhandles = 0;
CURLMcode result = curl_multi_socket_action(curl, s, evBitmask, &numhandles);
if (result != CURLM_OK) {
fprintf(stderr, "Curl error on %s: %i (%s)\n",
info, result, curl_multi_strerror(result));
}
}
/**
* Invoke curl when a file descriptor is set.
*/
static void checkFdSet(CURLM *curl, struct Sockets *sockets, fd_set *fdset,
int evBitmask, const char *name)
{
int i;
for (i = 0; i < sockets->count; ++i) {
if (FD_ISSET(sockets->sockets[i], fdset)) {
notifyCurl(curl, sockets->sockets[i], evBitmask, name);
}
}
}
int test(char *URL)
{
int res = 0;
CURL *curl = NULL;
FILE *hd_src = NULL;
int hd ;
int error;
struct_stat file_info;
CURLM *m = NULL;
struct ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}};
struct timeval timeout = {-1, 0};
int success = 0;
start_test_timing();
if (!libtest_arg3) {
fprintf(stderr, "Usage: lib582 [url] [filename] [username]\n");
return TEST_ERR_USAGE;
}
hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) {
error = ERRNO;
fprintf(stderr, "fopen() failed with error: %d (%s)\n",
error, strerror(error));
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2);
return TEST_ERR_FOPEN;
}
/* get the file size of the local file */
hd = fstat(fileno(hd_src), &file_info);
if(hd == -1) {
/* can't open file, bail out */
error = ERRNO;
fprintf(stderr, "fstat() failed with error: %d (%s)\n",
error, strerror(error));
fprintf(stderr, "ERROR: cannot open file (%s)\n", libtest_arg2);
fclose(hd_src);
return TEST_ERR_FSTAT;
}
fprintf(stderr, "Set to upload %d bytes\n", (int)file_info.st_size);
res_global_init(CURL_GLOBAL_ALL);
if(res) {
fclose(hd_src);
return res;
}
easy_init(curl);
/* enable uploading */
easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */
easy_setopt(curl,CURLOPT_URL, URL);
/* go verbose */
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* now specify which file to upload */
easy_setopt(curl, CURLOPT_READDATA, hd_src);
easy_setopt(curl, CURLOPT_USERPWD, libtest_arg3);
easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
multi_init(m);
multi_setopt(m, CURLMOPT_SOCKETFUNCTION, curlSocketCallback);
multi_setopt(m, CURLMOPT_SOCKETDATA, &sockets);
multi_setopt(m, CURLMOPT_TIMERFUNCTION, curlTimerCallback);
multi_setopt(m, CURLMOPT_TIMERDATA, &timeout);
multi_add_handle(m, curl);
while (!checkForCompletion(m, &success))
{
fd_set readSet, writeSet;
curl_socket_t maxFd = 0;
struct timeval tv = {10, 0};
FD_ZERO(&readSet);
FD_ZERO(&writeSet);
updateFdSet(&sockets.read, &readSet, &maxFd);
updateFdSet(&sockets.write, &writeSet, &maxFd);
if (timeout.tv_sec != -1)
{
int usTimeout = getMicroSecondTimeout(&timeout);
tv.tv_sec = usTimeout / 1000000;
tv.tv_usec = usTimeout % 1000000;
}
else if (maxFd <= 0)
{
tv.tv_sec = 0;
tv.tv_usec = 100000;
}
select_test(maxFd, &readSet, &writeSet, NULL, &tv);
/* Check the sockets for reading / writing */
checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read");
checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write");
if (timeout.tv_sec != -1 && getMicroSecondTimeout(&timeout) == 0)
{
/* Curl's timer has elapsed. */
notifyCurl(m, CURL_SOCKET_TIMEOUT, 0, "timeout");
}
abort_on_test_timeout();
}
if (!success)
{
fprintf(stderr, "Error uploading file.\n");
res = TEST_ERR_MAJOR_BAD;
}
test_cleanup:
/* proper cleanup sequence - type PB */
curl_multi_remove_handle(m, curl);
curl_easy_cleanup(curl);
curl_multi_cleanup(m);
curl_global_cleanup();
/* close the local file */
fclose(hd_src);
/* free local memory */
if(sockets.read.sockets)
free(sockets.read.sockets);
if(sockets.write.sockets)
free(sockets.write.sockets);
return res;
}
@@ -1,84 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* This test case is based on the sample code provided by Saqib Ali
* http://curl.haxx.se/mail/lib-2011-03/0066.html
*/
#include "test.h"
#include <sys/stat.h>
#include "memdebug.h"
int test(char *URL)
{
int stillRunning;
CURLM* multiHandle = NULL;
CURL* curl = NULL;
int res = 0;
global_init(CURL_GLOBAL_ALL);
multi_init(multiHandle);
easy_init(curl);
easy_setopt(curl, CURLOPT_USERPWD, libtest_arg2);
easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
easy_setopt(curl, CURLOPT_UPLOAD, 1L);
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_INFILESIZE, (long)5);
multi_add_handle(multiHandle, curl);
/* this tests if removing an easy handle immediately after multi
perform has been called succeeds or not. */
fprintf(stderr, "curl_multi_perform()...\n");
multi_perform(multiHandle, &stillRunning);
fprintf(stderr, "curl_multi_perform() succeeded\n");
fprintf(stderr, "curl_multi_remove_handle()...\n");
res = (int) curl_multi_remove_handle(multiHandle, curl);
if(res)
fprintf(stderr, "curl_multi_remove_handle() failed, "
"with code %d\n", res);
else
fprintf(stderr, "curl_multi_remove_handle() succeeded\n");
test_cleanup:
/* undocumented cleanup sequence - type UB */
curl_easy_cleanup(curl);
curl_multi_cleanup(multiHandle);
curl_global_cleanup();
return res;
}
@@ -1,246 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include <curl/mprintf.h>
#include "memdebug.h"
#define THREADS 2
/* struct containing data of a thread */
struct Tdata {
CURLSH *share;
char *url;
};
struct userdata {
char *text;
int counter;
};
/* lock callback */
static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess,
void *useptr )
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
(void)handle;
(void)laccess;
switch ( data ) {
case CURL_LOCK_DATA_SHARE:
what = "share";
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
break;
case CURL_LOCK_DATA_SSL_SESSION:
what = "ssl_session";
break;
default:
fprintf(stderr, "lock: no such data: %d\n", (int)data);
return;
}
printf("lock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
}
/* unlock callback */
static void my_unlock(CURL *handle, curl_lock_data data, void *useptr )
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
(void)handle;
switch ( data ) {
case CURL_LOCK_DATA_SHARE:
what = "share";
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
break;
case CURL_LOCK_DATA_SSL_SESSION:
what = "ssl_session";
break;
default:
fprintf(stderr, "unlock: no such data: %d\n", (int)data);
return;
}
printf("unlock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
}
/* the dummy thread function */
static void *fire(void *ptr)
{
CURLcode code;
struct Tdata *tdata = (struct Tdata*)ptr;
CURL *curl;
int i=0;
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
return NULL;
}
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_URL, tdata->url);
printf( "CURLOPT_SHARE\n" );
curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share);
printf( "PERFORM\n" );
code = curl_easy_perform(curl);
if( code != CURLE_OK ) {
fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n",
tdata->url, i, (int)code);
}
printf( "CLEANUP\n" );
curl_easy_cleanup(curl);
return NULL;
}
/* test function */
int test(char *URL)
{
int res;
CURLSHcode scode = CURLSHE_OK;
char *url;
struct Tdata tdata;
CURL *curl;
CURLSH *share;
int i;
struct userdata user;
user.text = (char *)"Pigs in space";
user.counter = 0;
printf( "GLOBAL_INIT\n" );
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* prepare share */
printf( "SHARE_INIT\n" );
if ((share = curl_share_init()) == NULL) {
fprintf(stderr, "curl_share_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
if ( CURLSHE_OK == scode ) {
printf( "CURLSHOPT_LOCKFUNC\n" );
scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, my_lock);
}
if ( CURLSHE_OK == scode ) {
printf( "CURLSHOPT_UNLOCKFUNC\n" );
scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, my_unlock);
}
if ( CURLSHE_OK == scode ) {
printf( "CURLSHOPT_USERDATA\n" );
scode = curl_share_setopt( share, CURLSHOPT_USERDATA, &user);
}
if ( CURLSHE_OK == scode ) {
printf( "CURL_LOCK_DATA_SSL_SESSION\n" );
scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
}
if ( CURLSHE_OK != scode ) {
fprintf(stderr, "curl_share_setopt() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
res = 0;
/* start treads */
for (i=1; i<=THREADS; i++ ) {
/* set thread data */
tdata.url = URL;
tdata.share = share;
/* simulate thread, direct call of "thread" function */
printf( "*** run %d\n",i );
fire( &tdata );
}
/* fetch a another one */
printf( "*** run %d\n", i );
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
url = URL;
test_setopt( curl, CURLOPT_URL, url );
printf( "CURLOPT_SHARE\n" );
test_setopt( curl, CURLOPT_SHARE, share );
printf( "PERFORM\n" );
curl_easy_perform( curl );
/* try to free share, expect to fail because share is in use*/
printf( "try SHARE_CLEANUP...\n" );
scode = curl_share_cleanup( share );
if ( scode==CURLSHE_OK )
{
fprintf(stderr, "curl_share_cleanup succeed but error expected\n");
share = NULL;
} else {
printf( "SHARE_CLEANUP failed, correct\n" );
}
test_cleanup:
/* clean up last handle */
printf( "CLEANUP\n" );
curl_easy_cleanup( curl );
/* free share */
printf( "SHARE_CLEANUP\n" );
scode = curl_share_cleanup( share );
if ( scode!=CURLSHE_OK )
fprintf(stderr, "curl_share_cleanup failed, code errno %d\n",
(int)scode);
printf( "GLOBAL_CLEANUP\n" );
curl_global_cleanup();
return res;
}
@@ -1,71 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
/*
Based on a bug report recipe by Rene Bernhardt in
http://curl.haxx.se/mail/lib-2011-10/0323.html
It is reproducible by the following steps:
- Use a proxy that offers NTLM and Negotiate ( CURLOPT_PROXY and
CURLOPT_PROXYPORT )
- Tell libcurl NOT to use Negotiate CURL_EASY_SETOPT(CURLOPT_PROXYAUTH,
CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_NTLM )
- Start the request
*/
#include "memdebug.h"
int test(char *URL)
{
CURLcode res;
CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_PROXYAUTH,
(long) (CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_NTLM));
test_setopt(curl, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
test_setopt(curl, CURLOPT_PROXYUSERPWD, "me:password");
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
@@ -1,149 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
/* lib591 is used for test cases 591, 592, 593 and 594 */
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
CURL *easy = NULL;
CURLM *multi = NULL;
int res = 0;
int running;
int msgs_left;
CURLMsg *msg;
FILE *upload = NULL;
int error;
start_test_timing();
upload = fopen(libtest_arg3, "rb");
if(!upload) {
error = ERRNO;
fprintf(stderr, "fopen() failed with error: %d (%s)\n",
error, strerror(error));
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg3);
return TEST_ERR_FOPEN;
}
res_global_init(CURL_GLOBAL_ALL);
if(res) {
fclose(upload);
return res;
}
easy_init(easy);
/* go verbose */
easy_setopt(easy, CURLOPT_VERBOSE, 1L);
/* specify target */
easy_setopt(easy, CURLOPT_URL, URL);
/* enable uploading */
easy_setopt(easy, CURLOPT_UPLOAD, 1L);
/* data pointer for the file read function */
easy_setopt(easy, CURLOPT_READDATA, upload);
/* use active mode FTP */
easy_setopt(easy, CURLOPT_FTPPORT, "-");
/* server connection timeout */
easy_setopt(easy, CURLOPT_ACCEPTTIMEOUT_MS,
strtol(libtest_arg2, NULL, 10)*1000);
multi_init(multi);
multi_add_handle(multi, easy);
for(;;) {
struct timeval interval;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
long timeout = -99;
int maxfd = -99;
multi_perform(multi, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
multi_timeout(multi, &timeout);
/* At this point, timeout is guaranteed to be greater or equal than -1. */
if(timeout != -1L) {
int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
interval.tv_sec = itimeout/1000;
interval.tv_usec = (itimeout%1000)*1000;
}
else {
interval.tv_sec = 0;
interval.tv_usec = 100000L; /* 100 ms */
}
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval);
abort_on_test_timeout();
}
msg = curl_multi_info_read(multi, &msgs_left);
if(msg)
res = msg->data.result;
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(easy);
curl_global_cleanup();
/* close the local file */
fclose(upload);
return res;
}
@@ -1,150 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 5 * 1000
/*
* Test case for below scenario:
* - Connect to an FTP server using CONNECT_ONLY option
* - transfer some files with re-using the connection (omitted in test case)
* - Disconnect from FTP server with sending QUIT command
*
* The test case originated for verifying CONNECT_ONLY option shall not
* block after protocol connect is done, but it returns the message
* with function curl_multi_info_read().
*/
enum {
CONNECT_ONLY_PHASE = 0,
QUIT_PHASE,
LAST_PHASE
};
int test(char *URL)
{
CURL *easy = NULL;
CURLM *multi = NULL;
int res = 0;
int running;
int msgs_left;
int phase;
CURLMsg *msg;
start_test_timing();
res_global_init(CURL_GLOBAL_ALL);
if(res) {
return res;
}
easy_init(easy);
multi_init(multi);
for (phase = CONNECT_ONLY_PHASE; phase < LAST_PHASE; ++phase) {
/* go verbose */
easy_setopt(easy, CURLOPT_VERBOSE, 1L);
/* specify target */
easy_setopt(easy, CURLOPT_URL, URL);
/* enable 'CONNECT_ONLY' option when in connect phase */
if (phase == CONNECT_ONLY_PHASE)
easy_setopt(easy, CURLOPT_CONNECT_ONLY, 1L);
/* enable 'NOBODY' option to send 'QUIT' command in quit phase */
if (phase == QUIT_PHASE) {
easy_setopt(easy, CURLOPT_CONNECT_ONLY, 0L);
easy_setopt(easy, CURLOPT_NOBODY, 1L);
easy_setopt(easy, CURLOPT_FORBID_REUSE, 1L);
}
multi_add_handle(multi, easy);
for(;;) {
struct timeval interval;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
long timeout = -99;
int maxfd = -99;
multi_perform(multi, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
multi_timeout(multi, &timeout);
/* At this point, timeout is guaranteed to be greater or equal than -1. */
if(timeout != -1L) {
int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
interval.tv_sec = itimeout/1000;
interval.tv_usec = (itimeout%1000)*1000;
}
else {
interval.tv_sec = TEST_HANG_TIMEOUT/1000+1;
interval.tv_usec = 0;
}
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval);
abort_on_test_timeout();
}
msg = curl_multi_info_read(multi, &msgs_left);
if(msg)
res = msg->data.result;
multi_remove_handle(multi, easy);
}
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(easy);
curl_global_cleanup();
return res;
}
@@ -1,72 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode res;
CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_REFERER, "http://example.com/the-moo");
test_setopt(curl, CURLOPT_USERAGENT, "the-moo agent next generation");
test_setopt(curl, CURLOPT_COOKIE, "name=moo");
test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "retrieve 1 failed\n");
goto test_cleanup;
}
curl_easy_reset(curl);
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
if(res)
fprintf(stderr, "retrieve 2 failed\n");
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
@@ -1,84 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static int progress_callback(void *clientp, double dltotal,
double dlnow, double ultotal, double ulnow)
{
(void)clientp;
(void)ulnow;
(void)ultotal;
if((dltotal > 0.0) && (dlnow > dltotal)) {
/* this should not happen with test case 599 */
printf("%.0f > %.0f !!\n", dltotal, dlnow);
return -1;
}
return 0;
}
int test(char *URL)
{
CURL *curl;
CURLcode res=CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* we want to use our own progress function */
test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* follow redirects */
test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
@@ -1,153 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* argv1 = URL
* argv2 = main auth type
* argv3 = second auth type
*/
#include "test.h"
#include "strequal.h"
#include "memdebug.h"
static CURLcode send_request(CURL *curl, const char *url, int seq,
long auth_scheme, const char *userpwd)
{
CURLcode res;
char* full_url = malloc(strlen(url) + 4 + 1);
if (!full_url) {
fprintf(stderr, "Not enough memory for full url\n");
res = CURLE_OUT_OF_MEMORY;
goto test_cleanup;
}
sprintf(full_url, "%s%04d", url, seq);
fprintf(stderr, "Sending new request %d to %s with credential %s "
"(auth %ld)\n", seq, full_url, userpwd, auth_scheme);
test_setopt(curl, CURLOPT_URL, full_url);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_HTTPGET, 1L);
test_setopt(curl, CURLOPT_USERPWD, userpwd);
test_setopt(curl, CURLOPT_HTTPAUTH, auth_scheme);
res = curl_easy_perform(curl);
test_cleanup:
free(full_url);
return res;
}
static CURLcode send_wrong_password(CURL *curl, const char *url, int seq,
long auth_scheme)
{
return send_request(curl, url, seq, auth_scheme, "testuser:wrongpass");
}
static CURLcode send_right_password(CURL *curl, const char *url, int seq,
long auth_scheme)
{
return send_request(curl, url, seq, auth_scheme, "testuser:testpass");
}
static long parse_auth_name(const char *arg)
{
if (!arg)
return CURLAUTH_NONE;
if (strequal(arg, "basic"))
return CURLAUTH_BASIC;
if (strequal(arg, "digest"))
return CURLAUTH_DIGEST;
if (strequal(arg, "ntlm"))
return CURLAUTH_NTLM;
return CURLAUTH_NONE;
}
int test(char *url)
{
CURLcode res;
CURL *curl = NULL;
long main_auth_scheme = parse_auth_name(libtest_arg2);
long fallback_auth_scheme = parse_auth_name(libtest_arg3);
if (main_auth_scheme == CURLAUTH_NONE ||
fallback_auth_scheme == CURLAUTH_NONE) {
fprintf(stderr, "auth schemes not found on commandline\n");
return TEST_ERR_MAJOR_BAD;
}
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* Send wrong password, then right password */
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
res = send_wrong_password(curl, url, 100, main_auth_scheme);
if (res != CURLE_OK)
goto test_cleanup;
curl_easy_reset(curl);
res = send_right_password(curl, url, 200, fallback_auth_scheme);
if (res != CURLE_OK)
goto test_cleanup;
curl_easy_reset(curl);
curl_easy_cleanup(curl);
/* Send wrong password twice, then right password */
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
res = send_wrong_password(curl, url, 300, main_auth_scheme);
if (res != CURLE_OK)
goto test_cleanup;
curl_easy_reset(curl);
res = send_wrong_password(curl, url, 400, fallback_auth_scheme);
if (res != CURLE_OK)
goto test_cleanup;
curl_easy_reset(curl);
res = send_right_password(curl, url, 500, fallback_auth_scheme);
if (res != CURLE_OK)
goto test_cleanup;
curl_easy_reset(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
@@ -1,275 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include <assert.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 5 * 1000
#define MAX_EASY_HANDLES 3
static CURL *easy[MAX_EASY_HANDLES];
static curl_socket_t sockets[MAX_EASY_HANDLES];
static int res = 0;
static size_t callback(char* ptr, size_t size, size_t nmemb, void* data)
{
ssize_t idx = ((CURL **) data) - easy;
curl_socket_t sock;
long longdata;
CURLcode code;
const size_t failure = (size * nmemb) ? 0 : 1;
char *output = malloc(size * nmemb + 1);
if (!output) {
fprintf(stderr, "output, malloc() failed\n");
res = TEST_ERR_MAJOR_BAD;
return failure;
}
memcpy(output, ptr, size * nmemb);
output[size * nmemb] = '\0';
fprintf(stdout, "%s", output);
free(output);
/* Get socket being used for this easy handle, otherwise CURL_SOCKET_BAD */
code = curl_easy_getinfo(easy[idx], CURLINFO_LASTSOCKET, &longdata);
if (CURLE_OK != code) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed, "
"with code %d (%s)\n",
__FILE__, __LINE__, (int)code, curl_easy_strerror(code));
res = TEST_ERR_MAJOR_BAD;
return failure;
}
if (longdata == -1L)
sock = CURL_SOCKET_BAD;
else
sock = (curl_socket_t)longdata;
if (sock != CURL_SOCKET_BAD) {
/* Track relationship between this easy handle and the socket. */
if (sockets[idx] == CURL_SOCKET_BAD) {
/* An easy handle without previous socket, record the socket. */
sockets[idx] = sock;
}
else if (sock != sockets[idx]) {
/* An easy handle with a socket different to previously
tracked one, log and fail right away. Known bug #37. */
fprintf(stderr, "Handle %d started on socket %d and moved to %d\n",
curlx_sztosi(idx), (int)sockets[idx], (int)sock);
res = TEST_ERR_MAJOR_BAD;
return failure;
}
}
return size * nmemb;
}
enum HandleState {
ReadyForNewHandle,
NeedSocketForNewHandle,
NoMoreHandles
};
int test(char *url)
{
CURLM *multi = NULL;
int running;
int i, j;
int num_handles = 0;
enum HandleState state = ReadyForNewHandle;
char* full_url = malloc(strlen(url) + 4 + 1);
start_test_timing();
if (!full_url) {
fprintf(stderr, "Not enough memory for full url\n");
return TEST_ERR_MAJOR_BAD;
}
for (i = 0; i < MAX_EASY_HANDLES; ++i) {
easy[i] = NULL;
sockets[i] = CURL_SOCKET_BAD;
}
res_global_init(CURL_GLOBAL_ALL);
if(res) {
free(full_url);
return res;
}
multi_init(multi);
for(;;) {
struct timeval interval;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
long timeout = -99;
int maxfd = -99;
bool found_new_socket = FALSE;
/* Start a new handle if we aren't at the max */
if (state == ReadyForNewHandle) {
easy_init(easy[num_handles]);
if (num_handles % 3 == 2) {
sprintf(full_url, "%s0200", url);
easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
} else {
sprintf(full_url, "%s0100", url);
easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
}
easy_setopt(easy[num_handles], CURLOPT_FRESH_CONNECT, 1L);
easy_setopt(easy[num_handles], CURLOPT_URL, full_url);
easy_setopt(easy[num_handles], CURLOPT_VERBOSE, 1L);
easy_setopt(easy[num_handles], CURLOPT_HTTPGET, 1L);
easy_setopt(easy[num_handles], CURLOPT_USERPWD, "testuser:testpass");
easy_setopt(easy[num_handles], CURLOPT_WRITEFUNCTION, callback);
easy_setopt(easy[num_handles], CURLOPT_WRITEDATA, easy + num_handles);
easy_setopt(easy[num_handles], CURLOPT_HEADER, 1L);
multi_add_handle(multi, easy[num_handles]);
num_handles += 1;
state = NeedSocketForNewHandle;
}
multi_perform(multi, &running);
abort_on_test_timeout();
if(!running && state == NoMoreHandles)
break; /* done */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
/* Any socket which is new in fdread is associated with the new handle */
for (i = 0; i <= maxfd; ++i) {
bool socket_exists = FALSE;
curl_socket_t curfd = (curl_socket_t)i;
if (!FD_ISSET(curfd, &fdread)) {
continue;
}
/* Check if this socket was already detected for an earlier handle (or
for this handle, num_handles-1, in the callback */
for (j = 0; j < num_handles; ++j) {
if (sockets[j] == curfd) {
socket_exists = TRUE;
break;
}
}
if (socket_exists) {
continue;
}
if (found_new_socket || state != NeedSocketForNewHandle) {
fprintf(stderr, "Unexpected new socket\n");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
/* Now we know the socket is for the most recent handle, num_handles-1 */
if (sockets[num_handles-1] != CURL_SOCKET_BAD) {
/* A socket for this handle was already detected in the callback; if it
matched socket_exists should be true and we would never get here */
assert(curfd != sockets[num_handles-1]);
fprintf(stderr, "Handle %d wrote to socket %d then detected on %d\n",
num_handles-1, (int)sockets[num_handles-1], (int)curfd);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
else {
sockets[num_handles-1] = curfd;
found_new_socket = TRUE;
/* continue to make sure there's only one new handle */
}
}
if (state == NeedSocketForNewHandle) {
if(maxfd != -1 && !found_new_socket) {
fprintf(stderr, "Warning: socket did not open immediately for new "
"handle (trying again)\n");
continue;
}
state = num_handles < MAX_EASY_HANDLES ? ReadyForNewHandle
: NoMoreHandles;
}
multi_timeout(multi, &timeout);
/* At this point, timeout is guaranteed to be greater or equal than -1. */
fprintf(stderr, "%s:%d num_handles %d timeout %ld\n",
__FILE__, __LINE__, num_handles, timeout);
if(timeout != -1L) {
int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
interval.tv_sec = itimeout/1000;
interval.tv_usec = (itimeout%1000)*1000;
}
else {
interval.tv_sec = TEST_HANG_TIMEOUT/1000+1;
interval.tv_usec = 0;
/* if there's no timeout and we get here on the last handle, we may
already have read the last part of the stream so waiting makes no
sense */
if(!running && num_handles == MAX_EASY_HANDLES) {
break;
}
}
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval);
abort_on_test_timeout();
}
test_cleanup:
/* proper cleanup sequence - type PB */
for(i = 0; i < MAX_EASY_HANDLES; i++) {
curl_multi_remove_handle(multi, easy[i]);
curl_easy_cleanup(easy[i]);
}
curl_multi_cleanup(multi);
curl_global_cleanup();
free(full_url);
return res;
}
@@ -1,15 +0,0 @@
#!/usr/bin/env perl
# Check that given arguments do not exist on filesystem.
my $code = 0;
if ($#ARGV < 0) {
print "Usage: $0 file1 [fileN]\n";
exit 2;
}
while (@ARGV) {
my $fname = shift @ARGV;
if (-e $fname) {
print "Found '$fname' when not supposed to exist.\n";
$code = 1;
}
}
exit $code;
@@ -1,41 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curl_setup.h"
#include "sethostname.h"
/*
* we force our own host name, in order to make some tests machine independent
*/
int gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen)
{
const char *force_hostname = getenv("CURL_GETHOSTNAME");
if(force_hostname) {
strncpy(name, force_hostname, namelen);
name[namelen-1] = '\0';
return 0;
}
/* LD_PRELOAD used, but no hostname set, we'll just return a failure */
return -1;
}
@@ -1,45 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#if (defined(WIN32) || defined(__SYMBIAN32__)) && !defined(CURL_STATICLIB)
# if defined(BUILDING_LIBCURL)
# define LIBHOSTNAME_EXTERN __declspec(dllexport)
# else
# define LIBHOSTNAME_EXTERN __declspec(dllimport)
# endif
#else
# ifdef CURL_HIDDEN_SYMBOLS
# define LIBHOSTNAME_EXTERN CURL_EXTERN_SYMBOL
# else
# define LIBHOSTNAME_EXTERN
# endif
#endif
#ifdef USE_WINSOCK
# define FUNCALLCONV __stdcall
#else
# define FUNCALLCONV
#endif
LIBHOSTNAME_EXTERN int FUNCALLCONV
gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen);
+22 -397
View File
@@ -1,50 +1,40 @@
/***************************************************************************
/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
* $Id: test.h,v 1.21 2008-09-18 16:21:09 yangtse Exp $
*/
/* Now include the curl_setup.h file from libcurl's private libdir (the source
version, but that might include "curl_config.h" from the build dir so we
need both of them in the include path), so that we get good in-depth
knowledge about the system we're building this on */
/* Now include the setup.h file from libcurl's private libdir (the source
version, but that might include "config.h" from the build dir so we need
both of them in the include path), so that we get good in-depth knowledge
about the system we're building this on */
#define CURL_NO_OLDIES
#include "curl_setup.h"
#include "setup.h"
#include <curl/curl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_SELECT_H
/* since so many tests use select(), we can just as well include it here */
#include <sys/select.h>
#endif
#ifdef TPF
# include "select.h"
#ifdef HAVE_UNISTD_H
/* at least somewhat oldish FreeBSD systems need this for select() */
#include <unistd.h>
#endif
#define test_setopt(A,B,C) \
if((res = curl_easy_setopt((A),(B),(C))) != CURLE_OK) goto test_cleanup
#define test_multi_setopt(A,B,C) \
if((res = curl_multi_setopt((A),(B),(C))) != CURLE_OK) goto test_cleanup
#define TEST_ERR_MAJOR_BAD 100
#define TEST_ERR_RUNS_FOREVER 99
extern char *libtest_arg2; /* set by first.c to the argv[2] or NULL */
extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */
@@ -53,374 +43,9 @@ extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */
extern int test_argc;
extern char **test_argv;
extern struct timeval tv_test_start; /* for test timing */
extern int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
struct timeval *tv);
extern int select_test(int num_fds, fd_set *rd, fd_set *wr, fd_set *exc,
struct timeval *tv);
extern int test(char *URL); /* the actual test function provided by each
individual libXXX.c file */
#ifdef UNITTESTS
extern int unitfail;
#endif
/*
** TEST_ERR_* values must be greater than CURL_LAST CURLcode in order
** to avoid confusion with any CURLcode or CURLMcode. These TEST_ERR_*
** codes are returned to signal test specific situations and should
** not get mixed with CURLcode or CURLMcode values.
**
** For portability reasons TEST_ERR_* values should be less than 127.
*/
#define TEST_ERR_MAJOR_BAD 126
#define TEST_ERR_RUNS_FOREVER 125
#define TEST_ERR_EASY_INIT 124
#define TEST_ERR_MULTI_INIT 123
#define TEST_ERR_NUM_HANDLES 122
#define TEST_ERR_SELECT 121
#define TEST_ERR_SUCCESS 120
#define TEST_ERR_FAILURE 119
#define TEST_ERR_USAGE 118
#define TEST_ERR_FOPEN 117
#define TEST_ERR_FSTAT 116
#define TEST_ERR_BAD_TIMEOUT 115
/*
** Macros for test source code readability/maintainability.
**
** All of the following macros require that an int data type 'res' variable
** exists in scope where macro is used, and that it has been initialized to
** zero before the macro is used.
**
** exe_* and chk_* macros are helper macros not intended to be used from
** outside of this header file. Arguments 'Y' and 'Z' of these represent
** source code file and line number, while Arguments 'A', 'B', etc, are
** the arguments used to actually call a libcurl function.
**
** All easy_* and multi_* macros call a libcurl function and evaluate if
** the function has succeeded or failed. When the function succeeds 'res'
** variable is not set nor cleared and program continues normal flow. On
** the other hand if function fails 'res' variable is set and a jump to
** label 'test_cleanup' is performed.
**
** Every easy_* and multi_* macros have a res_easy_* and res_multi_* macro
** counterpart that operates in tha same way with the exception that no
** jump takes place in case of failure. res_easy_* and res_multi_* macros
** should be immediately followed by checking if 'res' variable has been
** set.
**
** 'res' variable when set will hold a CURLcode, CURLMcode, or any of the
** TEST_ERR_* values defined above. It is advisable to return this value
** as test result.
*/
/* ---------------------------------------------------------------- */
#define exe_easy_init(A,Y,Z) do { \
if(((A) = curl_easy_init()) == NULL) { \
fprintf(stderr, "%s:%d curl_easy_init() failed\n", (Y), (Z)); \
res = TEST_ERR_EASY_INIT; \
} \
} WHILE_FALSE
#define res_easy_init(A) \
exe_easy_init((A),(__FILE__),(__LINE__))
#define chk_easy_init(A,Y,Z) do { \
exe_easy_init((A),(Y),(Z)); \
if(res) \
goto test_cleanup; \
} WHILE_FALSE
#define easy_init(A) \
chk_easy_init((A),(__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
#define exe_multi_init(A,Y,Z) do { \
if(((A) = curl_multi_init()) == NULL) { \
fprintf(stderr, "%s:%d curl_multi_init() failed\n", (Y), (Z)); \
res = TEST_ERR_MULTI_INIT; \
} \
} WHILE_FALSE
#define res_multi_init(A) \
exe_multi_init((A),(__FILE__),(__LINE__))
#define chk_multi_init(A,Y,Z) do { \
exe_multi_init((A),(Y),(Z)); \
if(res) \
goto test_cleanup; \
} WHILE_FALSE
#define multi_init(A) \
chk_multi_init((A),(__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
#define exe_easy_setopt(A,B,C,Y,Z) do { \
CURLcode ec; \
if((ec = curl_easy_setopt((A),(B),(C))) != CURLE_OK) { \
fprintf(stderr, "%s:%d curl_easy_setopt() failed, " \
"with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_easy_strerror(ec)); \
res = (int)ec; \
} \
} WHILE_FALSE
#define res_easy_setopt(A,B,C) \
exe_easy_setopt((A),(B),(C),(__FILE__),(__LINE__))
#define chk_easy_setopt(A,B,C,Y,Z) do { \
exe_easy_setopt((A),(B),(C),(Y),(Z)); \
if(res) \
goto test_cleanup; \
} WHILE_FALSE
#define easy_setopt(A,B,C) \
chk_easy_setopt((A),(B),(C),(__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
#define exe_multi_setopt(A,B,C,Y,Z) do { \
CURLMcode ec; \
if((ec = curl_multi_setopt((A),(B),(C))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_setopt() failed, " \
"with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
res = (int)ec; \
} \
} WHILE_FALSE
#define res_multi_setopt(A,B,C) \
exe_multi_setopt((A),(B),(C),(__FILE__),(__LINE__))
#define chk_multi_setopt(A,B,C,Y,Z) do { \
exe_multi_setopt((A),(B),(C),(Y),(Z)); \
if(res) \
goto test_cleanup; \
} WHILE_FALSE
#define multi_setopt(A,B,C) \
chk_multi_setopt((A),(B),(C),(__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
#define exe_multi_add_handle(A,B,Y,Z) do { \
CURLMcode ec; \
if((ec = curl_multi_add_handle((A),(B))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_add_handle() failed, " \
"with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
res = (int)ec; \
} \
} WHILE_FALSE
#define res_multi_add_handle(A,B) \
exe_multi_add_handle((A),(B),(__FILE__),(__LINE__))
#define chk_multi_add_handle(A,B,Y,Z) do { \
exe_multi_add_handle((A),(B),(Y),(Z)); \
if(res) \
goto test_cleanup; \
} WHILE_FALSE
#define multi_add_handle(A,B) \
chk_multi_add_handle((A),(B),(__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
#define exe_multi_remove_handle(A,B,Y,Z) do { \
CURLMcode ec; \
if((ec = curl_multi_remove_handle((A),(B))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_remove_handle() failed, " \
"with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
res = (int)ec; \
} \
} WHILE_FALSE
#define res_multi_remove_handle(A,B) \
exe_multi_remove_handle((A),(B),(__FILE__),(__LINE__))
#define chk_multi_remove_handle(A,B,Y,Z) do { \
exe_multi_remove_handle((A),(B),(Y),(Z)); \
if(res) \
goto test_cleanup; \
} WHILE_FALSE
#define multi_remove_handle(A,B) \
chk_multi_remove_handle((A),(B),(__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
#define exe_multi_perform(A,B,Y,Z) do { \
CURLMcode ec; \
if((ec = curl_multi_perform((A),(B))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_perform() failed, " \
"with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
res = (int)ec; \
} \
else if(*((B)) < 0) { \
fprintf(stderr, "%s:%d curl_multi_perform() succeeded, " \
"but returned invalid running_handles value (%d)\n", \
(Y), (Z), (int)*((B))); \
res = TEST_ERR_NUM_HANDLES; \
} \
} WHILE_FALSE
#define res_multi_perform(A,B) \
exe_multi_perform((A),(B),(__FILE__),(__LINE__))
#define chk_multi_perform(A,B,Y,Z) do { \
exe_multi_perform((A),(B),(Y),(Z)); \
if(res) \
goto test_cleanup; \
} WHILE_FALSE
#define multi_perform(A,B) \
chk_multi_perform((A),(B),(__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
#define exe_multi_fdset(A,B,C,D,E,Y,Z) do { \
CURLMcode ec; \
if((ec = curl_multi_fdset((A),(B),(C),(D),(E))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_fdset() failed, " \
"with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
res = (int)ec; \
} \
else if(*((E)) < -1) { \
fprintf(stderr, "%s:%d curl_multi_fdset() succeeded, " \
"but returned invalid max_fd value (%d)\n", \
(Y), (Z), (int)*((E))); \
res = TEST_ERR_NUM_HANDLES; \
} \
} WHILE_FALSE
#define res_multi_fdset(A,B,C,D,E) \
exe_multi_fdset((A),(B),(C),(D),(E),(__FILE__),(__LINE__))
#define chk_multi_fdset(A,B,C,D,E,Y,Z) do { \
exe_multi_fdset((A),(B),(C),(D),(E),(Y),(Z)); \
if(res) \
goto test_cleanup; \
} WHILE_FALSE
#define multi_fdset(A,B,C,D,E) \
chk_multi_fdset((A),(B),(C),(D),(E),(__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
#define exe_multi_timeout(A,B,Y,Z) do { \
CURLMcode ec; \
if((ec = curl_multi_timeout((A),(B))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_timeout() failed, " \
"with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
res = (int)ec; \
} \
else if(*((B)) < -1L) { \
fprintf(stderr, "%s:%d curl_multi_timeout() succeeded, " \
"but returned invalid timeout value (%ld)\n", \
(Y), (Z), (long)*((B))); \
res = TEST_ERR_BAD_TIMEOUT; \
} \
} WHILE_FALSE
#define res_multi_timeout(A,B) \
exe_multi_timeout((A),(B),(__FILE__),(__LINE__))
#define chk_multi_timeout(A,B,Y,Z) do { \
exe_multi_timeout((A),(B),(Y),(Z)); \
if(res) \
goto test_cleanup; \
} WHILE_FALSE
#define multi_timeout(A,B) \
chk_multi_timeout((A),(B),(__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
#define exe_select_test(A,B,C,D,E,Y,Z) do { \
int ec; \
if(select_wrapper((A),(B),(C),(D),(E)) == -1 ) { \
ec = SOCKERRNO; \
fprintf(stderr, "%s:%d select() failed, with " \
"errno %d (%s)\n", \
(Y), (Z), ec, strerror(ec)); \
res = TEST_ERR_SELECT; \
} \
} WHILE_FALSE
#define res_select_test(A,B,C,D,E) \
exe_select_test((A),(B),(C),(D),(E),(__FILE__),(__LINE__))
#define chk_select_test(A,B,C,D,E,Y,Z) do { \
exe_select_test((A),(B),(C),(D),(E),(Y),(Z)); \
if(res) \
goto test_cleanup; \
} WHILE_FALSE
#define select_test(A,B,C,D,E) \
chk_select_test((A),(B),(C),(D),(E),(__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
#define start_test_timing() do { \
tv_test_start = tutil_tvnow(); \
} WHILE_FALSE
#define exe_test_timedout(Y,Z) do { \
if(tutil_tvdiff(tutil_tvnow(), tv_test_start) > TEST_HANG_TIMEOUT) { \
fprintf(stderr, "%s:%d ABORTING TEST, since it seems " \
"that it would have run forever.\n", (Y), (Z)); \
res = TEST_ERR_RUNS_FOREVER; \
} \
} WHILE_FALSE
#define res_test_timedout() \
exe_test_timedout((__FILE__),(__LINE__))
#define chk_test_timedout(Y,Z) do { \
exe_test_timedout(Y,Z); \
if(res) \
goto test_cleanup; \
} WHILE_FALSE
#define abort_on_test_timeout() \
chk_test_timedout((__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
#define exe_global_init(A,Y,Z) do { \
CURLcode ec; \
if((ec = curl_global_init((A))) != CURLE_OK) { \
fprintf(stderr, "%s:%d curl_global_init() failed, " \
"with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_easy_strerror(ec)); \
res = (int)ec; \
} \
} WHILE_FALSE
#define res_global_init(A) \
exe_global_init((A),(__FILE__),(__LINE__))
#define chk_global_init(A,Y,Z) do { \
exe_global_init((A),(Y),(Z)); \
if(res) \
return res; \
} WHILE_FALSE
/* global_init() is different than other macros. In case of
failure it 'return's instead of going to 'test_cleanup'. */
#define global_init(A) \
chk_global_init((A),(__FILE__),(__LINE__))
/* ---------------------------------------------------------------- */
@@ -1,10 +1,10 @@
#!/usr/bin/env perl
# Determine if curl-config --protocols/--features matches the
# curl --version protocols/features
if ( $#ARGV != 2 )
if ( $#ARGV != 2 )
{
print "Usage: $0 curl-config-script curl-version-output-file features|protocols\n";
exit 3;
print "Usage: $0 curl-config-script curl-version-output-file features|protocols\n";
exit 3;
}
my $what=$ARGV[2];
@@ -18,12 +18,11 @@ while( <CURL> )
}
close CURL;
$curl_protocols =~ s/\r//;
$curl_protocols =~ /\w+: (.*)$/;
@curl = split / /,$1;
# These features are not supported by curl-config
@curl = grep(!/^(Debug|TrackMemory|Metalink|Largefile|CharConv|GSS-Negotiate|SPNEGO)$/i, @curl);
@curl = grep(!/^(Debug|Largefile|CharConv|GSS-Negotiate|SPNEGO)$/i, @curl);
@curl = sort @curl;
# Read the output of curl-config
@@ -43,8 +42,8 @@ my $curlconfigproto = join ' ', @curl_config;
my $different = $curlproto ne $curlconfigproto;
if ($different) {
print "Mismatch in $what lists:\n";
print "curl: $curlproto\n";
print "curl-config: $curlconfigproto\n";
print "Mismatch in $what lists:\n";
print "curl: $curlproto\n";
print "curl-config: $curlconfigproto\n";
}
exit $different;
@@ -1,9 +1,9 @@
#!/usr/bin/env perl
# Determine if curl-config --version matches the curl --version
if ( $#ARGV != 2 )
if ( $#ARGV != 2 )
{
print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n";
exit 3;
print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n";
exit 3;
}
my $what=$ARGV[2];
@@ -12,7 +12,7 @@ my $what=$ARGV[2];
open(CURL, "$ARGV[1]") || die "Can't open curl --version list in $ARGV[1]\n";
$_ = <CURL>;
chomp;
/libcurl\/([\.\d]+((-DEV)|(-\d+))?)/;
/libcurl\/([\.\d]+(-CVS)?)/;
my $version = $1;
close CURL;
@@ -22,33 +22,24 @@ my $curlconfigversion;
open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config --$what list\n";
$_ = <CURLCONFIG>;
chomp;
my $filever=$_;
if ( $what eq "version" ) {
if($filever =~ /^libcurl ([\.\d]+((-DEV)|(-\d+))?)$/) {
$curlconfigversion = $1;
}
else {
$curlconfigversion = "illegal value";
}
/^libcurl ([\.\d]+(-CVS)?)$/ ;
$curlconfigversion = $1;
}
else { # "vernum" case
# Convert hex version to decimal for comparison's sake
if($filever =~ /^(..)(..)(..)$/) {
$curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3);
}
else {
$curlconfigversion = "illegal value";
}
else {
# Convert hex version to decimal for comparison's sake
/^(..)(..)(..)$/ ;
$curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3);
# Strip off the -DEV from the curl version if it's there
$version =~ s/-\w*$//;
# Strip off the -CVS from the curl version if it's there
$version =~ s/-CVS$//;
}
close CURLCONFIG;
my $different = $version ne $curlconfigversion;
if ($different || !$version) {
print "Mismatch in --version:\n";
print "curl: $version\n";
print "curl-config: $curlconfigversion\n";
exit 1;
print "Mismatch in --version:\n";
print "curl: $version\n";
print "curl-config: $curlconfigversion\n";
exit 1;
}
@@ -1,14 +1,14 @@
#!/usr/bin/env perl
# Determine if the given curl executable supports the 'openssl' SSL engine
if ( $#ARGV != 0 )
if ( $#ARGV != 0 )
{
print "Usage: $0 curl-executable\n";
exit 3;
print "Usage: $0 curl-executable\n";
exit 3;
}
if (!open(CURL, "@ARGV[0] -s --engine list|"))
{
print "Can't get SSL engine list\n";
exit 2;
print "Can't get SSL engine list\n";
exit 2;
}
while( <CURL> )
{
@@ -1,33 +1,33 @@
#!/usr/bin/env perl
# Perform simple file and directory manipulation in a portable way
if ( $#ARGV <= 0 )
if ( $#ARGV <= 0 )
{
print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n";
exit 1;
print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n";
exit 1;
}
use File::Copy;
while(@ARGV) {
my $cmd = shift @ARGV;
my $arg = shift @ARGV;
if ($cmd eq "mkdir") {
mkdir $arg || die "$!";
}
elsif ($cmd eq "rmdir") {
rmdir $arg || die "$!";
}
elsif ($cmd eq "rm") {
unlink $arg || die "$!";
}
elsif ($cmd eq "move") {
my $arg2 = shift @ARGV;
move($arg,$arg2) || die "$!";
}
elsif ($cmd eq "gone") {
! -e $arg || die "Path $arg exists";
} else {
print "Unsupported command $cmd\n";
exit 1;
}
my $cmd = shift @ARGV;
my $arg = shift @ARGV;
if ($cmd eq "mkdir") {
mkdir $arg || die "$!";
}
elsif ($cmd eq "rmdir") {
rmdir $arg || die "$!";
}
elsif ($cmd eq "rm") {
unlink $arg || die "$!";
}
elsif ($cmd eq "move") {
my $arg2 = shift @ARGV;
move($arg,$arg2) || die "$!";
}
elsif ($cmd eq "gone") {
! -e $arg || die "Path $arg exists";
} else {
print "Unsupported command $cmd\n";
exit 1;
}
}
exit 0;
@@ -2,104 +2,104 @@
# Prepare a directory with known files and clean up afterwards
use Time::Local;
if ( $#ARGV < 1 )
if ( $#ARGV < 1 )
{
print "Usage: $0 prepare|postprocess dir [logfile]\n";
exit 1;
print "Usage: $0 prepare|postprocess dir [logfile]\n";
exit 1;
}
# <precheck> expects an error message on stdout
sub errout {
print $_[0] . "\n";
exit 1;
print $_[0] . "\n";
exit 1;
}
if ($ARGV[0] eq "prepare")
{
my $dirname = $ARGV[1];
mkdir $dirname || errout "$!";
chdir $dirname;
my $dirname = $ARGV[1];
mkdir $dirname || errout "$!";
chdir $dirname;
# Create the files in alphabetical order, to increase the chances
# of receiving a consistent set of directory contents regardless
# of whether the server alphabetizes the results or not.
mkdir "asubdir" || errout "$!";
chmod 0777, "asubdir";
# Create the files in alphabetical order, to increase the chances
# of receiving a consistent set of directory contents regardless
# of whether the server alphabetizes the results or not.
mkdir "asubdir" || errout "$!";
chmod 0777, "asubdir";
open(FILE, ">plainfile.txt") || errout "$!";
binmode FILE;
print FILE "Test file to support curl test suite\n";
close(FILE);
utime time, timegm(0,0,12,1,0,100), "plainfile.txt";
chmod 0666, "plainfile.txt";
open(FILE, ">plainfile.txt") || errout "$!";
binmode FILE;
print FILE "Test file to support curl test suite\n";
close(FILE);
utime time, timegm(0,0,12,1,0,100), "plainfile.txt";
chmod 0666, "plainfile.txt";
open(FILE, ">rofile.txt") || errout "$!";
binmode FILE;
print FILE "Read-only test file to support curl test suite\n";
close(FILE);
utime time, timegm(0,0,12,31,11,100), "rofile.txt";
chmod 0444, "rofile.txt";
open(FILE, ">rofile.txt") || errout "$!";
binmode FILE;
print FILE "Read-only test file to support curl test suite\n";
close(FILE);
utime time, timegm(0,0,12,31,11,100), "rofile.txt";
chmod 0444, "rofile.txt";
exit 0;
exit 0;
}
elsif ($ARGV[0] eq "postprocess")
{
my $dirname = $ARGV[1];
my $logfile = $ARGV[2];
my $dirname = $ARGV[1];
my $logfile = $ARGV[2];
# Clean up the test directory
unlink "$dirname/rofile.txt";
unlink "$dirname/plainfile.txt";
rmdir "$dirname/asubdir";
# Clean up the test directory
unlink "$dirname/rofile.txt";
unlink "$dirname/plainfile.txt";
rmdir "$dirname/asubdir";
rmdir $dirname || die "$!";
rmdir $dirname || die "$!";
if ($logfile) {
# Process the directory file to remove all information that
# could be inconsistent from one test run to the next (e.g.
# file date) or may be unsupported on some platforms (e.g.
# Windows). Also, since 7.17.0, the sftp directory listing
# format can be dependent on the server (with a recent
# enough version of libssh2) so this script must also
# canonicalize the format. Here are examples of the general
# format supported:
# -r--r--r-- 12 ausername grp 47 Dec 31 2000 rofile.txt
# -r--r--r-- 1 1234 4321 47 Dec 31 2000 rofile.txt
# The "canonical" format is similar to the first (which is
# the one generated on a typical Linux installation):
# -r-?r-?r-? 12 U U 47 Dec 31 2000 rofile.txt
if ($logfile) {
# Process the directory file to remove all information that
# could be inconsistent from one test run to the next (e.g.
# file date) or may be unsupported on some platforms (e.g.
# Windows). Also, since 7.17.0, the sftp directory listing
# format can be dependent on the server (with a recent
# enough version of libssh2) so this script must also
# canonicalize the format. Here are examples of the general
# format supported:
# -r--r--r-- 12 ausername grp 47 Dec 31 2000 rofile.txt
# -r--r--r-- 1 1234 4321 47 Dec 31 2000 rofile.txt
# The "canonical" format is similar to the first (which is
# the one generated on a typical Linux installation):
# -r-?r-?r-? 12 U U 47 Dec 31 2000 rofile.txt
my @canondir;
open(IN, "<$logfile") || die "$!";
while (<IN>) {
/^(.)(..).(..).(..).\s*(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+\s+\S+\s+\S+)(.*)$/;
if ($1 eq "d") {
# Erase all directory metadata except for the name, as it is not
# consistent for across all test systems and filesystems
push @canondir, "d????????? N U U N ??? N NN:NN$8\n";
} elsif ($1 eq "-") {
# Erase user and group names, as they are not consistent across
# all test systems
my $line = sprintf("%s%s?%s?%s?%5d U U %15d %s%s\n", $1,$2,$3,$4,$5,$6,$7,$8);
push @canondir, $line;
} else {
# Unexpected format; just pass it through and let the test fail
push @canondir, $_;
}
}
close(IN);
my @canondir;
open(IN, "<$logfile") || die "$!";
while (<IN>) {
/^(.)(..).(..).(..).\s*(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+\s+\S+\s+\S+)(.*)$/;
if ($1 eq "d") {
# Erase all directory metadata except for the name, as it is not
# consistent for across all test systems and filesystems
push @canondir, "d????????? N U U N ??? N NN:NN$8\n";
} elsif ($1 eq "-") {
# Erase user and group names, as they are not consistent across
# all test systems
my $line = sprintf("%s%s?%s?%s?%5d U U %15d %s%s\n", $1,$2,$3,$4,$5,$6,$7,$8);
push @canondir, $line;
} else {
# Unexpected format; just pass it through and let the test fail
push @canondir, $_;
}
}
close(IN);
@canondir = sort {substr($a,57) cmp substr($b,57)} @canondir;
my $newfile = $logfile . ".new";
open(OUT, ">$newfile") || die "$!";
print OUT join('', @canondir);
close(OUT);
@canondir = sort {substr($a,57) cmp substr($b,57)} @canondir;
my $newfile = $logfile . ".new";
open(OUT, ">$newfile") || die "$!";
print OUT join('', @canondir);
close(OUT);
unlink $logfile;
rename $newfile, $logfile;
}
unlink $logfile;
rename $newfile, $logfile;
}
exit 0;
exit 0;
}
print "Unsupported command $ARGV[0]\n";
exit 1;
@@ -1,13 +1,13 @@
#!/usr/bin/env perl
# Check that the length of a given URL is correct
if ( $#ARGV != 1 )
if ( $#ARGV != 1 )
{
print "Usage: $0 string length\n";
exit 3;
print "Usage: $0 string length\n";
exit 3;
}
if (length(@ARGV[0]) != @ARGV[1])
{
print "Given host IP and port not supported\n";
exit 1;
print "Given host IP and port not supported\n";
exit 1;
}
exit 0;
@@ -1,146 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
#include "testutil.h"
#include "testtrace.h"
#include "memdebug.h"
struct libtest_trace_cfg libtest_debug_config;
static time_t epoch_offset; /* for test time tracing */
static int known_offset; /* for test time tracing */
static
void libtest_debug_dump(const char *timebuf, const char *text, FILE *stream,
const unsigned char *ptr, size_t size, int nohex)
{
size_t i;
size_t c;
unsigned int width = 0x10;
if(nohex)
/* without the hex output, we can fit more on screen */
width = 0x40;
fprintf(stream, "%s%s, %d bytes (0x%x)\n", timebuf, text,
(int)size, (int)size);
for(i = 0; i < size; i += width) {
fprintf(stream, "%04x: ", (int)i);
if(!nohex) {
/* hex not disabled, show it */
for(c = 0; c < width; c++)
if(i+c < size)
fprintf(stream, "%02x ", ptr[i+c]);
else
fputs(" ", stream);
}
for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */
if(nohex &&
(i+c+1 < size) && (ptr[i+c] == 0x0D) && (ptr[i+c+1] == 0x0A)) {
i += (c+2-width);
break;
}
fprintf(stream, "%c", ((ptr[i+c] >= 0x20) && (ptr[i+c] < 0x80)) ?
ptr[i+c] : '.');
/* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex &&
(i+c+2 < size) && (ptr[i+c+1] == 0x0D) && (ptr[i+c+2] == 0x0A)) {
i += (c+3-width);
break;
}
}
fputc('\n', stream); /* newline */
}
fflush(stream);
}
int libtest_debug_cb(CURL *handle, curl_infotype type,
unsigned char *data, size_t size,
void *userp)
{
struct libtest_trace_cfg *trace_cfg = userp;
const char *text;
struct timeval tv;
struct tm *now;
char timebuf[20];
char *timestr;
time_t secs;
(void)handle;
timebuf[0] = '\0';
timestr = &timebuf[0];
if(trace_cfg->tracetime) {
tv = tutil_tvnow();
if(!known_offset) {
epoch_offset = time(NULL) - tv.tv_sec;
known_offset = 1;
}
secs = epoch_offset + tv.tv_sec;
now = localtime(&secs); /* not thread safe but we don't care */
snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld ",
now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec);
}
switch (type) {
case CURLINFO_TEXT:
fprintf(stderr, "%s== Info: %s", timestr, (char *)data);
default: /* in case a new one is introduced to shock us */
return 0;
case CURLINFO_HEADER_OUT:
text = "=> Send header";
break;
case CURLINFO_DATA_OUT:
text = "=> Send data";
break;
case CURLINFO_SSL_DATA_OUT:
text = "=> Send SSL data";
break;
case CURLINFO_HEADER_IN:
text = "<= Recv header";
break;
case CURLINFO_DATA_IN:
text = "<= Recv data";
break;
case CURLINFO_SSL_DATA_IN:
text = "<= Recv SSL data";
break;
}
libtest_debug_dump(timebuf, text, stderr, data, size, trace_cfg->nohex);
return 0;
}
@@ -1,37 +0,0 @@
#ifndef HEADER_LIBTEST_TESTTRACE_H
#define HEADER_LIBTEST_TESTTRACE_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
struct libtest_trace_cfg {
int tracetime; /* 0 represents FALSE, anything else TRUE */
int nohex; /* 0 represents FALSE, anything else TRUE */
};
extern struct libtest_trace_cfg libtest_debug_config;
int libtest_debug_cb(CURL *handle, curl_infotype type,
unsigned char *data, size_t size,
void *userp);
#endif /* HEADER_LIBTEST_TESTTRACE_H */
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
* Copyright (C) 1998 - 2008, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -18,8 +18,10 @@
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
* $Id: testutil.c,v 1.8 2008-09-20 04:26:57 yangtse Exp $
***************************************************************************/
#include "curl_setup.h"
#include "setup.h"
#include "testutil.h"
#include "memdebug.h"
@@ -122,11 +124,8 @@ long tutil_tvdiff(struct timeval newer, struct timeval older)
*/
double tutil_tvdiff_secs(struct timeval newer, struct timeval older)
{
if(newer.tv_sec != older.tv_sec)
return (double)(newer.tv_sec-older.tv_sec)+
(double)(newer.tv_usec-older.tv_usec)/1000000.0;
else
return (double)(newer.tv_usec-older.tv_usec)/1000000.0;
return (double)(newer.tv_sec-older.tv_sec)+
(double)(newer.tv_usec-older.tv_usec)/1000000.0;
}
/* return the number of seconds in the given input timeval struct */
@@ -1,5 +1,5 @@
#ifndef HEADER_CURL_LIBTEST_TESTUTIL_H
#define HEADER_CURL_LIBTEST_TESTUTIL_H
#ifndef __LIBTEST_TESTUTIL_H
#define __LIBTEST_TESTUTIL_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
* Copyright (C) 1998 - 2007, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -20,8 +20,11 @@
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
* $Id: testutil.h,v 1.4 2007-02-20 12:12:27 yangtse Exp $
***************************************************************************/
#include "curl_setup.h"
#include "setup.h"
struct timeval tutil_tvnow(void);
@@ -43,5 +46,5 @@ double tutil_tvdiff_secs(struct timeval t1, struct timeval t2);
long tutil_tvlong(struct timeval t1);
#endif /* HEADER_CURL_LIBTEST_TESTUTIL_H */
#endif /* __LIBTEST_TESTUTIL_H */