summaryrefslogtreecommitdiff
path: root/libcurl/tests
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-01-11 23:51:49 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-01-22 18:04:37 +0300
commit23b1a0ab70f190dbbb33dabb18ec039c7d85d6b3 (patch)
treec86693607a9be05c53a44ce311d8f83638cbda03 /libcurl/tests
parented9a6438ec4b50ee897ac01296034de84167f2fe (diff)
Add implementation
Diffstat (limited to 'libcurl/tests')
-rw-r--r--libcurl/tests/.gitignore3
-rw-r--r--libcurl/tests/basic/buildfile7
-rw-r--r--libcurl/tests/basic/driver.c48
-rw-r--r--libcurl/tests/basic/testscript27
-rw-r--r--libcurl/tests/build/.gitignore3
-rw-r--r--libcurl/tests/build/bootstrap.build9
-rw-r--r--libcurl/tests/build/root.build22
-rw-r--r--libcurl/tests/buildfile5
8 files changed, 124 insertions, 0 deletions
diff --git a/libcurl/tests/.gitignore b/libcurl/tests/.gitignore
new file mode 100644
index 0000000..2e508a9
--- /dev/null
+++ b/libcurl/tests/.gitignore
@@ -0,0 +1,3 @@
+driver
+test/
+test-*/
diff --git a/libcurl/tests/basic/buildfile b/libcurl/tests/basic/buildfile
new file mode 100644
index 0000000..a01f5f2
--- /dev/null
+++ b/libcurl/tests/basic/buildfile
@@ -0,0 +1,7 @@
+# file : tests/basic/buildfile
+# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC
+# license : cURL License; see accompanying COPYING file
+
+import libs = libcurl%lib{curl}
+
+exe{driver}: {h c}{*} $libs testscript
diff --git a/libcurl/tests/basic/driver.c b/libcurl/tests/basic/driver.c
new file mode 100644
index 0000000..8e78ba9
--- /dev/null
+++ b/libcurl/tests/basic/driver.c
@@ -0,0 +1,48 @@
+/* file : tests/basic/driver.c
+ * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC
+ * license : cURL License; see accompanying COPYING file
+ */
+#include <stdio.h>
+#include <assert.h>
+
+#include <curl/curl.h>
+
+/* Usage: argv[0] <URL>
+ *
+ * Request the specified URL and print the response to stdout.
+ */
+int
+main (int argc, char* argv[])
+{
+ assert (argc == 2);
+
+ const char* url = argv[1];
+
+ curl_global_init (CURL_GLOBAL_DEFAULT);
+
+ int r = 1;
+
+ CURL* curl = curl_easy_init ();
+
+ if (curl != NULL)
+ {
+ curl_easy_setopt (curl, CURLOPT_URL, url);
+
+ CURLcode cr = curl_easy_perform (curl);
+
+ if (cr == CURLE_OK)
+ r = 0;
+ else
+ fprintf (stderr,
+ "failed to request '%s': %s\n",
+ url,
+ curl_easy_strerror (cr));
+
+ curl_easy_cleanup (curl);
+ }
+ else
+ fprintf (stderr, "curl_easy_init() failed\n");
+
+ curl_global_cleanup ();
+ return r;
+}
diff --git a/libcurl/tests/basic/testscript b/libcurl/tests/basic/testscript
new file mode 100644
index 0000000..a2260f4
--- /dev/null
+++ b/libcurl/tests/basic/testscript
@@ -0,0 +1,27 @@
+# file : tests/basic/testscript
+# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd
+# license : cURL License; see accompanying COPYING file
+
+: http
+:
+$* 'http://www.example.com' >>~%EOO%
+%<!doctype .*>%
+%.+
+EOO
+
+: https
+:
+: Test that an HTTPS URL is queried successfully via the system SSL backend
+: on Windows and MacOS/Clang and fails for other targets that use the OpenSSL
+: backend by default.
+:
+if ($c.target.class == 'windows' || \
+ $c.target.class == 'macos' && $c.id == 'clang-apple')
+{
+ $* 'http://www.example.com' | set s;
+ $* 'https://www.example.com' >"$s"
+}
+else
+{
+ $* 'https://www.example.com' 2>~'%failed to request .+%' != 0
+}
diff --git a/libcurl/tests/build/.gitignore b/libcurl/tests/build/.gitignore
new file mode 100644
index 0000000..4a730a3
--- /dev/null
+++ b/libcurl/tests/build/.gitignore
@@ -0,0 +1,3 @@
+config.build
+root/
+bootstrap/
diff --git a/libcurl/tests/build/bootstrap.build b/libcurl/tests/build/bootstrap.build
new file mode 100644
index 0000000..d2722f1
--- /dev/null
+++ b/libcurl/tests/build/bootstrap.build
@@ -0,0 +1,9 @@
+# file : tests/build/bootstrap.build
+# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd
+# license : cURL License; see accompanying COPYING file
+
+project = # Unnamed subproject.
+
+using config
+using dist
+using test
diff --git a/libcurl/tests/build/root.build b/libcurl/tests/build/root.build
new file mode 100644
index 0000000..a5f8fbe
--- /dev/null
+++ b/libcurl/tests/build/root.build
@@ -0,0 +1,22 @@
+# file : tests/build/root.build
+# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd
+# license : cURL License; see accompanying COPYING file
+
+using c
+
+h{*}: extension = h
+c{*}: extension = c
+
+if ($c.target.system == 'win32-msvc')
+ c.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
+
+if ($c.class == 'msvc')
+ c.coptions += /wd4251 /wd4275 /wd4800
+
+# Every exe{} in this subproject is by default a test.
+#
+exe{*}: test = true
+
+# Specify the test target for cross-testing.
+#
+test.target = $c.target
diff --git a/libcurl/tests/buildfile b/libcurl/tests/buildfile
new file mode 100644
index 0000000..dcd3e02
--- /dev/null
+++ b/libcurl/tests/buildfile
@@ -0,0 +1,5 @@
+# file : tests/buildfile
+# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd
+# license : cURL License; see accompanying COPYING file
+
+./: {*/ -build/}