aboutsummaryrefslogtreecommitdiff
path: root/tests/openssl/driver.cxx
blob: 769c77e14beec3e28f7dd069239ac710253232c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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;
}