quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

lib583.c (2663B)


      1 /***************************************************************************
      2  *                                  _   _ ____  _
      3  *  Project                     ___| | | |  _ \| |
      4  *                             / __| | | | |_) | |
      5  *                            | (__| |_| |  _ <| |___
      6  *                             \___|\___/|_| \_\_____|
      7  *
      8  * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      9  *
     10  * This software is licensed as described in the file COPYING, which
     11  * you should have received as part of this distribution. The terms
     12  * are also available at https://curl.se/docs/copyright.html.
     13  *
     14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
     15  * copies of the Software, and permit persons to whom the Software is
     16  * furnished to do so, under the terms of the COPYING file.
     17  *
     18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
     19  * KIND, either express or implied.
     20  *
     21  * SPDX-License-Identifier: curl
     22  *
     23  ***************************************************************************/
     24 /*
     25  * This test case is based on the sample code provided by Saqib Ali
     26  * https://curl.se/mail/lib-2011-03/0066.html
     27  */
     28 
     29 #include "first.h"
     30 
     31 #include "memdebug.h"
     32 
     33 static CURLcode test_lib583(char *URL)
     34 {
     35   int stillRunning;
     36   CURLM *multiHandle = NULL;
     37   CURL *curl = NULL;
     38   CURLcode res = CURLE_OK;
     39   CURLMcode mres;
     40 
     41   assert(test_argc >= 4);
     42 
     43   global_init(CURL_GLOBAL_ALL);
     44 
     45   multi_init(multiHandle);
     46 
     47   easy_init(curl);
     48 
     49   easy_setopt(curl, CURLOPT_USERPWD, libtest_arg2);
     50   easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE,  test_argv[3]);
     51   easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, test_argv[4]);
     52 
     53   easy_setopt(curl, CURLOPT_UPLOAD, 1L);
     54   easy_setopt(curl, CURLOPT_VERBOSE, 1L);
     55 
     56   easy_setopt(curl, CURLOPT_URL, URL);
     57   easy_setopt(curl, CURLOPT_INFILESIZE, (long)5);
     58 
     59   multi_add_handle(multiHandle, curl);
     60 
     61   /* this tests if removing an easy handle immediately after multi
     62      perform has been called succeeds or not. */
     63 
     64   curl_mfprintf(stderr, "curl_multi_perform()...\n");
     65 
     66   multi_perform(multiHandle, &stillRunning);
     67 
     68   curl_mfprintf(stderr, "curl_multi_perform() succeeded\n");
     69 
     70   curl_mfprintf(stderr, "curl_multi_remove_handle()...\n");
     71   mres = curl_multi_remove_handle(multiHandle, curl);
     72   if(mres) {
     73     curl_mfprintf(stderr, "curl_multi_remove_handle() failed, "
     74                   "with code %d\n", (int)mres);
     75     res = TEST_ERR_MULTI;
     76   }
     77   else
     78     curl_mfprintf(stderr, "curl_multi_remove_handle() succeeded\n");
     79 
     80 test_cleanup:
     81 
     82   /* undocumented cleanup sequence - type UB */
     83 
     84   curl_easy_cleanup(curl);
     85   curl_multi_cleanup(multiHandle);
     86   curl_global_cleanup();
     87 
     88   return res;
     89 }