lib1500.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 = TEST_ERR_FAILURE;
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     int num;
00058     res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
00059     if(res != CURLM_OK) {
00060       printf("curl_multi_wait() returned %d\n", res);
00061       res = TEST_ERR_MAJOR_BAD;
00062       goto test_cleanup;
00063     }
00064 
00065     abort_on_test_timeout();
00066 
00067     multi_perform(multi, &still_running);
00068 
00069     abort_on_test_timeout();
00070   }
00071 
00072   msg = curl_multi_info_read(multi, &still_running);
00073   if(msg)
00074     /* this should now contain a result code from the easy handle,
00075        get it */
00076     i = msg->data.result;
00077 
00078 test_cleanup:
00079 
00080   /* undocumented cleanup sequence - type UA */
00081 
00082   curl_multi_cleanup(multi);
00083   curl_easy_cleanup(curls);
00084   curl_global_cleanup();
00085 
00086   if(res)
00087     i = res;
00088 
00089   return i; /* return the final return code */
00090 }


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