From bdf0e1764b6f2a79006a0f4fe168c53292b01bac Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 11 May 2013 22:00:54 +0000 Subject: [PATCH] merged fixes from RC_0_16 --- src/create_torrent.cpp | 5 ++--- src/storage.cpp | 1 + test/Makefile.am | 6 ++++++ test/setup_transfer.cpp | 13 ++++++++----- test/test_rss.cpp | 4 ++++ test/test_torrent_parse.cpp | 4 ++-- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/create_torrent.cpp b/src/create_torrent.cpp index 169b90a4f..510007af5 100644 --- a/src/create_torrent.cpp +++ b/src/create_torrent.cpp @@ -194,10 +194,9 @@ namespace libtorrent , boost::function f, error_code& ec) { file_pool fp; + std::string path = complete(p); #if TORRENT_USE_UNC_PATHS - std::string path = canonicalize_path(p); -#else - std::string const& path = p; + path = canonicalize_path(path); #endif boost::scoped_ptr st( default_storage_constructor(const_cast(t.files()), 0, path, fp diff --git a/src/storage.cpp b/src/storage.cpp index 03ae6ee68..ccfe5de42 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -391,6 +391,7 @@ namespace libtorrent , m_page_size(page_size()) , m_allocate_files(false) { + TORRENT_ASSERT(is_complete(path)); if (mapped) m_mapped_files.reset(new file_storage(*mapped)); TORRENT_ASSERT(m_files.begin() != m_files.end()); diff --git a/test/Makefile.am b/test/Makefile.am index cef9d325e..dca796bac 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -79,6 +79,12 @@ EXTRA_DIST = Jamfile \ test_torrents/invalid_root_hash2.torrent \ test_torrents/root_hash.torrent \ test_torrents/invalid_file_size.torrent + eztv.xml \ + kat.xml \ + cb.xml \ + mn.xml \ + pb.xml \ + upnp.xml EXTRA_PROGRAMS = $(test_programs) diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 12b6cf731..2ac3bdbe8 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -65,11 +65,14 @@ bool tests_failure = false; void report_failure(char const* err, char const* file, int line) { -#if defined TORRENT_WINDOWS && defined TORRENT_MINGW - HANDLE console = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, 0, CONSOLE_TEXTMODE_BUFFER, 0); - SetConsoleTextAttribute(console, FOREGROUND_RED); - fprintf(stderr, "\n**** %s:%d \"%s\" ****\n\n", file, line, err); - CloseHandle(console); +#if defined TORRENT_WINDOWS + HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE); + SetConsoleTextAttribute(out, FOREGROUND_RED); + char buffer[1024]; + int len = snprintf(buffer, sizeof(buffer), "\n**** %s:%d \"%s\" ****\n\n", file, line, err); + DWORD written; + WriteFile(out, buffer, len, &written, NULL); + SetConsoleTextAttribute(out, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); #else fprintf(stderr, "\033[31m %s:%d \"%s\"\033[0m\n", file, line, err); #endif diff --git a/test/test_rss.cpp b/test/test_rss.cpp index 7cd9a8171..7767f8200 100644 --- a/test/test_rss.cpp +++ b/test/test_rss.cpp @@ -79,6 +79,10 @@ void test_feed(std::string const& filename, rss_expect const& expect) std::vector buffer; error_code ec; load_file(filename, buffer, ec); + if (ec) + { + fprintf(stderr, "failed to load file \"%s\": %s\n", filename.c_str(), ec.message().c_str()); + } TEST_CHECK(!ec); char* buf = &buffer[0]; diff --git a/test/test_torrent_parse.cpp b/test/test_torrent_parse.cpp index 3e1f9f864..981aa7639 100644 --- a/test/test_torrent_parse.cpp +++ b/test/test_torrent_parse.cpp @@ -127,8 +127,8 @@ int test_main() { // make sure we disambiguated the files TEST_EQUAL(ti->num_files(), 2); - TEST_CHECK(ti->file_at(0).path == "temp/foo/bar.txt"); - TEST_CHECK(ti->file_at(1).path == "temp/foo/bar.1.txt"); + TEST_CHECK(ti->file_at(0).path == combine_path(combine_path("temp", "foo"), "bar.txt")); + TEST_CHECK(ti->file_at(1).path == combine_path(combine_path("temp", "foo"), "bar.1.txt")); } else if (std::string(test_torrents[i].file) == "pad_file.torrent") {