actually add a test to the unit test

This commit is contained in:
arvidn 2015-11-30 19:07:35 -05:00
parent 7540a6e5cc
commit 12dde0f415
3 changed files with 24 additions and 3 deletions

View File

@ -123,7 +123,7 @@ private:
typedef std::multimap<int, observer_ptr> transactions_t;
#endif
transactions_t m_transactions;
udp_socket_interface* m_sock;
dht_logger* m_log;
dht_settings const& m_settings;

View File

@ -7069,7 +7069,6 @@ retry:
{
va_list v;
va_start(v, fmt);
char usr[1024];
vsnprintf(usr, sizeof(usr), fmt, v);
va_end(v);

View File

@ -487,11 +487,21 @@ struct obs : dht::dht_observer
virtual void outgoing_get_peers(sha1_hash const& target
, sha1_hash const& sent_target, udp::endpoint const& ep) TORRENT_OVERRIDE {}
virtual void announce(sha1_hash const& ih, address const& addr, int port) TORRENT_OVERRIDE {}
virtual void log(dht_logger::module_t l, char const* fmt, ...) TORRENT_OVERRIDE {}
virtual void log(dht_logger::module_t l, char const* fmt, ...) TORRENT_OVERRIDE
{
va_list v;
va_start(v, fmt);
char buf[1024];
vsnprintf(buf, sizeof(buf), fmt, v);
va_end(v);
m_log.push_back(buf);
}
virtual void log_packet(message_direction_t dir, char const* pkt, int len
, udp::endpoint node) TORRENT_OVERRIDE {}
virtual bool on_dht_request(char const* query, int query_len
, dht::msg const& request, entry& response) TORRENT_OVERRIDE { return false; }
std::vector<std::string> m_log;
};
dht_settings test_settings()
@ -2382,6 +2392,18 @@ TORRENT_TEST(invalid_error_msg)
dht::msg m(decoded, source);
node.incoming(m);
bool found = false;
for (int i = 0; i < observer.m_log.size(); ++i)
{
if (observer.m_log[i].find("INCOMING ERROR")
&& observer.m_log[i].find("(malformed)"))
found = true;
printf("%s\n", observer.m_log[i].c_str());
}
TEST_EQUAL(found, false);
}
#endif