]> granicus.if.org Git - pdns/commitdiff
Add debug informations to the MPlexer unit tests, tracking a failure
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 17 Jun 2019 12:27:32 +0000 (14:27 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 17 Jun 2019 12:27:32 +0000 (14:27 +0200)
pdns/test-mplexer.cc

index 8a7412fea6a87403a0091c8d2b885b7f8e000584..f2ac639afc5ccf1b7b6391cfc6aac75c3b1106c2 100644 (file)
@@ -90,9 +90,9 @@ BOOST_AUTO_TEST_CASE(test_MPlexer) {
                         *calledPtr = true;
                 };
   mplexer->addReadFD(pipes[0],
-                      readCB,
-                      &readCBCalled,
-                      &ttd);
+                     readCB,
+                     &readCBCalled,
+                     &ttd);
 
   /* not ready for reading yet */
   readyFDs.clear();
@@ -124,6 +124,25 @@ BOOST_AUTO_TEST_CASE(test_MPlexer) {
   /* both should be available */
   readyFDs.clear();
   mplexer->getAvailableFDs(readyFDs, 0);
+  if (readyFDs.size() == 1) {
+    /* something is wrong, we need some debug infos */
+    cerr<<"FDMultiPlexer implementation is "<<mplexer->getName()<<endl;
+    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;
+    char buffer[2];
+    ssize_t res = read(pipes[0], &buffer[0], sizeof(buffer));
+    cerr<<"Reading from pipes[0] returns "<<res<<endl;
+    if (res == -1) {
+      cerr<<"errno is "<<errno<<endl;
+    }
+    res = write(pipes[1], "0", 1);
+    cerr<<"Writing to pipes[1] returns "<<res<<endl;
+    if (res == -1) {
+      cerr<<"errno is "<<errno<<endl;
+    }
+  }
   BOOST_REQUIRE_EQUAL(readyFDs.size(), 2);
 
   readCBCalled = false;