]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Don't fail the test right away if we don't have the right number of FDs ready 8087/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 16 Jul 2019 12:05:12 +0000 (14:05 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 16 Jul 2019 12:05:12 +0000 (14:05 +0200)
This way we can at least check that the callbacks are called later.
Also, since it looks like the read pipe is always reported as ready,
let's try to write first to see if it blocks.

pdns/test-mplexer.cc

index b35c54d1892c8d9a3b49f160a3b8829b558ec289..5a3269f5593149a9267c94da0ffc2b008aaa636c 100644 (file)
@@ -130,22 +130,22 @@ BOOST_AUTO_TEST_CASE(test_MPlexer) {
     cerr<<"Watching "<<mplexer->getWatchedFDCount(false)<<" FDs for read and "<<mplexer->getWatchedFDCount(true)<<" for write"<<endl;
     cerr<<"pipes[0] is "<<pipes[0]<<endl;
     cerr<<"pipes[1] is "<<pipes[1]<<endl;
-    cerr<<"The file descripttor returned as ready is "<<readyFDs.at(0)<<endl;
+    cerr<<"The file descriptor returned as ready is "<<readyFDs.at(0)<<endl;
     char buffer[2];
-    ssize_t res = read(pipes[0], &buffer[0], sizeof(buffer));
+    ssize_t res = write(pipes[1], "0", 1);
     int saved = errno;
-    cerr<<"Reading from pipes[0] returns "<<res<<endl;
+    cerr<<"Writing to pipes[1] returns "<<res<<endl;
     if (res == -1) {
       cerr<<"errno is "<<saved<<endl;
     }
-    res = write(pipes[1], "0", 1);
+    res = read(pipes[0], &buffer[0], sizeof(buffer));
     saved = errno;
-    cerr<<"Writing to pipes[1] returns "<<res<<endl;
+    cerr<<"Reading from pipes[0] returns "<<res<<endl;
     if (res == -1) {
       cerr<<"errno is "<<saved<<endl;
     }
   }
-  BOOST_REQUIRE_EQUAL(readyFDs.size(), 2);
+  BOOST_CHECK_EQUAL(readyFDs.size(), 2);
 
   readCBCalled = false;
   writeCBCalled = false;