On Thu, 12 Nov 2015 14:05:31 +0100 l...@gnu.org (Ludovic Courtès) wrote: > Efraim Flashner <efr...@flashner.co.il> skribis: > > >> In the end rebuilding c-ares with the release tarball and not the github > >> tarball fixed the issues with aria2 not recognizing c-ares. I wasn't able > >> to > >> get anything more out of aria2, more than it not finding the locations and > >> leaving me with with variables pointing to /path/to/dir and the like. > >> > > > > here's the end of the log file: > > > > ##Failure Location unknown## : Error > > Test name: N5aria224LpdMessageDispatcherTestE::testSendMessage > > uncaught exception of type N5aria29DlAbortExE > > - Failed to set a socket option, cause: No such device > > Could you check what this test does? The “No such device” is likely due > to our build environment not corresponding to the assumptions made by > the test wrt. available networking capabilities.
here's the failing line: std::shared_ptr<SocketCore> recvsock(new SocketCore(SOCK_DGRAM)); new SocketCore(SOCK_DGRAM) occurs only in LpdMessage{Dispatcher,Reciever}Test.cc and in SocketCoreTest.cc > > LpdMessageReceiverTest.cc:34:Assertion > > Test name: N5aria222LpdMessageReceiverTestE::testReceiveMessage > > assertion failed > > - Expression: rcv.init("") > > And this one is likely related to the one above. Looking at LpdMessageReceiver.h, I'm not sure that this is connected to the other failed test, or really why it failed. Or maybe it was supposed to fail for not passing an address, or it was supposed to be commented out since the line before it was created with an address and port. > TIA, > Ludo’. I'll keep staring at it, and hopefully it'll make sense soon :) -- Efraim Flashner <efr...@flashner.co.il> אפרים פלשנר GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted
#include "LpdMessageDispatcher.h" #include <cstring> #include <sstream> #include <cppunit/extensions/HelperMacros.h> #include "TestUtil.h" #include "Exception.h" #include "util.h" #include "LpdMessageDispatcher.h" #include "SocketCore.h" #include "BtConstants.h" namespace aria2 { class LpdMessageDispatcherTest:public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(LpdMessageDispatcherTest); CPPUNIT_TEST(testCreateLpdRequest); CPPUNIT_TEST(testSendMessage); CPPUNIT_TEST_SUITE_END(); public: void testCreateLpdRequest(); void testSendMessage(); }; CPPUNIT_TEST_SUITE_REGISTRATION(LpdMessageDispatcherTest); void LpdMessageDispatcherTest::testCreateLpdRequest() { std::string infoHashString = "cd41c7fdddfd034a15a04d7ff881216e01c4ceaf"; CPPUNIT_ASSERT_EQUAL (std::string("BT-SEARCH * HTTP/1.1\r\n" "Host: 239.192.152.143:6771\r\n" "Port: 6000\r\n" "Infohash: cd41c7fdddfd034a15a04d7ff881216e01c4ceaf\r\n" "\r\n\r\n"), bittorrent::createLpdRequest("239.192.152.143", 6771, fromHex(infoHashString), 6000)); } void LpdMessageDispatcherTest::testSendMessage() { std::shared_ptr<SocketCore> recvsock(new SocketCore(SOCK_DGRAM)); #ifdef __MINGW32__ recvsock->bindWithFamily(LPD_MULTICAST_PORT, AF_INET); #else // !__MINGW32__ recvsock->bind(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT, AF_INET); #endif // !__MINGW32__ recvsock->joinMulticastGroup(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT, ""); recvsock->setNonBlockingMode(); LpdMessageDispatcher d("cd41c7fdddfd034a15a04d7ff881216e01c4ceaf", 6000, LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT); d.init("", 0, 1); CPPUNIT_ASSERT(d.sendMessage()); unsigned char buf[200]; std::pair<std::string, uint16_t> peer; ssize_t nbytes; int trycnt; for(trycnt = 0; trycnt < 5; ++trycnt) { nbytes = recvsock->readDataFrom(buf, sizeof(buf), peer); if(nbytes == 0) { util::sleep(1); } else { break; } } if(trycnt == 5) { CPPUNIT_FAIL("[TIMEOUT] No Multicast packet received."); } buf[nbytes] = '\0'; std::stringstream temp; temp << "BT-SEARCH * HTTP/1.1\r\n" << "Host: " << LPD_MULTICAST_ADDR << ":" << LPD_MULTICAST_PORT << "\r\n" << "Port: " << d.getPort() << "\r\n" << "Infohash: " << util::toHex(d.getInfoHash()) << "\r\n" << "\r\n\r\n"; CPPUNIT_ASSERT_EQUAL(temp.str(), std::string(&buf[0], &buf[nbytes])); } } // namespace aria2
#include "LpdMessageReceiver.h" #include <cstring> #include <cppunit/extensions/HelperMacros.h> #include "TestUtil.h" #include "Exception.h" #include "util.h" #include "LpdMessageReceiver.h" #include "SocketCore.h" #include "BtConstants.h" #include "LpdMessage.h" #include "LpdMessageDispatcher.h" #include "Peer.h" namespace aria2 { class LpdMessageReceiverTest:public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(LpdMessageReceiverTest); CPPUNIT_TEST(testReceiveMessage); CPPUNIT_TEST_SUITE_END(); public: void testReceiveMessage(); }; CPPUNIT_TEST_SUITE_REGISTRATION(LpdMessageReceiverTest); void LpdMessageReceiverTest::testReceiveMessage() { LpdMessageReceiver rcv(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT); CPPUNIT_ASSERT(rcv.init("")); std::shared_ptr<SocketCore> sendsock(new SocketCore(SOCK_DGRAM)); sendsock->create(AF_INET); // Mingw32 build needs to set interface explicitly. sendsock->setMulticastInterface(""); sendsock->setMulticastTtl(0); std::string infoHashString = "cd41c7fdddfd034a15a04d7ff881216e01c4ceaf"; std::string infoHash = fromHex(infoHashString); std::string request = bittorrent::createLpdRequest(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT, infoHash, 6000); sendsock->writeData(request.c_str(), request.size(), LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT); rcv.getSocket()->isReadable(5); auto msg = rcv.receiveMessage(); CPPUNIT_ASSERT(msg); CPPUNIT_ASSERT_EQUAL(std::string("cd41c7fdddfd034a15a04d7ff881216e01c4ceaf"), util::toHex(msg->infoHash)); CPPUNIT_ASSERT_EQUAL((uint16_t)6000, msg->peer->getPort()); // Bad infohash std::string badInfoHashString = "cd41c7fdddfd034a15a04d7ff881216e01c4ce"; request = bittorrent::createLpdRequest(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT, fromHex(badInfoHashString), 6000); sendsock->writeData(request.c_str(), request.size(), LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT); rcv.getSocket()->isReadable(5); msg = rcv.receiveMessage(); CPPUNIT_ASSERT(!msg); // Bad port request = bittorrent::createLpdRequest(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT, infoHash, 0); sendsock->writeData(request.c_str(), request.size(), LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT); rcv.getSocket()->isReadable(5); msg = rcv.receiveMessage(); CPPUNIT_ASSERT(!msg); // No data available msg = rcv.receiveMessage(); CPPUNIT_ASSERT(!msg); } } // namespace aria2
/* * aria2 - The high speed download utility * * Copyright (C) 2010 Tatsuhiro Tsujikawa * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef D_LPD_MESSAGE_RECEIVER_H #define D_LPD_MESSAGE_RECEIVER_H #include "common.h" #include <string> #include <memory> namespace aria2 { class SocketCore; struct LpdMessage; class LpdMessageReceiver { private: std::shared_ptr<SocketCore> socket_; std::string multicastAddress_; uint16_t multicastPort_; std::string localAddress_; public: // Currently only IPv4 multicastAddresses are supported. LpdMessageReceiver (const std::string& multicastAddress, uint16_t multicastPort); ~LpdMessageReceiver(); // No throw. bool init(const std::string& localAddr); // Receives LPD message and returns LpdMessage which contains // sender(peer) and infohash. If no data is available on socket, // returns std::shared_ptr<LpdMessage>(). If received data is bad, // they are just skipped. std::unique_ptr<LpdMessage> receiveMessage(); const std::shared_ptr<SocketCore>& getSocket() const { return socket_; } const std::string& getLocalAddress() const { return localAddress_; } }; } // namespace aria2 #endif // D_LPD_MESSAGE_RECEIVER_H
pgpGpk7qPO8ww.pgp
Description: OpenPGP digital signature