2019-10-23 15:57:40 +02:00
|
|
|
#include "test_common.h"
|
2019-09-20 01:40:30 +02:00
|
|
|
|
|
|
|
#include <openvpn/common/string.hpp>
|
|
|
|
#include <openvpn/common/process.hpp>
|
|
|
|
|
|
|
|
using namespace openvpn;
|
|
|
|
|
2019-10-23 15:57:40 +02:00
|
|
|
TEST(misc, pipe) {
|
2019-09-20 01:40:30 +02:00
|
|
|
RedirectPipe::InOut io;
|
|
|
|
|
|
|
|
{
|
|
|
|
Argv argv;
|
|
|
|
io.in = "one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n";
|
|
|
|
argv.emplace_back("sort");
|
|
|
|
argv.emplace_back("-u");
|
2019-10-23 15:57:40 +02:00
|
|
|
//OPENVPN_LOG(argv.to_string());
|
2020-02-05 18:35:36 +01:00
|
|
|
const int status = system_cmd("/usr/bin/sort", argv, nullptr, io, 0, nullptr);
|
2019-09-20 01:40:30 +02:00
|
|
|
|
2019-10-23 15:57:40 +02:00
|
|
|
ASSERT_EQ(0, status) << "bad sort status=" << status << " stderr=" << io.err;
|
2019-09-20 01:40:30 +02:00
|
|
|
|
|
|
|
const std::string expected = "eight\nfive\nfour\nnine\none\nseven\nsix\nten\nthree\ntwo\n";
|
2019-10-23 15:57:40 +02:00
|
|
|
ASSERT_EQ (io.out, expected) << "bad sort EXPECTED:\n" << expected << "ACTUAL:\n" << io.out;
|
2019-09-20 01:40:30 +02:00
|
|
|
}
|
2020-02-05 18:35:36 +01:00
|
|
|
}
|