aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2018-02-10 15:13:15 +0100
committerDaniel Stenberg <daniel@haxx.se>2018-02-15 09:36:03 +0100
commitb46cfbc068ebe90f18e9777b9e877e4934c1b5e3 (patch)
tree4d88b0f4d9492f51a93251e488400ff7a8abba62 /tests
parent43a50a2580db2bfb28483a96964ae27b584472da (diff)
TODO fixed: Detect when called from within callbacks
Closes #2302
Diffstat (limited to 'tests')
-rw-r--r--tests/data/Makefile.inc2
-rw-r--r--tests/data/test15386
-rw-r--r--tests/data/test155550
-rw-r--r--tests/libtest/Makefile.inc6
-rw-r--r--tests/libtest/lib1555.c77
5 files changed, 137 insertions, 4 deletions
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index 34fdbfffb..335570ae6 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -171,7 +171,7 @@ test1520 test1521 \
test1525 test1526 test1527 test1528 test1529 test1530 test1531 test1532 \
test1533 test1534 test1535 test1536 test1537 test1538 \
test1540 \
-test1550 test1551 test1552 test1553 test1554 \
+test1550 test1551 test1552 test1553 test1554 test1555 \
test1600 test1601 test1602 test1603 test1604 test1605 test1606 \
\
test1700 test1701 test1702 \
diff --git a/tests/data/test1538 b/tests/data/test1538
index 25b39a6f6..b084dac6d 100644
--- a/tests/data/test1538
+++ b/tests/data/test1538
@@ -125,7 +125,8 @@ e89: The max connection limit is reached
e90: SSL public key does not match pinned public key
e91: SSL server certificate status verification FAILED
e92: Stream error in the HTTP/2 framing layer
-e93: Unknown error
+e93: API function called from within callback
+e94: Unknown error
m-1: Please call curl_multi_perform() soon
m0: No error
m1: Invalid multi handle
@@ -135,7 +136,8 @@ m4: Internal error
m5: Invalid socket argument
m6: Unknown option
m7: The easy handle is already added to a multi handle
-m8: Unknown error
+m8: API function called from within callback
+m9: Unknown error
s0: No error
s1: Unknown share option
s2: Share currently in use
diff --git a/tests/data/test1555 b/tests/data/test1555
new file mode 100644
index 000000000..19512c5f5
--- /dev/null
+++ b/tests/data/test1555
@@ -0,0 +1,50 @@
+<testcase>
+<info>
+<keywords>
+RECURSIVE_API_CALL
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<data nocheck="yes">
+HTTP/1.1 204 PARTIAL
+X-Comment: partial response to keep the client waiting
+</data>
+<postcmd>
+wait 10
+</postcmd>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+<tool>
+lib1555
+</tool>
+ <name>
+verify api is protected against calls from callbacks
+ </name>
+
+# this server/host won't be used for real
+ <command>
+http://%HOSTIP:%HTTPPORT/1555
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+</protocol>
+# 42 == CURLE_ABORTED_BY_CALLBACK
+<errorcode>
+42
+</errorcode>
+<stdout>
+curl_easy_recv returned 93
+curl_easy_send returned 93
+</stdout>
+</verify>
+</testcase>
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index d8a55e21d..c23dedd5e 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -27,7 +27,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
lib1525 lib1526 lib1527 lib1528 lib1529 lib1530 lib1531 lib1532 lib1533 \
lib1534 lib1535 lib1536 lib1537 lib1538 \
lib1540 \
- lib1550 lib1551 lib1552 lib1553 lib1554 \
+ lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 \
lib1900 \
lib2033
@@ -477,6 +477,10 @@ lib1553_CPPFLAGS = $(AM_CPPFLAGS)
lib1554_SOURCES = lib1554.c $(SUPPORTFILES)
lib1554_CPPFLAGS = $(AM_CPPFLAGS)
+lib1555_SOURCES = lib1555.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
+lib1555_LDADD = $(TESTUTIL_LIBS)
+lib1555_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1555
+
lib1900_SOURCES = lib1900.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1900_LDADD = $(TESTUTIL_LIBS)
lib1900_CPPFLAGS = $(AM_CPPFLAGS)
diff --git a/tests/libtest/lib1555.c b/tests/libtest/lib1555.c
new file mode 100644
index 000000000..e4f2255ac
--- /dev/null
+++ b/tests/libtest/lib1555.c
@@ -0,0 +1,77 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2015, 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+/*
+ * Verify that some API functions are locked from being called inside callback
+ */
+
+#include "test.h"
+
+#include "memdebug.h"
+
+static CURL *curl;
+
+static int progressCallback(void *arg,
+ double dltotal,
+ double dlnow,
+ double ultotal,
+ double ulnow)
+{
+ CURLcode res = 0;
+ (void)arg;
+ (void)dltotal;
+ (void)dlnow;
+ (void)ultotal;
+ (void)ulnow;
+ res = curl_easy_recv(curl, NULL, 0, NULL);
+ printf("curl_easy_recv returned %d\n", res);
+ res = curl_easy_send(curl, NULL, 0, NULL);
+ printf("curl_easy_send returned %d\n", res);
+
+ return 1;
+}
+
+int test(char *URL)
+{
+ int res = 0;
+
+ global_init(CURL_GLOBAL_ALL);
+
+ easy_init(curl);
+
+ easy_setopt(curl, CURLOPT_URL, URL);
+ easy_setopt(curl, CURLOPT_TIMEOUT, (long)7);
+ easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1);
+ easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressCallback);
+ easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
+ easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0);
+
+ res = curl_easy_perform(curl);
+
+test_cleanup:
+
+ /* undocumented cleanup sequence - type UA */
+
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+
+ return res;
+}