aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-05-29 20:05:54 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-05-30 19:04:13 +0300
commit95ff8f359cfc2189bd4d7e02e15373027d2bda32 (patch)
tree2b22d991886c0a5c2678ea0fb5f565f90d57df25 /tests
parent1b57e247b8d1a7a41a8ee45d6d524c71edd63a81 (diff)
Implement openssl process
Diffstat (limited to 'tests')
-rw-r--r--tests/buildfile3
-rw-r--r--tests/openssl/buildfile7
-rw-r--r--tests/openssl/driver.cxx35
-rw-r--r--tests/openssl/testscript5
4 files changed, 48 insertions, 2 deletions
diff --git a/tests/buildfile b/tests/buildfile
index 6761a42..a721517 100644
--- a/tests/buildfile
+++ b/tests/buildfile
@@ -2,5 +2,4 @@
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-./: {*/ -curl/ -sendmail/}
-
+./: {*/ -curl/ -openssl/ -sendmail/}
diff --git a/tests/openssl/buildfile b/tests/openssl/buildfile
new file mode 100644
index 0000000..3a3ab49
--- /dev/null
+++ b/tests/openssl/buildfile
@@ -0,0 +1,7 @@
+# file : tests/openssl/buildfile
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+exe{driver}: cxx{driver} ../../libbutl/lib{butl} test{testscript}
+
+include ../../libbutl/
diff --git a/tests/openssl/driver.cxx b/tests/openssl/driver.cxx
new file mode 100644
index 0000000..769c77e
--- /dev/null
+++ b/tests/openssl/driver.cxx
@@ -0,0 +1,35 @@
+// file : tests/openssl/driver.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <vector>
+#include <iostream>
+#include <iterator>
+#include <system_error>
+
+#include <libbutl/path.hxx>
+#include <libbutl/utility.hxx> // operator<<(ostream, exception)
+#include <libbutl/openssl.hxx>
+
+using namespace std;
+using namespace butl;
+
+// Usage: argv[0]
+//
+int
+main (int, const char* argv[])
+try
+{
+ openssl os (nullfd, path ("-"), 2, path ("openssl"), "rand", 128);
+
+ vector<char> r
+ ((istreambuf_iterator<char> (os.in)), istreambuf_iterator<char> ());
+
+ os.in.close ();
+ return os.wait () && r.size () == 128 ? 0 : 1;
+}
+catch (const system_error& e)
+{
+ cerr << argv[0] << ": " << e << endl;
+ return 1;
+}
diff --git a/tests/openssl/testscript b/tests/openssl/testscript
new file mode 100644
index 0000000..f0eef62
--- /dev/null
+++ b/tests/openssl/testscript
@@ -0,0 +1,5 @@
+# file : tests/openssl/testscript
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+$*