lib507.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, 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 "testutil.h"
00025 #include "warnless.h"
00026 #include "memdebug.h"
00027 
00028 #define TEST_HANG_TIMEOUT 60 * 1000
00029 
00030 int test(char *URL)
00031 {
00032   CURL *curls = NULL;
00033   CURLM *multi = NULL;
00034   int still_running;
00035   int i = -1;
00036   int res = 0;
00037   CURLMsg *msg;
00038 
00039   start_test_timing();
00040 
00041   global_init(CURL_GLOBAL_ALL);
00042 
00043   multi_init(multi);
00044 
00045   easy_init(curls);
00046 
00047   easy_setopt(curls, CURLOPT_URL, URL);
00048   easy_setopt(curls, CURLOPT_HEADER, 1L);
00049 
00050   multi_add_handle(multi, curls);
00051 
00052   multi_perform(multi, &still_running);
00053 
00054   abort_on_test_timeout();
00055 
00056   while(still_running) {
00057     struct timeval timeout;
00058     fd_set fdread;
00059     fd_set fdwrite;
00060     fd_set fdexcep;
00061     int maxfd = -99;
00062 
00063     FD_ZERO(&fdread);
00064     FD_ZERO(&fdwrite);
00065     FD_ZERO(&fdexcep);
00066     timeout.tv_sec = 1;
00067     timeout.tv_usec = 0;
00068 
00069     multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
00070 
00071     /* At this point, maxfd is guaranteed to be greater or equal than -1. */
00072 
00073     select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
00074 
00075     abort_on_test_timeout();
00076 
00077     multi_perform(multi, &still_running);
00078 
00079     abort_on_test_timeout();
00080   }
00081 
00082   msg = curl_multi_info_read(multi, &still_running);
00083   if(msg)
00084     /* this should now contain a result code from the easy handle,
00085        get it */
00086     i = msg->data.result;
00087 
00088 test_cleanup:
00089 
00090   /* undocumented cleanup sequence - type UA */
00091 
00092   curl_multi_cleanup(multi);
00093   curl_easy_cleanup(curls);
00094   curl_global_cleanup();
00095 
00096   if(res)
00097     i = res;
00098 
00099   return i; /* return the final return code */
00100 }


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