Imported Upstream version 7.59.0
[platform/upstream/curl.git] / tests / libtest / lib1555.c
1 /***************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2015, 2017, 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.haxx.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  ***************************************************************************/
22 /*
23  * Verify that some API functions are locked from being called inside callback
24  */
25
26 #include "test.h"
27
28 #include "memdebug.h"
29
30 static CURL *curl;
31
32 static int progressCallback(void *arg,
33                             double dltotal,
34                             double dlnow,
35                             double ultotal,
36                             double ulnow)
37 {
38   CURLcode res = 0;
39   (void)arg;
40   (void)dltotal;
41   (void)dlnow;
42   (void)ultotal;
43   (void)ulnow;
44   res = curl_easy_recv(curl, NULL, 0, NULL);
45   printf("curl_easy_recv returned %d\n", res);
46   res = curl_easy_send(curl, NULL, 0, NULL);
47   printf("curl_easy_send returned %d\n", res);
48
49   return 1;
50 }
51
52 int test(char *URL)
53 {
54   int res = 0;
55
56   global_init(CURL_GLOBAL_ALL);
57
58   easy_init(curl);
59
60   easy_setopt(curl, CURLOPT_URL, URL);
61   easy_setopt(curl, CURLOPT_TIMEOUT, (long)7);
62   easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1);
63   easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressCallback);
64   easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
65   easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0);
66
67   res = curl_easy_perform(curl);
68
69 test_cleanup:
70
71   /* undocumented cleanup sequence - type UA */
72
73   curl_easy_cleanup(curl);
74   curl_global_cleanup();
75
76   return res;
77 }