From bc851d317f8e5e9d91c67e4129bd7539604df7a7 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 22 Mar 2012 01:48:17 +0000 Subject: [PATCH] work on test_web_seed --- src/storage.cpp | 2 ++ test/setup_transfer.cpp | 9 +++++++++ test/test_web_seed.cpp | 12 +++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/storage.cpp b/src/storage.cpp index aedafa969..ad74a034e 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -2821,7 +2821,9 @@ ret: if (m_storage_mode != internal_storage_mode_compact_deprecated) return piece_index; +#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS INVARIANT_CHECK; +#endif TORRENT_ASSERT(piece_index >= 0); TORRENT_ASSERT(piece_index < (int)m_piece_to_slot.size()); diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index dc2139e1c..612252599 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -956,6 +956,7 @@ void web_server_thread(int* port, bool ssl, bool chunked) } std::string path = p.path(); + fprintf(stderr, "%s\n", path.c_str()); if (path == "/redirect") { @@ -1098,6 +1099,14 @@ void web_server_thread(int* port, bool ssl, bool chunked) char eh[400]; snprintf(eh, sizeof(eh), "Content-Range: bytes %d-%d\r\n", start, end); extra_header[1] = eh; + if (end - start + 1 >= 1000) + { + fprintf(stderr, "request size: %.2f kB\n", int(end - start + 1)/1000.f); + } + else + { + fprintf(stderr, "request size: %d Bytes\n", int(end - start + 1)); + } send_response(s, ec, 206, "Partial", extra_header, end - start + 1); if (!file_buf.empty()) { diff --git a/test/test_web_seed.cpp b/test/test_web_seed.cpp index 2f1223cb4..2123202a9 100644 --- a/test/test_web_seed.cpp +++ b/test/test_web_seed.cpp @@ -220,7 +220,17 @@ int run_suite(char const* protocol, bool test_url_seed, bool chunked_encoding) std::generate(random_data, random_data + 300000, &std::rand); char filename[200]; snprintf(filename, sizeof(filename), "tmp1_web_seed/test_torrent_dir/test%d", i); - save_file(filename, random_data, file_sizes[i]); + int to_write = file_sizes[i]; + file f(filename, file::write_only, ec); + size_type offset = 0; + while (to_write > 0) + { + int s = (std::min)(to_write, 300000); + file::iovec_t b = { random_data, s}; + f.writev(offset, &b, 1, ec); + offset += s; + to_write -= s; + } } add_files(fs, "tmp1_web_seed/test_torrent_dir");