big-endian fixes to test_primitives and more logging to track down error in test_dht

This commit is contained in:
Arvid Norberg 2013-06-23 01:22:44 +00:00
parent d376c6c636
commit 78da577e2b
2 changed files with 17 additions and 3 deletions

View File

@ -121,7 +121,9 @@ void send_dht_msg(node_impl& node, char const* msg, udp::endpoint const& ep
if (seq >= 0) a["seq"] = seq; if (seq >= 0) a["seq"] = seq;
char msg_buf[1500]; char msg_buf[1500];
int size = bencode(msg_buf, e); int size = bencode(msg_buf, e);
// std::cerr << "sending: " << e << "\n"; #if defined TORRENT_DEBUG && TORRENT_USE_IOSTREAM
std::cerr << "sending: " << e << "\n";
#endif
lazy_entry decoded; lazy_entry decoded;
error_code ec; error_code ec;
@ -202,9 +204,11 @@ void announce_immutable_items(node_impl& node, udp::endpoint const* eps
{ {
TEST_EQUAL(parsed[4]->string_value(), "r"); TEST_EQUAL(parsed[4]->string_value(), "r");
token = parsed[2]->string_value(); token = parsed[2]->string_value();
fprintf(stderr, "got token: %s\n", token.c_str());
} }
else else
{ {
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
fprintf(stderr, " invalid get response: %s\n", error_string); fprintf(stderr, " invalid get response: %s\n", error_string);
TEST_ERROR(error_string); TEST_ERROR(error_string);
} }
@ -225,14 +229,17 @@ void announce_immutable_items(node_impl& node, udp::endpoint const* eps
{ "y", lazy_entry::string_t, 1, 0 } { "y", lazy_entry::string_t, 1, 0 }
}; };
// fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
ret = verify_message(&response, desc2, parsed, 1, error_string, sizeof(error_string)); ret = verify_message(&response, desc2, parsed, 1, error_string, sizeof(error_string));
if (ret) if (ret)
{ {
if (parsed[0]->string_value() != "r")
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
TEST_EQUAL(parsed[0]->string_value(), "r"); TEST_EQUAL(parsed[0]->string_value(), "r");
} }
else else
{ {
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
fprintf(stderr, " invalid put response: %s\n", error_string); fprintf(stderr, " invalid put response: %s\n", error_string);
TEST_ERROR(error_string); TEST_ERROR(error_string);
} }
@ -374,9 +381,11 @@ int test_main()
{ {
TEST_CHECK(parsed[0]->string_value() == "r"); TEST_CHECK(parsed[0]->string_value() == "r");
token = parsed[2]->string_value(); token = parsed[2]->string_value();
fprintf(stderr, "got token: %s\n", token.c_str());
} }
else else
{ {
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
fprintf(stderr, " invalid get_peers response: %s\n", error_string); fprintf(stderr, " invalid get_peers response: %s\n", error_string);
} }
@ -414,9 +423,11 @@ int test_main()
{ {
TEST_CHECK(parsed[0]->string_value() == "r"); TEST_CHECK(parsed[0]->string_value() == "r");
token = parsed[2]->string_value(); token = parsed[2]->string_value();
fprintf(stderr, "got token: %s\n", token.c_str());
} }
else else
{ {
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
fprintf(stderr, " invalid get_peers response: %s\n", error_string); fprintf(stderr, " invalid get_peers response: %s\n", error_string);
} }
response.clear(); response.clear();
@ -560,9 +571,11 @@ int test_main()
{ {
TEST_EQUAL(parsed[4]->string_value(), "r"); TEST_EQUAL(parsed[4]->string_value(), "r");
token = parsed[2]->string_value(); token = parsed[2]->string_value();
fprintf(stderr, "got token: %s\n", token.c_str());
} }
else else
{ {
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
fprintf(stderr, " invalid get response: %s\n%s\n" fprintf(stderr, " invalid get response: %s\n%s\n"
, error_string, print_entry(response).c_str()); , error_string, print_entry(response).c_str());
TEST_ERROR(error_string); TEST_ERROR(error_string);

View File

@ -1294,7 +1294,8 @@ int test_main()
for (int i = 1; i < 255; ++i) for (int i = 1; i < 255; ++i)
{ {
bool hex = strchr(hex_chars, i) != NULL; bool hex = strchr(hex_chars, i) != NULL;
TEST_EQUAL(is_hex((char const*)&i, 1), hex); char c = i;
TEST_EQUAL(is_hex(&c, 1), hex);
} }
TEST_EQUAL(hex_to_int('0'), 0); TEST_EQUAL(hex_to_int('0'), 0);