1 #include "SockBuffer.hpp"
8 #include <fmt/format.h>
10 #include <glog/logging.h>
12 int main(int argc
, char* argv
[])
14 constexpr auto infile
= "body.txt";
16 int fd_in
= open(infile
, O_RDONLY
);
17 PCHECK(fd_in
!= -1) << "Can't open file " << infile
;
19 char outfile
[] = "/tmp/SockBuffer-test-XXXXXX";
21 int fd_out
= mkstemp(outfile
);
24 auto read_hook
= []() { std::cout
<< "read_hook\n"; };
26 boost::iostreams::stream
<SockBuffer
> iostream
{fd_in
,
29 std::chrono::seconds(10),
30 std::chrono::seconds(10),
31 std::chrono::seconds(1)};
34 while (std::getline(iostream
, line
)) {
35 iostream
<< line
<< '\n';
37 iostream
.clear(); // unset eof bit, if set will short-circut flush
38 iostream
<< std::flush
;
40 auto const diff_cmd
{fmt::format("diff {} {}", infile
, outfile
)};
41 CHECK_EQ(system(diff_cmd
.c_str()), 0);
43 PCHECK(!unlink(outfile
)) << "unlink failed for " << outfile
;
45 std::cout
<< "sizeof(SockBuffer) == " << sizeof(SockBuffer
) << '\n';