summaryrefslogtreecommitdiff
path: root/tests/test_tools_6.cc
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2024-12-10 22:30:12 +0100
committerRodrigo Arias Mallo <rodarima@gmail.com>2024-12-10 22:30:12 +0100
commit429d5f88b94ff28416cbfc6420b6389fa284df97 (patch)
treefb6fdaf7731de1ef396f98b748c56f3149801c84 /tests/test_tools_6.cc
Import RTFL 0.1.1v0.1.1
Diffstat (limited to 'tests/test_tools_6.cc')
-rw-r--r--tests/test_tools_6.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_tools_6.cc b/tests/test_tools_6.cc
new file mode 100644
index 0000000..f02a19e
--- /dev/null
+++ b/tests/test_tools_6.cc
@@ -0,0 +1,29 @@
+#include "simple_sink.hh"
+#include "testtools.hh"
+
+using namespace rtfl::tools;
+using namespace rtfl::tests;
+
+// Test LinesSourceSequence: make sure that LinesSourceSequence deals correctly
+// with timeouts.
+int main (int argc, char *argv[])
+{
+ int fd1 = openPipe ("sleep 5");
+ BlockingLinesSource s1 (fd1);
+ // Both commands start at the same time, even if fd2 is processed later; so
+ // it takes 10, not 15 secs totally.
+ int fd2 = openPipe ("sleep 10");
+ BlockingLinesSource s2 (fd2);
+
+ LinesSourceSequence lss (false);
+ lss.add (&s1);
+ lss.add (&s2);
+
+ for (int i = 2; i <= 20; i += 2)
+ lss.addTimeout(i, i);
+
+ SimpleSink sink;
+ lss.setup (&sink);
+
+ return 0;
+}