# # # add_file "netxx_pipe_stdio_main.cc" # content [38e6df2df0e476cd62e94e347da132a440283e9d] # # patch "Makefile.am" # from [2fcc23bd4f5f2ae7a4d36eacb047ce44b33158d9] # to [fb6fd5b1ab1e76e5018625866898cf5b092af51a] # # patch "netsync.cc" # from [6b00f6271a8eb7d72d3234ef738691fcbf6574c4] # to [6d75d32b27057d033026d79cd1ce5a8332876c76] # ============================================================ --- netxx_pipe_stdio_main.cc 38e6df2df0e476cd62e94e347da132a440283e9d +++ netxx_pipe_stdio_main.cc 38e6df2df0e476cd62e94e347da132a440283e9d @@ -0,0 +1,80 @@ +// Copyright (C) 2007 Stephen Leake +// +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. +// +// Provide a simple main program for use in netxx_pipe.cc unit test +// +// It uses StdioStream, and echos stdin to stdout, with debug messages +// on stderr. + +#include "base.hh" +#include "netxx_pipe.hh" + +#include + +struct tester_sanity : public sanity +{ + void inform_log(std::string const &msg) + {fprintf(stdout, "%s", msg.c_str());} + void inform_message(std::string const &msg) + {fprintf(stdout, "%s", msg.c_str());}; + void inform_warning(std::string const &msg) + {fprintf(stderr, "warning: %s", msg.c_str());}; + void inform_error(std::string const &msg) + {fprintf(stderr, "error: %s", msg.c_str());}; +}; +tester_sanity real_sanity; +sanity & global_sanity = real_sanity; + +int main (int argc, char *argv[]) +{ + + Netxx::StdioStream stream (STDIN_FILENO, STDOUT_FILENO); + Netxx::StdioProbe probe; + Netxx::Probe::result_type probe_result; + Netxx::Timeout short_time(0,1000); + + char buffer[256]; + Netxx::signed_size_type bytes_read; + int i; + + probe.add (stream, Netxx::Probe::ready_read); + + // if no argument specified, continue forever; else exit after 100 loops + for (i = 0; (argc == 1) || (i < 100); i++) + { + probe_result = probe.ready(short_time); + fprintf (stderr, "probe_result => %d\n", probe_result.second); + + switch (probe_result.second) + { + case Netxx::Probe::ready_none: + break; + + case Netxx::Probe::ready_read: + bytes_read = stream.read (buffer, sizeof (buffer)); + fprintf (stderr, "bytes read => %d\n", bytes_read); + stream.write (buffer, bytes_read); + + break; + + case Netxx::Probe::ready_write: + break; + + case Netxx::Probe::ready_oobd: + continue; + break; + } + } + + stream.close(); + + return 1; +} // end main +// end of file ============================================================ --- Makefile.am 2fcc23bd4f5f2ae7a4d36eacb047ce44b33158d9 +++ Makefile.am fb6fd5b1ab1e76e5018625866898cf5b092af51a @@ -357,6 +357,10 @@ tester_LDADD = $(addprefix mtn-, $(patsu $(filter %.cc, $(SANITY_CORE_SOURCES) $(LUAEXT_SOURCES) \ pcrewrap.cc))) +netxx_pipe_stdio_main_SOURCES = netxx_pipe_stdio_main.cc netxx_pipe.cc +netxx_pipe_stdio_main_CPPFLAGS = -I$(top_srcdir)/lua +netxx_pipe_stdio_main_LDADD = $(tester_LDADD) + txt2c_SOURCES = txt2c.cc noinst_LIBRARIES = libplatform.a lib3rdparty.a @@ -450,6 +454,7 @@ if WIN32_PLATFORM mtn_SOURCES += win32/main.cc mtn_LDADD += -lshfolder -lws2_32 -lintl -liconv -liphlpapi unit_tester_LDADD += -lshfolder -lws2_32 -lintl -liconv -liphlpapi + netxx_pipe_stdio_main_LDADD += -lshfolder -lws2_32 -lintl -liconv -liphlpapi lib3rdparty_a_CPPFLAGS += -DWIN32 -DBOTAN_EXT_ENTROPY_SRC_CAPI -DBOTAN_EXT_ENTROPY_SRC_WIN32 lib3rdparty_a_SOURCES += botan/es_capi.cpp botan/es_win32.cpp else @@ -645,7 +650,7 @@ lua_tests.status : mtn unit_tests.status : unit_tester lua_tests.status : mtn -check_PROGRAMS = unit_tester tester +check_PROGRAMS = unit_tester tester netxx_pipe_stdio_main # We want the tests re-run even if the .status files already exist. # .PHONY does not work for that (bad interaction with pattern rules), @@ -835,3 +840,5 @@ html: monotone.texi version.texi std_hoo sed -e 's,,,' $$f.bak >$$f; \ rm -f $$f.bak; \ done + +* Makefile.am (check_PROGRAMS): ============================================================ --- netsync.cc 6b00f6271a8eb7d72d3234ef738691fcbf6574c4 +++ netsync.cc 6d75d32b27057d033026d79cd1ce5a8332876c76 @@ -2501,7 +2501,7 @@ static void } static void -arm_sessions_and_calculate_probe(Netxx::Probe & probe, +arm_sessions_and_calculate_probe(Netxx::StdioProbe & probe, map > & sessions, set & armed_sessions, transaction_guard & guard) @@ -2718,7 +2718,7 @@ serve_connections(protocol_role role, unsigned long timeout_seconds, unsigned long session_limit) { - Netxx::Probe probe; + Netxx::StdioProbe probe; Netxx::Timeout forever,