lib575.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 #include "test.h"
00023 
00024 #include <fcntl.h>
00025 
00026 #include "testutil.h"
00027 #include "warnless.h"
00028 #include "memdebug.h"
00029 
00030 #define TEST_HANG_TIMEOUT 60 * 1000
00031 
00032 /* 3x download!
00033  * 1. normal
00034  * 2. dup handle
00035  * 3. with multi interface
00036  */
00037 
00038 int test(char *URL)
00039 {
00040   CURL *handle = NULL;
00041   CURL *duphandle = NULL;
00042   CURLM *mhandle = NULL;
00043   int res = 0;
00044   int still_running = 0;
00045 
00046   start_test_timing();
00047 
00048   global_init(CURL_GLOBAL_ALL);
00049 
00050   easy_init(handle);
00051 
00052   easy_setopt(handle, CURLOPT_URL, URL);
00053   easy_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
00054   easy_setopt(handle, CURLOPT_VERBOSE, 1L);
00055 
00056   res = curl_easy_perform(handle);
00057   if(res)
00058     goto test_cleanup;
00059 
00060   res = curl_easy_perform(handle);
00061   if(res)
00062     goto test_cleanup;
00063 
00064   duphandle = curl_easy_duphandle(handle);
00065   if(!duphandle)
00066     goto test_cleanup;
00067   curl_easy_cleanup(handle);
00068   handle = duphandle;
00069 
00070   multi_init(mhandle);
00071 
00072   multi_add_handle(mhandle, handle);
00073 
00074   multi_perform(mhandle, &still_running);
00075 
00076   abort_on_test_timeout();
00077 
00078   while(still_running) {
00079     struct timeval timeout;
00080     fd_set fdread;
00081     fd_set fdwrite;
00082     fd_set fdexcep;
00083     int maxfd = -99;
00084 
00085     timeout.tv_sec = 0;
00086     timeout.tv_usec = 100000L; /* 100 ms */
00087 
00088     FD_ZERO(&fdread);
00089     FD_ZERO(&fdwrite);
00090     FD_ZERO(&fdexcep);
00091 
00092     multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &maxfd);
00093 
00094     /* At this point, maxfd is guaranteed to be greater or equal than -1. */
00095 
00096     select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
00097 
00098     abort_on_test_timeout();
00099 
00100     multi_perform(mhandle, &still_running);
00101 
00102     abort_on_test_timeout();
00103   }
00104 
00105 test_cleanup:
00106 
00107   /* undocumented cleanup sequence - type UA */
00108 
00109   curl_multi_cleanup(mhandle);
00110   curl_easy_cleanup(handle);
00111   curl_global_cleanup();
00112 
00113   return res;
00114 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05