mirror of https://github.com/aria2/aria2
				
				
				
			Made `make distcheck' pass.
We added 2 macros A2_TEST_DIR and A2_TEST_OUT_DIR to pass tests in `make distcheck`. A2_TEST_DIR refers to test directory. All output files by unit tests are now created under A2_TEST_OUT_DIR directory.pull/1/head
							parent
							
								
									7ac1f17d56
								
							
						
					
					
						commit
						3ee6784b76
					
				| 
						 | 
				
			
			@ -294,6 +294,7 @@ SRCS += IteratableChunkChecksumValidator.cc IteratableChunkChecksumValidator.h\
 | 
			
		|||
	Checksum.cc Checksum.h\
 | 
			
		||||
	ChunkChecksum.cc ChunkChecksum.h\
 | 
			
		||||
	MessageDigest.cc MessageDigest.h\
 | 
			
		||||
	MessageDigestImpl.h\
 | 
			
		||||
	HashFuncEntry.h
 | 
			
		||||
endif # ENABLE_MESSAGE_DIGEST
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -559,7 +560,7 @@ aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
 | 
			
		|||
	@SQLITE3_LIBS@ #-lprofiler
 | 
			
		||||
#aria2c_LDFLAGS = -pg
 | 
			
		||||
AM_CPPFLAGS =  -Wall\
 | 
			
		||||
	-I../lib -I../intl -I$(top_srcdir)/intl\
 | 
			
		||||
	-I$(top_srcdir)/lib -I$(top_srcdir)/intl\
 | 
			
		||||
	@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
 | 
			
		||||
	@LIBCARES_CPPFLAGS@ @LIBEXPAT_CPPFLAGS@\
 | 
			
		||||
	@LIBZ_CPPFLAGS@	 @SQLITE3_CFLAGS@\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,7 +59,7 @@ typedef _off_t off_t;
 | 
			
		|||
#endif
 | 
			
		||||
#endif // __MINGW32__
 | 
			
		||||
 | 
			
		||||
#include "gettext.h"
 | 
			
		||||
#include <gettext.h>
 | 
			
		||||
#ifdef ENABLE_NLS
 | 
			
		||||
# define _(String) gettext(String)
 | 
			
		||||
#else // ENABLE_NLS
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,6 +8,7 @@
 | 
			
		|||
 | 
			
		||||
#include "Platform.h"
 | 
			
		||||
#include "SocketCore.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
 | 
			
		||||
int main(int argc, char* argv[]) {
 | 
			
		||||
  aria2::Platform platform;
 | 
			
		||||
| 
						 | 
				
			
			@ -27,6 +28,8 @@ int main(int argc, char* argv[]) {
 | 
			
		|||
  // If AI_ADDRCONFIG is set, tests fail if IPv4 address is not
 | 
			
		||||
  // configured.
 | 
			
		||||
  aria2::setDefaultAIFlags(0);
 | 
			
		||||
  // Create output directory
 | 
			
		||||
  aria2::util::mkdirs(A2_TEST_OUT_DIR);
 | 
			
		||||
 | 
			
		||||
  CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
 | 
			
		||||
  CppUnit::TextUi::TestRunner runner;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -132,7 +132,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(BittorrentHelperTest);
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testGetInfoHash() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  std::string correctHash = "248d0a1cd08284299de78d5c1ed359bb46717d8c";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -141,7 +141,7 @@ void BittorrentHelperTest::testGetInfoHash() {
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testGetPieceHash() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(util::toHex("AAAAAAAAAAAAAAAAAAAA", 20),
 | 
			
		||||
                       dctx->getPieceHash(0));
 | 
			
		||||
| 
						 | 
				
			
			@ -157,7 +157,7 @@ void BittorrentHelperTest::testGetPieceHash() {
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testGetFileEntries() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
  // This is multi-file torrent.
 | 
			
		||||
  std::vector<SharedHandle<FileEntry> > fileEntries = dctx->getFileEntries();
 | 
			
		||||
  // There are 2 file entries.
 | 
			
		||||
| 
						 | 
				
			
			@ -177,7 +177,7 @@ void BittorrentHelperTest::testGetFileEntries() {
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testGetFileEntriesSingle() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("single.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/single.torrent", dctx);
 | 
			
		||||
  // This is multi-file torrent.
 | 
			
		||||
  std::vector<SharedHandle<FileEntry> > fileEntries = dctx->getFileEntries();
 | 
			
		||||
  // There is 1 file entry.
 | 
			
		||||
| 
						 | 
				
			
			@ -193,42 +193,42 @@ void BittorrentHelperTest::testGetFileEntriesSingle() {
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testGetTotalLength() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((uint64_t)384ULL, dctx->getTotalLength());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BittorrentHelperTest::testGetTotalLengthSingle() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("single.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/single.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((uint64_t)384ULL, dctx->getTotalLength());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BittorrentHelperTest::testGetFileModeMulti() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(MULTI, getTorrentAttrs(dctx)->mode);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BittorrentHelperTest::testGetFileModeSingle() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("single.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/single.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(SINGLE, getTorrentAttrs(dctx)->mode);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BittorrentHelperTest::testGetNameMulti() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("aria2-test"), getTorrentAttrs(dctx)->name);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BittorrentHelperTest::testGetNameSingle() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("single.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/single.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("./aria2-0.8.2.tar.bz2"),
 | 
			
		||||
                       dctx->getBasePath());
 | 
			
		||||
| 
						 | 
				
			
			@ -239,7 +239,7 @@ void BittorrentHelperTest::testGetNameSingle() {
 | 
			
		|||
void BittorrentHelperTest::testOverrideName()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx, "aria2-override.name");
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx, "aria2-override.name");
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("./aria2-override.name"),
 | 
			
		||||
                       dctx->getBasePath());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("aria2-override.name"),
 | 
			
		||||
| 
						 | 
				
			
			@ -249,7 +249,7 @@ void BittorrentHelperTest::testOverrideName()
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testGetAnnounceTier() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("single.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/single.torrent", dctx);
 | 
			
		||||
  SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
 | 
			
		||||
  // There is 1 tier.
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)1, attrs->announceList.size());
 | 
			
		||||
| 
						 | 
				
			
			@ -261,7 +261,7 @@ void BittorrentHelperTest::testGetAnnounceTier() {
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testGetAnnounceTierAnnounceList() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
  SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
 | 
			
		||||
  // There are 3 tiers.
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)3, attrs->announceList.size());
 | 
			
		||||
| 
						 | 
				
			
			@ -281,14 +281,14 @@ void BittorrentHelperTest::testGetAnnounceTierAnnounceList() {
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testGetPieceLength() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)128, dctx->getPieceLength());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BittorrentHelperTest::testGetInfoHashAsString() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("248d0a1cd08284299de78d5c1ed359bb46717d8c"),
 | 
			
		||||
                       getInfoHashString(dctx));
 | 
			
		||||
| 
						 | 
				
			
			@ -336,7 +336,7 @@ void BittorrentHelperTest::testComputeFastSet()
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testGetFileEntries_multiFileUrlList() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("url-list-multiFile.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/url-list-multiFile.torrent", dctx);
 | 
			
		||||
  // This is multi-file torrent.
 | 
			
		||||
  const std::vector<SharedHandle<FileEntry> >& fileEntries =
 | 
			
		||||
    dctx->getFileEntries();
 | 
			
		||||
| 
						 | 
				
			
			@ -369,7 +369,7 @@ void BittorrentHelperTest::testGetFileEntries_multiFileUrlList() {
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testGetFileEntries_singleFileUrlList() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("url-list-singleFile.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/url-list-singleFile.torrent", dctx);
 | 
			
		||||
  // This is single-file torrent.
 | 
			
		||||
  const std::vector<SharedHandle<FileEntry> >& fileEntries =
 | 
			
		||||
    dctx->getFileEntries();
 | 
			
		||||
| 
						 | 
				
			
			@ -387,7 +387,7 @@ void BittorrentHelperTest::testGetFileEntries_singleFileUrlList() {
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testGetFileEntries_singleFileUrlListEndsWithSlash() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("url-list-singleFileEndsWithSlash.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/url-list-singleFileEndsWithSlash.torrent", dctx);
 | 
			
		||||
  // This is single-file torrent.
 | 
			
		||||
  const std::vector<SharedHandle<FileEntry> >& fileEntries =
 | 
			
		||||
    dctx->getFileEntries();
 | 
			
		||||
| 
						 | 
				
			
			@ -625,13 +625,13 @@ void BittorrentHelperTest::testGetNodes()
 | 
			
		|||
void BittorrentHelperTest::testGetBasePath()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> singleCtx(new DownloadContext());
 | 
			
		||||
  load("single.torrent", singleCtx);
 | 
			
		||||
  load(A2_TEST_DIR"/single.torrent", singleCtx);
 | 
			
		||||
  singleCtx->setFilePathWithIndex(1, "new-path");
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("new-path"), singleCtx->getBasePath());
 | 
			
		||||
 | 
			
		||||
  SharedHandle<DownloadContext> multiCtx(new DownloadContext());
 | 
			
		||||
  multiCtx->setDir("downloads");
 | 
			
		||||
  load("test.torrent", multiCtx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", multiCtx);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("downloads/aria2-test"),
 | 
			
		||||
                       multiCtx->getBasePath());
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -639,7 +639,7 @@ void BittorrentHelperTest::testGetBasePath()
 | 
			
		|||
void BittorrentHelperTest::testSetFileFilter_single()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("single.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/single.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT(dctx->getFirstFileEntry()->isRequested());
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -658,7 +658,7 @@ void BittorrentHelperTest::testSetFileFilter_single()
 | 
			
		|||
void BittorrentHelperTest::testSetFileFilter_multi()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT(dctx->getFileEntries()[0]->isRequested());
 | 
			
		||||
  CPPUNIT_ASSERT(dctx->getFileEntries()[1]->isRequested());
 | 
			
		||||
| 
						 | 
				
			
			@ -683,7 +683,7 @@ void BittorrentHelperTest::testSetFileFilter_multi()
 | 
			
		|||
void BittorrentHelperTest::testUTF8Torrent()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("utf8.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/utf8.torrent", dctx);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("name in utf-8"),
 | 
			
		||||
                       getTorrentAttrs(dctx)->name);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("./name in utf-8/path in utf-8"),
 | 
			
		||||
| 
						 | 
				
			
			@ -695,7 +695,7 @@ void BittorrentHelperTest::testUTF8Torrent()
 | 
			
		|||
void BittorrentHelperTest::testEtc()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("REDNOAH.COM RULES"),
 | 
			
		||||
                       getTorrentAttrs(dctx)->comment);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("aria2"),
 | 
			
		||||
| 
						 | 
				
			
			@ -726,8 +726,8 @@ void BittorrentHelperTest::testCheckBitfield()
 | 
			
		|||
 | 
			
		||||
void BittorrentHelperTest::testMetadata() {
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  std::string torrentData = readFile("test.torrent");
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
  std::string torrentData = readFile(A2_TEST_DIR"/test.torrent");
 | 
			
		||||
  SharedHandle<ValueBase> tr = bencode2::decode(torrentData);
 | 
			
		||||
  SharedHandle<ValueBase> infoDic = asDict(tr)->get("info");
 | 
			
		||||
  std::string metadata = bencode2::encode(infoDic);
 | 
			
		||||
| 
						 | 
				
			
			@ -796,7 +796,7 @@ void BittorrentHelperTest::testMetadata2Torrent()
 | 
			
		|||
void BittorrentHelperTest::testTorrent2Magnet()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  load("test.torrent", dctx);
 | 
			
		||||
  load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
  
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL
 | 
			
		||||
    (std::string("magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -85,10 +85,11 @@ CPPUNIT_TEST_SUITE_REGISTRATION( BtDependencyTest );
 | 
			
		|||
 | 
			
		||||
void BtDependencyTest::testResolve()
 | 
			
		||||
{
 | 
			
		||||
  std::string filename = "single.torrent";
 | 
			
		||||
  std::string filename = A2_TEST_DIR"/single.torrent";
 | 
			
		||||
  SharedHandle<RequestGroup> dependant = createDependant(option_);
 | 
			
		||||
  SharedHandle<RequestGroup> dependee =
 | 
			
		||||
    createDependee(option_, filename, File(filename).size());
 | 
			
		||||
  dependee->getPieceStorage()->getDiskAdaptor()->enableReadOnly();
 | 
			
		||||
  dependee->getPieceStorage()->markAllPiecesDone();
 | 
			
		||||
  
 | 
			
		||||
  BtDependency dep(dependant.get(), dependee);
 | 
			
		||||
| 
						 | 
				
			
			@ -107,12 +108,13 @@ void BtDependencyTest::testResolve()
 | 
			
		|||
 | 
			
		||||
void BtDependencyTest::testResolve_originalNameNoMatch()
 | 
			
		||||
{
 | 
			
		||||
  std::string filename = "single.torrent";
 | 
			
		||||
  std::string filename = A2_TEST_DIR"/single.torrent";
 | 
			
		||||
  SharedHandle<RequestGroup> dependant = createDependant(option_);
 | 
			
		||||
  dependant->getDownloadContext()->getFirstFileEntry()->setOriginalName
 | 
			
		||||
    ("aria2-1.1.0.tar.bz2");
 | 
			
		||||
  SharedHandle<RequestGroup> dependee =
 | 
			
		||||
    createDependee(option_, filename, File(filename).size());
 | 
			
		||||
  dependee->getPieceStorage()->getDiskAdaptor()->enableReadOnly();
 | 
			
		||||
  dependee->getPieceStorage()->markAllPiecesDone();
 | 
			
		||||
  
 | 
			
		||||
  BtDependency dep(dependant.get(), dependee);
 | 
			
		||||
| 
						 | 
				
			
			@ -124,11 +126,12 @@ void BtDependencyTest::testResolve_originalNameNoMatch()
 | 
			
		|||
 | 
			
		||||
void BtDependencyTest::testResolve_singleFileWithoutOriginalName()
 | 
			
		||||
{
 | 
			
		||||
  std::string filename = "single.torrent";
 | 
			
		||||
  std::string filename = A2_TEST_DIR"/single.torrent";
 | 
			
		||||
  SharedHandle<RequestGroup> dependant = createDependant(option_);
 | 
			
		||||
  dependant->getDownloadContext()->getFirstFileEntry()->setOriginalName("");
 | 
			
		||||
  SharedHandle<RequestGroup> dependee =
 | 
			
		||||
    createDependee(option_, filename, File(filename).size());
 | 
			
		||||
  dependee->getPieceStorage()->getDiskAdaptor()->enableReadOnly();
 | 
			
		||||
  dependee->getPieceStorage()->markAllPiecesDone();
 | 
			
		||||
  BtDependency dep(dependant.get(), dependee);
 | 
			
		||||
  CPPUNIT_ASSERT(dep.resolve());
 | 
			
		||||
| 
						 | 
				
			
			@ -138,12 +141,13 @@ void BtDependencyTest::testResolve_singleFileWithoutOriginalName()
 | 
			
		|||
 | 
			
		||||
void BtDependencyTest::testResolve_multiFile()
 | 
			
		||||
{
 | 
			
		||||
  std::string filename = "test.torrent";
 | 
			
		||||
  std::string filename = A2_TEST_DIR"/test.torrent";
 | 
			
		||||
  SharedHandle<RequestGroup> dependant = createDependant(option_);
 | 
			
		||||
  dependant->getDownloadContext()->getFirstFileEntry()->setOriginalName
 | 
			
		||||
    ("aria2-test/aria2/src/aria2c");
 | 
			
		||||
  SharedHandle<RequestGroup> dependee =
 | 
			
		||||
    createDependee(option_, filename, File(filename).size());
 | 
			
		||||
  dependee->getPieceStorage()->getDiskAdaptor()->enableReadOnly();
 | 
			
		||||
  dependee->getPieceStorage()->markAllPiecesDone();
 | 
			
		||||
  
 | 
			
		||||
  BtDependency dep(dependant.get(), dependee);
 | 
			
		||||
| 
						 | 
				
			
			@ -224,7 +228,7 @@ void BtDependencyTest::testResolve_dependeeFailure()
 | 
			
		|||
 | 
			
		||||
void BtDependencyTest::testResolve_dependeeInProgress()
 | 
			
		||||
{
 | 
			
		||||
  std::string filename = "single.torrent";
 | 
			
		||||
  std::string filename = A2_TEST_DIR"/single.torrent";
 | 
			
		||||
  SharedHandle<RequestGroup> dependant = createDependant(option_);
 | 
			
		||||
  SharedHandle<RequestGroup> dependee =
 | 
			
		||||
    createDependee(option_, filename, File(filename).size());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,6 +7,8 @@
 | 
			
		|||
#include "Option.h"
 | 
			
		||||
#include "FileEntry.h"
 | 
			
		||||
#include "bittorrent_helper.h"
 | 
			
		||||
#include "PieceStorage.h"
 | 
			
		||||
#include "DiskAdaptor.h"
 | 
			
		||||
 | 
			
		||||
namespace aria2 {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +37,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION( BtPostDownloadHandlerTest );
 | 
			
		|||
 | 
			
		||||
void BtPostDownloadHandlerTest::testCanHandle_extension()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext(0, 0, "test.torrent"));
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(0, 0, A2_TEST_DIR"/test.torrent"));
 | 
			
		||||
  RequestGroup rg(option_);
 | 
			
		||||
  rg.setDownloadContext(dctx);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +46,7 @@ void BtPostDownloadHandlerTest::testCanHandle_extension()
 | 
			
		|||
 | 
			
		||||
  CPPUNIT_ASSERT(handler.canHandle(&rg));
 | 
			
		||||
 | 
			
		||||
  dctx->getFirstFileEntry()->setPath("test.torrent2");
 | 
			
		||||
  dctx->getFirstFileEntry()->setPath(A2_TEST_DIR"/test.torrent2");
 | 
			
		||||
  CPPUNIT_ASSERT(!handler.canHandle(&rg));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -65,10 +68,11 @@ void BtPostDownloadHandlerTest::testCanHandle_contentType()
 | 
			
		|||
void BtPostDownloadHandlerTest::testGetNextRequestGroups()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(1024, 0, "test.torrent"));
 | 
			
		||||
    (new DownloadContext(1024, 0, A2_TEST_DIR"/test.torrent"));
 | 
			
		||||
  RequestGroup rg(option_);
 | 
			
		||||
  rg.setDownloadContext(dctx);
 | 
			
		||||
  rg.initPieceStorage();
 | 
			
		||||
  rg.getPieceStorage()->getDiskAdaptor()->enableReadOnly();
 | 
			
		||||
 | 
			
		||||
  BtPostDownloadHandler handler;
 | 
			
		||||
  std::vector<SharedHandle<RequestGroup> > groups;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -260,7 +260,7 @@ void CookieStorageTest::testLoad()
 | 
			
		|||
{
 | 
			
		||||
  CookieStorage st;
 | 
			
		||||
 | 
			
		||||
  st.load("nscookietest.txt", 1001);
 | 
			
		||||
  st.load(A2_TEST_DIR"/nscookietest.txt", 1001);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)4, st.size());
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -310,7 +310,7 @@ void CookieStorageTest::testLoad_sqlite3()
 | 
			
		|||
{
 | 
			
		||||
  CookieStorage st;
 | 
			
		||||
#ifdef HAVE_SQLITE3
 | 
			
		||||
  st.load("cookies.sqlite", 1000);
 | 
			
		||||
  st.load(A2_TEST_DIR"/cookies.sqlite", 1000);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
 | 
			
		||||
  std::vector<Cookie> cookies;
 | 
			
		||||
  dumpCookie(cookies, st);
 | 
			
		||||
| 
						 | 
				
			
			@ -335,7 +335,7 @@ void CookieStorageTest::testLoad_sqlite3()
 | 
			
		|||
  CPPUNIT_ASSERT(!c.getSecure());
 | 
			
		||||
    
 | 
			
		||||
#else // !HAVE_SQLITE3
 | 
			
		||||
  CPPUNIT_ASSERT(!st.load("cookies.sqlite", 1000));
 | 
			
		||||
  CPPUNIT_ASSERT(!st.load(A2_TEST_DIR"/cookies.sqlite", 1000));
 | 
			
		||||
#endif // !HAVE_SQLITE3
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -348,7 +348,7 @@ void CookieStorageTest::testLoad_fileNotfound()
 | 
			
		|||
void CookieStorageTest::testSaveNsFormat()
 | 
			
		||||
{
 | 
			
		||||
  // TODO add cookie with default domain
 | 
			
		||||
  std::string filename = "./aria2_CookieStorageTest_testSaveNsFormat";
 | 
			
		||||
  std::string filename = A2_TEST_OUT_DIR"/aria2_CookieStorageTest_testSaveNsFormat";
 | 
			
		||||
  File(filename).remove();
 | 
			
		||||
  CookieStorage st;
 | 
			
		||||
  time_t now = 1000;
 | 
			
		||||
| 
						 | 
				
			
			@ -370,7 +370,8 @@ void CookieStorageTest::testSaveNsFormat()
 | 
			
		|||
 | 
			
		||||
void CookieStorageTest::testSaveNsFormat_fail()
 | 
			
		||||
{
 | 
			
		||||
  std::string filename = "./aria2_CookieStorageTest_testSaveNsFormat_fail";
 | 
			
		||||
  std::string filename =
 | 
			
		||||
    A2_TEST_OUT_DIR"/aria2_CookieStorageTest_testSaveNsFormat_fail";
 | 
			
		||||
  File f(filename);
 | 
			
		||||
  f.remove();
 | 
			
		||||
  f.mkdirs();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -140,7 +140,7 @@ public:
 | 
			
		|||
    rg_.reset(new RequestGroup(option_));
 | 
			
		||||
 | 
			
		||||
    dctx_.reset(new DownloadContext());
 | 
			
		||||
    bittorrent::load("test.torrent", dctx_);
 | 
			
		||||
    bittorrent::load(A2_TEST_DIR"/test.torrent", dctx_);
 | 
			
		||||
 | 
			
		||||
    rg_->setDownloadContext(dctx_);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,7 +56,7 @@ public:
 | 
			
		|||
  void initializeMembers(int32_t pieceLength, int64_t totalLength)
 | 
			
		||||
  {
 | 
			
		||||
    option_.reset(new Option());
 | 
			
		||||
    option_->put(PREF_DIR, ".");
 | 
			
		||||
    option_->put(PREF_DIR, A2_TEST_OUT_DIR);
 | 
			
		||||
 | 
			
		||||
    bitfield_.reset(new BitfieldMan(pieceLength, totalLength));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -113,13 +113,14 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DefaultBtProgressInfoFileTest);
 | 
			
		|||
void DefaultBtProgressInfoFileTest::testLoad_compat()
 | 
			
		||||
{
 | 
			
		||||
  initializeMembers(1024, 81920);
 | 
			
		||||
  dctx_->setBasePath("load");
 | 
			
		||||
  dctx_->setBasePath(A2_TEST_DIR"/load");
 | 
			
		||||
 | 
			
		||||
  DefaultBtProgressInfoFile infoFile(dctx_, pieceStorage_, option_.get());
 | 
			
		||||
  infoFile.setBtRuntime(btRuntime_);
 | 
			
		||||
  infoFile.setPeerStorage(peerStorage_);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("load.aria2"), infoFile.getFilename());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string(A2_TEST_DIR"/load.aria2"),
 | 
			
		||||
                       infoFile.getFilename());
 | 
			
		||||
 | 
			
		||||
  infoFile.load();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -162,10 +163,10 @@ void DefaultBtProgressInfoFileTest::testLoad()
 | 
			
		|||
{
 | 
			
		||||
  initializeMembers(1024, 81920);
 | 
			
		||||
 | 
			
		||||
  dctx_->setBasePath("load-v0001");
 | 
			
		||||
  dctx_->setBasePath(A2_TEST_DIR"/load-v0001");
 | 
			
		||||
 | 
			
		||||
  DefaultBtProgressInfoFile infoFile(dctx_, pieceStorage_, option_.get());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("load-v0001.aria2"),
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string(A2_TEST_DIR"/load-v0001.aria2"),
 | 
			
		||||
                       infoFile.getFilename());
 | 
			
		||||
  infoFile.setBtRuntime(btRuntime_);
 | 
			
		||||
  infoFile.setPeerStorage(peerStorage_);
 | 
			
		||||
| 
						 | 
				
			
			@ -210,7 +211,7 @@ void DefaultBtProgressInfoFileTest::testSave()
 | 
			
		|||
{
 | 
			
		||||
  initializeMembers(1024, 81920);
 | 
			
		||||
 | 
			
		||||
  dctx_->setBasePath("save-temp");
 | 
			
		||||
  dctx_->setBasePath(A2_TEST_OUT_DIR"/save-temp");
 | 
			
		||||
  bitfield_->setAllBit();
 | 
			
		||||
  bitfield_->unsetBit(79);
 | 
			
		||||
  pieceStorage_->setCompletedLength(80896);
 | 
			
		||||
| 
						 | 
				
			
			@ -229,7 +230,7 @@ void DefaultBtProgressInfoFileTest::testSave()
 | 
			
		|||
  infoFile.setBtRuntime(btRuntime_);
 | 
			
		||||
  infoFile.setPeerStorage(peerStorage_);
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("save-temp.aria2"),
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string(A2_TEST_OUT_DIR"/save-temp.aria2"),
 | 
			
		||||
                       infoFile.getFilename());
 | 
			
		||||
 | 
			
		||||
  infoFile.save();
 | 
			
		||||
| 
						 | 
				
			
			@ -332,11 +333,11 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt_compat()
 | 
			
		|||
  initializeMembers(1024, 81920);
 | 
			
		||||
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(1024, 81920, "load-nonBt"));
 | 
			
		||||
    (new DownloadContext(1024, 81920, A2_TEST_DIR"/load-nonBt"));
 | 
			
		||||
  
 | 
			
		||||
  DefaultBtProgressInfoFile infoFile(dctx, pieceStorage_, option_.get());
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("load-nonBt.aria2"),
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string(A2_TEST_DIR"/load-nonBt.aria2"),
 | 
			
		||||
                       infoFile.getFilename());
 | 
			
		||||
  infoFile.load();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -377,11 +378,11 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt()
 | 
			
		|||
  initializeMembers(1024, 81920);
 | 
			
		||||
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(1024, 81920, "load-nonBt-v0001"));
 | 
			
		||||
    (new DownloadContext(1024, 81920, A2_TEST_DIR"/load-nonBt-v0001"));
 | 
			
		||||
  
 | 
			
		||||
  DefaultBtProgressInfoFile infoFile(dctx, pieceStorage_, option_.get());
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("load-nonBt-v0001.aria2"),
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string(A2_TEST_DIR"/load-nonBt-v0001.aria2"),
 | 
			
		||||
                       infoFile.getFilename());
 | 
			
		||||
  infoFile.load();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -422,11 +423,11 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt_pieceLengthShorter()
 | 
			
		|||
  option_->put(PREF_ALLOW_PIECE_LENGTH_CHANGE, A2_V_TRUE);
 | 
			
		||||
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(512, 81920, "load-nonBt-v0001"));
 | 
			
		||||
    (new DownloadContext(512, 81920, A2_TEST_DIR"/load-nonBt-v0001"));
 | 
			
		||||
 | 
			
		||||
  DefaultBtProgressInfoFile infoFile(dctx, pieceStorage_, option_.get());
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("load-nonBt-v0001.aria2"),
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string(A2_TEST_DIR"/load-nonBt-v0001.aria2"),
 | 
			
		||||
                       infoFile.getFilename());
 | 
			
		||||
  infoFile.load();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -447,7 +448,7 @@ void DefaultBtProgressInfoFileTest::testSave_nonBt()
 | 
			
		|||
  initializeMembers(1024, 81920);
 | 
			
		||||
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(1024, 81920, "save-temp"));
 | 
			
		||||
    (new DownloadContext(1024, 81920, A2_TEST_OUT_DIR"/save-temp"));
 | 
			
		||||
 | 
			
		||||
  bitfield_->setAllBit();
 | 
			
		||||
  bitfield_->unsetBit(79);
 | 
			
		||||
| 
						 | 
				
			
			@ -462,7 +463,7 @@ void DefaultBtProgressInfoFileTest::testSave_nonBt()
 | 
			
		|||
  
 | 
			
		||||
  DefaultBtProgressInfoFile infoFile(dctx, pieceStorage_, option_.get());
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("save-temp.aria2"),
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string(A2_TEST_OUT_DIR"/save-temp.aria2"),
 | 
			
		||||
                       infoFile.getFilename());
 | 
			
		||||
 | 
			
		||||
  infoFile.save();
 | 
			
		||||
| 
						 | 
				
			
			@ -554,7 +555,7 @@ void DefaultBtProgressInfoFileTest::testSave_nonBt()
 | 
			
		|||
void DefaultBtProgressInfoFileTest::testUpdateFilename()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(1024, 81920, "./file1"));
 | 
			
		||||
    (new DownloadContext(1024, 81920, A2_TEST_DIR"/file1"));
 | 
			
		||||
 | 
			
		||||
  DefaultBtProgressInfoFile infoFile(dctx, SharedHandle<MockPieceStorage>(), 0);
 | 
			
		||||
#ifdef ENABLE_BITTORRENT
 | 
			
		||||
| 
						 | 
				
			
			@ -562,15 +563,18 @@ void DefaultBtProgressInfoFileTest::testUpdateFilename()
 | 
			
		|||
  infoFile.setPeerStorage(peerStorage_);
 | 
			
		||||
#endif // ENABLE_BITTORRENT
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("./file1.aria2"), infoFile.getFilename());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string(A2_TEST_DIR"/file1.aria2"),
 | 
			
		||||
                       infoFile.getFilename());
 | 
			
		||||
 | 
			
		||||
  dctx->getFirstFileEntry()->setPath("./file1.1");
 | 
			
		||||
  dctx->getFirstFileEntry()->setPath(A2_TEST_DIR"/file1.1");
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("./file1.aria2"), infoFile.getFilename());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string(A2_TEST_DIR"/file1.aria2"),
 | 
			
		||||
                       infoFile.getFilename());
 | 
			
		||||
 | 
			
		||||
  infoFile.updateFilename();
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("./file1.1.aria2"), infoFile.getFilename());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string(A2_TEST_DIR"/file1.1.aria2"),
 | 
			
		||||
                       infoFile.getFilename());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace aria2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION( DefaultDiskWriterTest );
 | 
			
		|||
 | 
			
		||||
void DefaultDiskWriterTest::testSize()
 | 
			
		||||
{
 | 
			
		||||
  DefaultDiskWriter dw("4096chunk.txt");
 | 
			
		||||
  DefaultDiskWriter dw(A2_TEST_DIR"/4096chunk.txt");
 | 
			
		||||
  dw.enableReadOnly();
 | 
			
		||||
  dw.openExistingFile();
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((uint64_t)4096ULL, dw.size());
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,7 +46,7 @@ private:
 | 
			
		|||
public:
 | 
			
		||||
  void setUp() {
 | 
			
		||||
    dctx_.reset(new DownloadContext());
 | 
			
		||||
    bittorrent::load("test.torrent", dctx_);
 | 
			
		||||
    bittorrent::load(A2_TEST_DIR"/test.torrent", dctx_);
 | 
			
		||||
    peer.reset(new Peer("192.168.0.1", 6889));
 | 
			
		||||
    peer->allocateSessionResource(dctx_->getPieceLength(),
 | 
			
		||||
                                  dctx_->getTotalLength());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DirectDiskAdaptorTest);
 | 
			
		|||
 | 
			
		||||
void DirectDiskAdaptorTest::testCutTrailingGarbage()
 | 
			
		||||
{
 | 
			
		||||
  std::string dir = "./";
 | 
			
		||||
  std::string dir = A2_TEST_OUT_DIR;
 | 
			
		||||
  SharedHandle<FileEntry> entry
 | 
			
		||||
    (new FileEntry(dir+"/aria2_DirectDiskAdaptorTest_testCutTrailingGarbage",
 | 
			
		||||
                   256, 0));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -83,7 +83,8 @@ void DownloadHandlerFactoryTest::testGetMetalinkPreDownloadHandler_contentType()
 | 
			
		|||
 | 
			
		||||
void DownloadHandlerFactoryTest::testGetBtPreDownloadHandler_extension()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext(0, 0, "test.torrent"));
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(0, 0, A2_TEST_DIR"/test.torrent"));
 | 
			
		||||
  RequestGroup rg(option_);
 | 
			
		||||
  rg.setDownloadContext(dctx);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -91,7 +92,7 @@ void DownloadHandlerFactoryTest::testGetBtPreDownloadHandler_extension()
 | 
			
		|||
 | 
			
		||||
  CPPUNIT_ASSERT(handler->canHandle(&rg));
 | 
			
		||||
 | 
			
		||||
  dctx->getFirstFileEntry()->setPath("test.torrent2");
 | 
			
		||||
  dctx->getFirstFileEntry()->setPath(A2_TEST_DIR"/test.torrent2");
 | 
			
		||||
  CPPUNIT_ASSERT(!handler->canHandle(&rg));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -181,7 +181,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_BitTorrent()
 | 
			
		|||
{
 | 
			
		||||
  std::string array[] = {
 | 
			
		||||
    "http://alpha/file",
 | 
			
		||||
    "test.torrent",
 | 
			
		||||
    A2_TEST_DIR"/test.torrent",
 | 
			
		||||
    "http://bravo/file",
 | 
			
		||||
    "http://charlie/file"
 | 
			
		||||
  };
 | 
			
		||||
| 
						 | 
				
			
			@ -232,7 +232,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink()
 | 
			
		|||
    "http://alpha/file",
 | 
			
		||||
    "http://bravo/file",
 | 
			
		||||
    "http://charlie/file",
 | 
			
		||||
    "test.xml"
 | 
			
		||||
    A2_TEST_DIR"/test.xml"
 | 
			
		||||
  };
 | 
			
		||||
  std::vector<std::string> uris(vbegin(array), vend(array));
 | 
			
		||||
  option_->put(PREF_MAX_CONNECTION_PER_SERVER, "1");
 | 
			
		||||
| 
						 | 
				
			
			@ -286,7 +286,7 @@ void DownloadHelperTest::testCreateRequestGroupForUriList()
 | 
			
		|||
{
 | 
			
		||||
  option_->put(PREF_MAX_CONNECTION_PER_SERVER, "3");
 | 
			
		||||
  option_->put(PREF_SPLIT, "3");
 | 
			
		||||
  option_->put(PREF_INPUT_FILE, "input_uris.txt");
 | 
			
		||||
  option_->put(PREF_INPUT_FILE, A2_TEST_DIR"/input_uris.txt");
 | 
			
		||||
  option_->put(PREF_DIR, "/tmp");
 | 
			
		||||
  option_->put(PREF_OUT, "file.out");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -327,7 +327,7 @@ void DownloadHelperTest::testCreateRequestGroupForBitTorrent()
 | 
			
		|||
  std::vector<std::string> auxURIs(vbegin(array), vend(array));
 | 
			
		||||
  option_->put(PREF_MAX_CONNECTION_PER_SERVER, "2");
 | 
			
		||||
  option_->put(PREF_SPLIT, "5");
 | 
			
		||||
  option_->put(PREF_TORRENT_FILE, "test.torrent");
 | 
			
		||||
  option_->put(PREF_TORRENT_FILE, A2_TEST_DIR"/test.torrent");
 | 
			
		||||
  option_->put(PREF_DIR, "/tmp");
 | 
			
		||||
  option_->put(PREF_OUT, "file.out");
 | 
			
		||||
  option_->put(PREF_BT_EXCLUDE_TRACKER, "http://tracker1");
 | 
			
		||||
| 
						 | 
				
			
			@ -381,7 +381,7 @@ void DownloadHelperTest::testCreateRequestGroupForBitTorrent()
 | 
			
		|||
void DownloadHelperTest::testCreateRequestGroupForMetalink()
 | 
			
		||||
{
 | 
			
		||||
  option_->put(PREF_SPLIT, "3");
 | 
			
		||||
  option_->put(PREF_METALINK_FILE, "test.xml");
 | 
			
		||||
  option_->put(PREF_METALINK_FILE, A2_TEST_DIR"/test.xml");
 | 
			
		||||
  option_->put(PREF_METALINK_SERVERS, "5");
 | 
			
		||||
  option_->put(PREF_DIR, "/tmp");
 | 
			
		||||
  option_->put(PREF_OUT, "file.out");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,8 @@
 | 
			
		|||
#include <cppunit/extensions/HelperMacros.h>
 | 
			
		||||
 | 
			
		||||
#include "DownloadFailureException.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "A2STR.h"
 | 
			
		||||
 | 
			
		||||
namespace aria2 {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -33,10 +35,10 @@ void ExceptionTest::testStackTrace()
 | 
			
		|||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL
 | 
			
		||||
    (std::string
 | 
			
		||||
     ("Exception: [ExceptionTest.cc:32] errorCode=2 exception thrown\n"
 | 
			
		||||
      "  -> [ExceptionTest.cc:30] errorCode=2 cause2\n"
 | 
			
		||||
      "  -> [ExceptionTest.cc:29] errorCode=2 cause1\n"),
 | 
			
		||||
     e.stackTrace());
 | 
			
		||||
     ("Exception: [ExceptionTest.cc:34] errorCode=2 exception thrown\n"
 | 
			
		||||
      "  -> [ExceptionTest.cc:32] errorCode=2 cause2\n"
 | 
			
		||||
      "  -> [ExceptionTest.cc:31] errorCode=2 cause1\n"),
 | 
			
		||||
     util::replace(e.stackTrace(), A2_TEST_DIR+A2STR::SLASH_C, ""));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace aria2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,41 +45,41 @@ public:
 | 
			
		|||
CPPUNIT_TEST_SUITE_REGISTRATION( FileTest );
 | 
			
		||||
 | 
			
		||||
void FileTest::testExists() {
 | 
			
		||||
  File f("FileTest.cc");
 | 
			
		||||
  File f(A2_TEST_DIR"/FileTest.cc");
 | 
			
		||||
  CPPUNIT_ASSERT(f.exists());
 | 
			
		||||
 | 
			
		||||
  File f2("NonExistentFile");
 | 
			
		||||
  CPPUNIT_ASSERT(!f2.exists());
 | 
			
		||||
 | 
			
		||||
  File d1("../test");
 | 
			
		||||
  File d1(A2_TEST_DIR);
 | 
			
		||||
  CPPUNIT_ASSERT(d1.exists());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FileTest::testIsFile() {
 | 
			
		||||
  File f("FileTest.cc");
 | 
			
		||||
  File f(A2_TEST_DIR"/FileTest.cc");
 | 
			
		||||
  CPPUNIT_ASSERT(f.isFile());
 | 
			
		||||
 | 
			
		||||
  File f2("NonExistentFile");
 | 
			
		||||
  CPPUNIT_ASSERT(!f2.isFile());
 | 
			
		||||
 | 
			
		||||
  File d1("../test");
 | 
			
		||||
  File d1(A2_TEST_DIR);
 | 
			
		||||
  CPPUNIT_ASSERT(!d1.isFile());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FileTest::testIsDir() {
 | 
			
		||||
  File f("FileTest.cc");
 | 
			
		||||
  File f(A2_TEST_DIR"/FileTest.cc");
 | 
			
		||||
  CPPUNIT_ASSERT(!f.isDir());
 | 
			
		||||
 | 
			
		||||
  File f2("NonExistentFile");
 | 
			
		||||
  CPPUNIT_ASSERT(!f2.isDir());
 | 
			
		||||
 | 
			
		||||
  File d1("../test");
 | 
			
		||||
  File d1(A2_TEST_DIR);
 | 
			
		||||
  CPPUNIT_ASSERT(d1.isDir());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FileTest::testRemove() {
 | 
			
		||||
  int fd;
 | 
			
		||||
  std::string name = "./aria2_FileTest_testRemove_testregfile";
 | 
			
		||||
  std::string name = A2_TEST_OUT_DIR"/aria2_FileTest_testRemove_testregfile";
 | 
			
		||||
  unlink(name.c_str());
 | 
			
		||||
  if((fd = creat(name.c_str(), S_IRUSR|S_IWUSR)) < 0) {
 | 
			
		||||
    CPPUNIT_FAIL("cannot create test file");
 | 
			
		||||
| 
						 | 
				
			
			@ -92,7 +92,7 @@ void FileTest::testRemove() {
 | 
			
		|||
  // delete the file again
 | 
			
		||||
  CPPUNIT_ASSERT(!f.remove());
 | 
			
		||||
 | 
			
		||||
  std::string dir = "./aria2_FileTest_testRemove_testdir";
 | 
			
		||||
  std::string dir = A2_TEST_OUT_DIR"/aria2_FileTest_testRemove_testdir";
 | 
			
		||||
#ifdef __MINGW32__
 | 
			
		||||
  mkdir(dir.c_str());
 | 
			
		||||
#else
 | 
			
		||||
| 
						 | 
				
			
			@ -107,13 +107,13 @@ void FileTest::testRemove() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
void FileTest::testSize() {
 | 
			
		||||
  File f("4096chunk.txt");
 | 
			
		||||
  File f(A2_TEST_DIR"/4096chunk.txt");
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(4096, (int)f.size());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FileTest::testMkdir() {
 | 
			
		||||
  {
 | 
			
		||||
    std::string dir = "./aria2_FileTest_testMkdir/test";
 | 
			
		||||
    std::string dir = A2_TEST_OUT_DIR"/aria2_FileTest_testMkdir/test";
 | 
			
		||||
    File d(dir);
 | 
			
		||||
    if(d.exists()) {
 | 
			
		||||
      CPPUNIT_ASSERT(d.remove());
 | 
			
		||||
| 
						 | 
				
			
			@ -128,8 +128,8 @@ void FileTest::testMkdir() {
 | 
			
		|||
    CPPUNIT_ASSERT(!d.mkdirs());
 | 
			
		||||
  }
 | 
			
		||||
  {
 | 
			
		||||
    std::string dir = ".////aria2_FileTest_testMkdir////test2///";
 | 
			
		||||
    std::string nDir = "./aria2_FileTest_testMkdir/test2";
 | 
			
		||||
    std::string dir = A2_TEST_OUT_DIR"////aria2_FileTest_testMkdir////test2///";
 | 
			
		||||
    std::string nDir = A2_TEST_OUT_DIR"/aria2_FileTest_testMkdir/test2";
 | 
			
		||||
    File d(dir);
 | 
			
		||||
    File nd(nDir);
 | 
			
		||||
    if(d.exists()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -212,16 +212,16 @@ void FileTest::testGetBasename()
 | 
			
		|||
 | 
			
		||||
void FileTest::testRenameTo()
 | 
			
		||||
{
 | 
			
		||||
  std::string fname = "aria2_FileTest_testRenameTo.txt";
 | 
			
		||||
  std::string fname = A2_TEST_OUT_DIR"/aria2_FileTest_testRenameTo.txt";
 | 
			
		||||
  std::ofstream of(fname.c_str(), std::ios::binary);
 | 
			
		||||
  of.close();
 | 
			
		||||
 | 
			
		||||
  File f(fname);
 | 
			
		||||
  std::string fnameTo = "aria2_FileTest_testRenameTo_dest.txt";
 | 
			
		||||
  std::string fnameTo = A2_TEST_OUT_DIR"/aria2_FileTest_testRenameTo_dest.txt";
 | 
			
		||||
  CPPUNIT_ASSERT(f.renameTo(fnameTo));
 | 
			
		||||
  CPPUNIT_ASSERT(f.exists());
 | 
			
		||||
  CPPUNIT_ASSERT(!File(fname).exists());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(fnameTo, f.getBasename());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(File(fnameTo).getBasename(), f.getBasename());
 | 
			
		||||
 | 
			
		||||
  // to see renameTo() work even when the destination file exists
 | 
			
		||||
  of.open(fname.c_str());
 | 
			
		||||
| 
						 | 
				
			
			@ -232,7 +232,7 @@ void FileTest::testRenameTo()
 | 
			
		|||
 | 
			
		||||
void FileTest::testUtime()
 | 
			
		||||
{
 | 
			
		||||
  File f("./aria2_FileTest_testUTime");
 | 
			
		||||
  File f(A2_TEST_OUT_DIR"/aria2_FileTest_testUTime");
 | 
			
		||||
  createFile(f.getPath(), 0);
 | 
			
		||||
  
 | 
			
		||||
  time_t atime = (time_t) 100000;
 | 
			
		||||
| 
						 | 
				
			
			@ -245,7 +245,7 @@ void FileTest::testUtime()
 | 
			
		|||
  CPPUNIT_ASSERT_EQUAL((time_t)atime, buf.st_atime);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((time_t)mtime, f.getModifiedTime().getTime());
 | 
			
		||||
 | 
			
		||||
  File notFound("./aria2_FileTest_testUTime_notFound");
 | 
			
		||||
  File notFound(A2_TEST_OUT_DIR"/aria2_FileTest_testUTime_notFound");
 | 
			
		||||
  notFound.remove();
 | 
			
		||||
  CPPUNIT_ASSERT(!notFound.utime(Time(atime), Time(mtime)));
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,10 +36,10 @@ void GZipDecoderTest::testDecode()
 | 
			
		|||
  GZipDecoder decoder;
 | 
			
		||||
  decoder.init();
 | 
			
		||||
 | 
			
		||||
  std::string outfile("./aria2_GZipDecoderTest_testDecode");
 | 
			
		||||
  std::string outfile(A2_TEST_OUT_DIR"/aria2_GZipDecoderTest_testDecode");
 | 
			
		||||
 | 
			
		||||
  char buf[4096];
 | 
			
		||||
  std::ifstream in("gzip_decode_test.gz", std::ios::binary);
 | 
			
		||||
  std::ifstream in(A2_TEST_DIR"/gzip_decode_test.gz", std::ios::binary);
 | 
			
		||||
  std::ofstream out(outfile.c_str(), std::ios::binary);
 | 
			
		||||
  while(in) {
 | 
			
		||||
    in.read(buf, sizeof(buf));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -66,7 +66,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(GZipDecodingStreamFilterTest);
 | 
			
		|||
void GZipDecodingStreamFilterTest::testTransform()
 | 
			
		||||
{
 | 
			
		||||
  unsigned char buf[4096];
 | 
			
		||||
  std::ifstream in("gzip_decode_test.gz", std::ios::binary);
 | 
			
		||||
  std::ifstream in(A2_TEST_DIR"/gzip_decode_test.gz", std::ios::binary);
 | 
			
		||||
  while(in) {
 | 
			
		||||
    in.read(reinterpret_cast<char*>(buf), sizeof(buf));
 | 
			
		||||
    filter_->transform(writer_, segment_, buf, in.gcount());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,11 +33,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION( IteratableChecksumValidatorTest );
 | 
			
		|||
void IteratableChecksumValidatorTest::testValidate() {
 | 
			
		||||
  Option option;
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(100, 250, "chunkChecksumTestFile250.txt"));
 | 
			
		||||
    (new DownloadContext(100, 250, A2_TEST_DIR"/chunkChecksumTestFile250.txt"));
 | 
			
		||||
  dctx->setChecksum("898a81b8e0181280ae2ee1b81e269196d91e869a");
 | 
			
		||||
  dctx->setChecksumHashAlgo("sha-1");
 | 
			
		||||
  SharedHandle<DefaultPieceStorage> ps(new DefaultPieceStorage(dctx, &option));
 | 
			
		||||
  ps->initStorage();
 | 
			
		||||
  ps->getDiskAdaptor()->enableReadOnly();
 | 
			
		||||
  ps->getDiskAdaptor()->openFile();
 | 
			
		||||
 | 
			
		||||
  IteratableChecksumValidator validator(dctx, ps);
 | 
			
		||||
| 
						 | 
				
			
			@ -52,11 +53,12 @@ void IteratableChecksumValidatorTest::testValidate() {
 | 
			
		|||
void IteratableChecksumValidatorTest::testValidate_fail() {
 | 
			
		||||
  Option option;
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(100, 250, "chunkChecksumTestFile250.txt"));
 | 
			
		||||
    (new DownloadContext(100, 250, A2_TEST_DIR"/chunkChecksumTestFile250.txt"));
 | 
			
		||||
  dctx->setChecksum(std::string(40, '0')); // set wrong checksum
 | 
			
		||||
  dctx->setChecksumHashAlgo("sha-1");
 | 
			
		||||
  SharedHandle<DefaultPieceStorage> ps(new DefaultPieceStorage(dctx, &option));
 | 
			
		||||
  ps->initStorage();
 | 
			
		||||
  ps->getDiskAdaptor()->enableReadOnly();
 | 
			
		||||
  ps->getDiskAdaptor()->openFile();
 | 
			
		||||
 | 
			
		||||
  IteratableChecksumValidator validator(dctx, ps);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,12 +38,13 @@ const char* IteratableChunkChecksumValidatorTest::csArray[] = { "29b0e7878271645
 | 
			
		|||
void IteratableChunkChecksumValidatorTest::testValidate() {
 | 
			
		||||
  Option option;
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(100, 250, "chunkChecksumTestFile250.txt"));
 | 
			
		||||
    (new DownloadContext(100, 250, A2_TEST_DIR"/chunkChecksumTestFile250.txt"));
 | 
			
		||||
  dctx->setPieceHashes(&csArray[0], &csArray[3]);
 | 
			
		||||
  dctx->setPieceHashAlgo("sha-1");
 | 
			
		||||
  SharedHandle<DefaultPieceStorage> ps
 | 
			
		||||
    (new DefaultPieceStorage(dctx, &option));
 | 
			
		||||
  ps->initStorage();
 | 
			
		||||
  ps->getDiskAdaptor()->enableReadOnly();
 | 
			
		||||
  ps->getDiskAdaptor()->openFile();
 | 
			
		||||
 | 
			
		||||
  IteratableChunkChecksumValidator validator(dctx, ps);
 | 
			
		||||
| 
						 | 
				
			
			@ -75,7 +76,7 @@ void IteratableChunkChecksumValidatorTest::testValidate() {
 | 
			
		|||
void IteratableChunkChecksumValidatorTest::testValidate_readError() {
 | 
			
		||||
  Option option;
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(100, 500, "chunkChecksumTestFile250.txt"));
 | 
			
		||||
    (new DownloadContext(100, 500, A2_TEST_DIR"/chunkChecksumTestFile250.txt"));
 | 
			
		||||
  std::deque<std::string> hashes(&csArray[0], &csArray[3]);
 | 
			
		||||
  hashes.push_back("ffffffffffffffffffffffffffffffffffffffff");
 | 
			
		||||
  hashes.push_back("ffffffffffffffffffffffffffffffffffffffff");
 | 
			
		||||
| 
						 | 
				
			
			@ -83,6 +84,7 @@ void IteratableChunkChecksumValidatorTest::testValidate_readError() {
 | 
			
		|||
  dctx->setPieceHashAlgo("sha-1");
 | 
			
		||||
  SharedHandle<DefaultPieceStorage> ps(new DefaultPieceStorage(dctx, &option));
 | 
			
		||||
  ps->initStorage();
 | 
			
		||||
  ps->getDiskAdaptor()->enableReadOnly();
 | 
			
		||||
  ps->getDiskAdaptor()->openFile();
 | 
			
		||||
 | 
			
		||||
  IteratableChunkChecksumValidator validator(dctx, ps);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,4 @@
 | 
			
		|||
a2_test_outdir = test_outdir
 | 
			
		||||
TESTS = aria2c
 | 
			
		||||
check_PROGRAMS = $(TESTS)
 | 
			
		||||
aria2c_SOURCES = AllTest.cc\
 | 
			
		||||
| 
						 | 
				
			
			@ -223,11 +224,14 @@ aria2c_LDADD = ../src/libaria2c.a\
 | 
			
		|||
	${CPPUNIT_LIBS}
 | 
			
		||||
AM_CPPFLAGS =  -Wall\
 | 
			
		||||
	${CPPUNIT_CFLAGS}\
 | 
			
		||||
	-I ../src\
 | 
			
		||||
	-I../lib -I../intl -I$(top_srcdir)/intl\
 | 
			
		||||
	-I$(top_srcdir)/src\
 | 
			
		||||
	-I$(top_srcdir)/lib -I$(top_srcdir)/intl\
 | 
			
		||||
	@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
 | 
			
		||||
	@LIBCARES_CPPFLAGS@ @LIBEXPAT_CPPFLAGS@\
 | 
			
		||||
	@LIBZ_CPPFLAGS@	 @SQLITE3_CFLAGS@ -DLOCALEDIR=\"$(localedir)\" @DEFS@
 | 
			
		||||
	@LIBZ_CPPFLAGS@	 @SQLITE3_CFLAGS@ -DLOCALEDIR=\"$(localedir)\"\
 | 
			
		||||
	-DA2_TEST_DIR=\"$(top_srcdir)/test\"\
 | 
			
		||||
	-DA2_TEST_OUT_DIR=\"${a2_test_outdir}\"\
 | 
			
		||||
	@DEFS@
 | 
			
		||||
 | 
			
		||||
EXTRA_DIST = 4096chunk.txt\
 | 
			
		||||
	chunkChecksumTestFile250.txt\
 | 
			
		||||
| 
						 | 
				
			
			@ -260,3 +264,6 @@ EXTRA_DIST = 4096chunk.txt\
 | 
			
		|||
	metalink4-groupbymetaurl.xml\
 | 
			
		||||
	serialize_session.meta4\
 | 
			
		||||
	metalink4-dosdirtraversal.xml
 | 
			
		||||
 | 
			
		||||
clean-local:
 | 
			
		||||
	-rm -rf ${a2_test_outdir}
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +29,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION( MessageDigestHelperTest );
 | 
			
		|||
 | 
			
		||||
void MessageDigestHelperTest::testHexDigestDiskWriter() {
 | 
			
		||||
  SharedHandle<DefaultDiskWriter> diskio
 | 
			
		||||
    (new DefaultDiskWriter("4096chunk.txt"));
 | 
			
		||||
    (new DefaultDiskWriter(A2_TEST_DIR"/4096chunk.txt"));
 | 
			
		||||
  diskio->enableReadOnly();
 | 
			
		||||
  diskio->openExistingFile();
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("608cabc0f2fa18c260cafd974516865c772363d5"),
 | 
			
		||||
                       MessageDigestHelper::hexDigest
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,7 +42,7 @@ void Metalink2RequestGroupTest::testGenerate()
 | 
			
		|||
{
 | 
			
		||||
  std::vector<SharedHandle<RequestGroup> > groups;
 | 
			
		||||
  option_->put(PREF_DIR, "/tmp");
 | 
			
		||||
  Metalink2RequestGroup().generate(groups, "test.xml", option_);
 | 
			
		||||
  Metalink2RequestGroup().generate(groups, A2_TEST_DIR"/test.xml", option_);
 | 
			
		||||
  // first file
 | 
			
		||||
  {
 | 
			
		||||
    SharedHandle<RequestGroup> rg = groups[0];
 | 
			
		||||
| 
						 | 
				
			
			@ -131,7 +131,8 @@ void Metalink2RequestGroupTest::testGenerate()
 | 
			
		|||
void Metalink2RequestGroupTest::testGenerate_groupByMetaurl()
 | 
			
		||||
{
 | 
			
		||||
  std::vector<SharedHandle<RequestGroup> > groups;
 | 
			
		||||
  Metalink2RequestGroup().generate(groups, "metalink4-groupbymetaurl.xml",
 | 
			
		||||
  Metalink2RequestGroup().generate(groups,
 | 
			
		||||
                                   A2_TEST_DIR"/metalink4-groupbymetaurl.xml",
 | 
			
		||||
                                   option_);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)3, groups.size());
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -207,7 +208,7 @@ void Metalink2RequestGroupTest::testGenerate_dosDirTraversal()
 | 
			
		|||
  std::vector<SharedHandle<RequestGroup> > groups;
 | 
			
		||||
  option_->put(PREF_DIR, "/tmp");
 | 
			
		||||
  Metalink2RequestGroup().generate
 | 
			
		||||
    (groups, "metalink4-dosdirtraversal.xml", option_);
 | 
			
		||||
    (groups, A2_TEST_DIR"/metalink4-dosdirtraversal.xml", option_);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)3, groups.size());
 | 
			
		||||
  SharedHandle<RequestGroup> rg = groups[0];
 | 
			
		||||
  SharedHandle<FileEntry> file = rg->getDownloadContext()->getFirstFileEntry();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ void MetalinkHelperTest::testParseAndQuery()
 | 
			
		|||
{
 | 
			
		||||
  Option option;
 | 
			
		||||
  std::vector<SharedHandle<MetalinkEntry> > result;
 | 
			
		||||
  MetalinkHelper::parseAndQuery(result, "test.xml", &option);
 | 
			
		||||
  MetalinkHelper::parseAndQuery(result, A2_TEST_DIR"/test.xml", &option);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)5, result.size());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ void MetalinkHelperTest::testParseAndQuery_version()
 | 
			
		|||
  Option option;
 | 
			
		||||
  option.put(PREF_METALINK_VERSION, "0.5.1");
 | 
			
		||||
  std::vector<SharedHandle<MetalinkEntry> > result;
 | 
			
		||||
  MetalinkHelper::parseAndQuery(result, "test.xml", &option);
 | 
			
		||||
  MetalinkHelper::parseAndQuery(result, A2_TEST_DIR"/test.xml", &option);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)1, result.size());
 | 
			
		||||
  SharedHandle<MetalinkEntry> entry = result.front();
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.5.1.tar.bz2"), entry->getPath());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,8 @@
 | 
			
		|||
#include "Option.h"
 | 
			
		||||
#include "DownloadContext.h"
 | 
			
		||||
#include "FileEntry.h"
 | 
			
		||||
#include "PieceStorage.h"
 | 
			
		||||
#include "DiskAdaptor.h"
 | 
			
		||||
 | 
			
		||||
namespace aria2 {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -65,10 +67,11 @@ void MetalinkPostDownloadHandlerTest::testCanHandle_contentType()
 | 
			
		|||
void MetalinkPostDownloadHandlerTest::testGetNextRequestGroups()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx
 | 
			
		||||
    (new DownloadContext(1024, 0, "test.xml"));
 | 
			
		||||
    (new DownloadContext(1024, 0, A2_TEST_DIR"/test.xml"));
 | 
			
		||||
  RequestGroup rg(option_);
 | 
			
		||||
  rg.setDownloadContext(dctx);
 | 
			
		||||
  rg.initPieceStorage();
 | 
			
		||||
  rg.getPieceStorage()->getDiskAdaptor()->enableReadOnly();
 | 
			
		||||
 | 
			
		||||
  MetalinkPostDownloadHandler handler;
 | 
			
		||||
  std::vector<SharedHandle<RequestGroup> > groups;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,7 +82,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION( MetalinkProcessorTest );
 | 
			
		|||
void MetalinkProcessorTest::testParseFileV4()
 | 
			
		||||
{
 | 
			
		||||
  MetalinkProcessor proc;
 | 
			
		||||
  SharedHandle<Metalinker> m = proc.parseFile("metalink4.xml");
 | 
			
		||||
  SharedHandle<Metalinker> m = proc.parseFile(A2_TEST_DIR"/metalink4.xml");
 | 
			
		||||
  SharedHandle<MetalinkEntry> e;
 | 
			
		||||
  SharedHandle<MetalinkResource> r;
 | 
			
		||||
  SharedHandle<MetalinkMetaurl> mu;
 | 
			
		||||
| 
						 | 
				
			
			@ -494,7 +494,7 @@ void MetalinkProcessorTest::testParseFile()
 | 
			
		|||
{
 | 
			
		||||
  MetalinkProcessor proc;
 | 
			
		||||
  try {
 | 
			
		||||
    SharedHandle<Metalinker> metalinker = proc.parseFile("test.xml");
 | 
			
		||||
    SharedHandle<Metalinker> metalinker = proc.parseFile(A2_TEST_DIR"/test.xml");
 | 
			
		||||
 | 
			
		||||
    std::vector<SharedHandle<MetalinkEntry> >::const_iterator entryItr =
 | 
			
		||||
      metalinker->getEntries().begin();
 | 
			
		||||
| 
						 | 
				
			
			@ -601,7 +601,7 @@ void MetalinkProcessorTest::testParseFile_dirtraversal()
 | 
			
		|||
{
 | 
			
		||||
  MetalinkProcessor proc;
 | 
			
		||||
  SharedHandle<Metalinker> metalinker =
 | 
			
		||||
    proc.parseFile("metalink3-dirtraversal.xml");
 | 
			
		||||
    proc.parseFile(A2_TEST_DIR"/metalink3-dirtraversal.xml");
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)1, metalinker->getEntries().size());
 | 
			
		||||
  SharedHandle<MetalinkEntry> e = metalinker->getEntries()[0];
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.5.3.tar.bz2"), e->getPath());
 | 
			
		||||
| 
						 | 
				
			
			@ -612,7 +612,8 @@ void MetalinkProcessorTest::testParseFile_dirtraversal()
 | 
			
		|||
void MetalinkProcessorTest::testParseFromBinaryStream()
 | 
			
		||||
{
 | 
			
		||||
  MetalinkProcessor proc;
 | 
			
		||||
  DefaultDiskWriterHandle dw(new DefaultDiskWriter("test.xml"));
 | 
			
		||||
  DefaultDiskWriterHandle dw(new DefaultDiskWriter(A2_TEST_DIR"/test.xml"));
 | 
			
		||||
  dw->enableReadOnly();
 | 
			
		||||
  dw->openExistingFile();
 | 
			
		||||
  
 | 
			
		||||
  try {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,15 +46,15 @@ CPPUNIT_TEST_SUITE_REGISTRATION( MultiDiskAdaptorTest );
 | 
			
		|||
 | 
			
		||||
std::vector<SharedHandle<FileEntry> > createEntries() {
 | 
			
		||||
  SharedHandle<FileEntry> array[] = {
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry("file0.txt", 0, 0)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry("file1.txt", 15, 0)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry("file2.txt", 7, 15)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry("file3.txt", 0, 22)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry("file4.txt", 2, 22)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry("file5.txt", 0, 24)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry("file6.txt", 3, 24)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry("file7.txt", 0, 27)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry("file8.txt", 2, 27)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(A2_TEST_OUT_DIR"/file0.txt", 0, 0)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(A2_TEST_OUT_DIR"/file1.txt", 15, 0)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(A2_TEST_OUT_DIR"/file2.txt", 7, 15)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(A2_TEST_OUT_DIR"/file3.txt", 0, 22)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(A2_TEST_OUT_DIR"/file4.txt", 2, 22)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(A2_TEST_OUT_DIR"/file5.txt", 0, 24)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(A2_TEST_OUT_DIR"/file6.txt", 3, 24)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(A2_TEST_OUT_DIR"/file7.txt", 0, 27)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(A2_TEST_OUT_DIR"/file8.txt", 2, 27)),
 | 
			
		||||
  };
 | 
			
		||||
  //           1    1    2    2    3
 | 
			
		||||
  // 0....5....0....5....0....5....0
 | 
			
		||||
| 
						 | 
				
			
			@ -297,9 +297,9 @@ void MultiDiskAdaptorTest::testWriteData() {
 | 
			
		|||
  adaptor->writeData((const unsigned char*)msg.c_str(), msg.size(), 0);
 | 
			
		||||
  adaptor->closeFile();
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT(File("file0.txt").isFile());
 | 
			
		||||
  CPPUNIT_ASSERT(File(A2_TEST_OUT_DIR"/file0.txt").isFile());
 | 
			
		||||
  char buf[128];
 | 
			
		||||
  readFile("file1.txt", buf, 5);
 | 
			
		||||
  readFile(A2_TEST_OUT_DIR"/file1.txt", buf, 5);
 | 
			
		||||
  buf[5] = '\0';
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(msg, std::string(buf));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -308,10 +308,10 @@ void MultiDiskAdaptorTest::testWriteData() {
 | 
			
		|||
  adaptor->writeData((const unsigned char*)msg2.c_str(), msg2.size(), 5);
 | 
			
		||||
  adaptor->closeFile();
 | 
			
		||||
 | 
			
		||||
  readFile("file1.txt", buf, 15);
 | 
			
		||||
  readFile(A2_TEST_OUT_DIR"/file1.txt", buf, 15);
 | 
			
		||||
  buf[15] = '\0';
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("1234567890ABCDE"), std::string(buf));
 | 
			
		||||
  readFile("file2.txt", buf, 1);
 | 
			
		||||
  readFile(A2_TEST_OUT_DIR"/file2.txt", buf, 1);
 | 
			
		||||
  buf[1] = '\0';
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("F"), std::string(buf));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -320,33 +320,33 @@ void MultiDiskAdaptorTest::testWriteData() {
 | 
			
		|||
  adaptor->writeData((const unsigned char*)msg3.c_str(), msg3.size(), 10);
 | 
			
		||||
  adaptor->closeFile();
 | 
			
		||||
 | 
			
		||||
  readFile("file1.txt", buf, 15);
 | 
			
		||||
  readFile(A2_TEST_OUT_DIR"/file1.txt", buf, 15);
 | 
			
		||||
  buf[15] = '\0';
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("123456789012345"), std::string(buf));
 | 
			
		||||
  readFile("file2.txt", buf, 7);
 | 
			
		||||
  readFile(A2_TEST_OUT_DIR"/file2.txt", buf, 7);
 | 
			
		||||
  buf[7] = '\0';
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("1234567"), std::string(buf));
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT(File("file3.txt").isFile());
 | 
			
		||||
  CPPUNIT_ASSERT(File(A2_TEST_OUT_DIR"/file3.txt").isFile());
 | 
			
		||||
 | 
			
		||||
  readFile("file4.txt", buf, 2);
 | 
			
		||||
  readFile(A2_TEST_OUT_DIR"/file4.txt", buf, 2);
 | 
			
		||||
  buf[2] = '\0';
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("12"), std::string(buf));
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT(File("file5.txt").isFile());
 | 
			
		||||
  CPPUNIT_ASSERT(File(A2_TEST_OUT_DIR"/file5.txt").isFile());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MultiDiskAdaptorTest::testReadData() {
 | 
			
		||||
  SharedHandle<FileEntry> entry1(new FileEntry("file1r.txt", 15, 0));
 | 
			
		||||
  SharedHandle<FileEntry> entry2(new FileEntry("file2r.txt", 7, 15));
 | 
			
		||||
  SharedHandle<FileEntry> entry3(new FileEntry("file3r.txt", 3, 22));
 | 
			
		||||
  SharedHandle<FileEntry> entry1(new FileEntry(A2_TEST_DIR"/file1r.txt", 15, 0));
 | 
			
		||||
  SharedHandle<FileEntry> entry2(new FileEntry(A2_TEST_DIR"/file2r.txt", 7, 15));
 | 
			
		||||
  SharedHandle<FileEntry> entry3(new FileEntry(A2_TEST_DIR"/file3r.txt", 3, 22));
 | 
			
		||||
  std::vector<SharedHandle<FileEntry> > entries;
 | 
			
		||||
  entries.push_back(entry1);
 | 
			
		||||
  entries.push_back(entry2);
 | 
			
		||||
  entries.push_back(entry3);
 | 
			
		||||
 | 
			
		||||
  adaptor->setFileEntries(entries.begin(), entries.end());
 | 
			
		||||
 | 
			
		||||
  adaptor->enableReadOnly();
 | 
			
		||||
  adaptor->openFile();
 | 
			
		||||
  unsigned char buf[128];
 | 
			
		||||
  adaptor->readData(buf, 15, 0);
 | 
			
		||||
| 
						 | 
				
			
			@ -365,7 +365,7 @@ void MultiDiskAdaptorTest::testReadData() {
 | 
			
		|||
 | 
			
		||||
void MultiDiskAdaptorTest::testCutTrailingGarbage()
 | 
			
		||||
{
 | 
			
		||||
  std::string dir = "./";
 | 
			
		||||
  std::string dir = A2_TEST_OUT_DIR;
 | 
			
		||||
  std::string prefix = "aria2_MultiDiskAdaptorTest_testCutTrailingGarbage_";
 | 
			
		||||
  SharedHandle<FileEntry> entries[] = {
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(dir+"/"+prefix+"1", 256, 0)),
 | 
			
		||||
| 
						 | 
				
			
			@ -394,7 +394,7 @@ void MultiDiskAdaptorTest::testCutTrailingGarbage()
 | 
			
		|||
 | 
			
		||||
void MultiDiskAdaptorTest::testSize()
 | 
			
		||||
{
 | 
			
		||||
  std::string dir = "./";
 | 
			
		||||
  std::string dir = A2_TEST_OUT_DIR;
 | 
			
		||||
  std::string prefix = "aria2_MultiDiskAdaptorTest_testSize_";
 | 
			
		||||
  SharedHandle<FileEntry> entries[] = {
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(dir+"/"+prefix+"1", 1, 0)),
 | 
			
		||||
| 
						 | 
				
			
			@ -418,7 +418,7 @@ void MultiDiskAdaptorTest::testSize()
 | 
			
		|||
 | 
			
		||||
void MultiDiskAdaptorTest::testUtime()
 | 
			
		||||
{
 | 
			
		||||
  std::string storeDir = "./aria2_MultiDiskAdaptorTest_testUtime";
 | 
			
		||||
  std::string storeDir = A2_TEST_OUT_DIR"/aria2_MultiDiskAdaptorTest_testUtime";
 | 
			
		||||
  SharedHandle<FileEntry> entries[] = {
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(storeDir+"/requested", 0, 0)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(storeDir+"/notFound", 0, 0)),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,8 +35,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION( MultiFileAllocationIteratorTest );
 | 
			
		|||
 | 
			
		||||
void MultiFileAllocationIteratorTest::testMakeDiskWriterEntries()
 | 
			
		||||
{
 | 
			
		||||
  std::string storeDir = "./aria2_MultiFileAllocationIteratorTest"
 | 
			
		||||
    "testMakeDiskWriterEntries_";
 | 
			
		||||
  std::string storeDir = A2_TEST_OUT_DIR"/aria2_MultiFileAllocationIteratorTest"
 | 
			
		||||
    "_testMakeDiskWriterEntries";
 | 
			
		||||
 | 
			
		||||
  SharedHandle<FileEntry> fs[] = {
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(storeDir+"/file1", 1536, 0)),
 | 
			
		||||
| 
						 | 
				
			
			@ -137,7 +137,7 @@ void MultiFileAllocationIteratorTest::testMakeDiskWriterEntries()
 | 
			
		|||
void MultiFileAllocationIteratorTest::testAllocate()
 | 
			
		||||
{
 | 
			
		||||
  std::string storeDir =
 | 
			
		||||
    "./aria2_MultiFileAllocationIteratorTest_testAllocate";
 | 
			
		||||
    A2_TEST_OUT_DIR"/aria2_MultiFileAllocationIteratorTest_testAllocate";
 | 
			
		||||
 | 
			
		||||
  std::string fname1 = "file1";
 | 
			
		||||
  std::string fname2 = "file2";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -70,7 +70,7 @@ void NetrcTest::testFindAuthenticator()
 | 
			
		|||
void NetrcTest::testParse()
 | 
			
		||||
{
 | 
			
		||||
  Netrc netrc;
 | 
			
		||||
  netrc.parse("sample.netrc");
 | 
			
		||||
  netrc.parse(A2_TEST_DIR"/sample.netrc");
 | 
			
		||||
  std::vector<SharedHandle<Authenticator> >::const_iterator itr =
 | 
			
		||||
    netrc.getAuthenticators().begin();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -109,7 +109,7 @@ void NetrcTest::testParse_fileNotFound()
 | 
			
		|||
void NetrcTest::testParse_emptyfile()
 | 
			
		||||
{
 | 
			
		||||
  Netrc netrc;
 | 
			
		||||
  netrc.parse("emptyfile");
 | 
			
		||||
  netrc.parse(A2_TEST_DIR"/emptyfile");
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)0, netrc.getAuthenticators().size());
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -118,7 +118,7 @@ void NetrcTest::testParse_malformedNetrc()
 | 
			
		|||
{
 | 
			
		||||
  Netrc netrc;
 | 
			
		||||
  try {
 | 
			
		||||
    netrc.parse("malformed.netrc");
 | 
			
		||||
    netrc.parse(A2_TEST_DIR"/malformed.netrc");
 | 
			
		||||
    CPPUNIT_FAIL("exception must be thrown.");
 | 
			
		||||
  } catch(Exception& e) {
 | 
			
		||||
    std::cerr << e.stackTrace() << std::endl;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,7 +33,7 @@ void NsCookieParserTest::testParse()
 | 
			
		|||
{
 | 
			
		||||
  NsCookieParser parser;
 | 
			
		||||
  time_t now = 0;
 | 
			
		||||
  std::vector<Cookie> cookies = parser.parse("nscookietest.txt", now);
 | 
			
		||||
  std::vector<Cookie> cookies = parser.parse(A2_TEST_DIR"/nscookietest.txt", now);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)5, cookies.size());
 | 
			
		||||
 | 
			
		||||
  Cookie c = cookies[0];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,9 +40,9 @@ void ProtocolDetectorTest::testIsStreamProtocol()
 | 
			
		|||
void ProtocolDetectorTest::testGuessTorrentFile()
 | 
			
		||||
{
 | 
			
		||||
  ProtocolDetector detector;
 | 
			
		||||
  CPPUNIT_ASSERT(detector.guessTorrentFile("test.torrent"));
 | 
			
		||||
  CPPUNIT_ASSERT(detector.guessTorrentFile(A2_TEST_DIR"/test.torrent"));
 | 
			
		||||
  CPPUNIT_ASSERT(!detector.guessTorrentFile("http://localhost/test.torrent"));
 | 
			
		||||
  CPPUNIT_ASSERT(!detector.guessTorrentFile("test.xml"));
 | 
			
		||||
  CPPUNIT_ASSERT(!detector.guessTorrentFile(A2_TEST_DIR"/test.xml"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ProtocolDetectorTest::testGuessTorrentMagnet()
 | 
			
		||||
| 
						 | 
				
			
			@ -63,9 +63,9 @@ void ProtocolDetectorTest::testGuessTorrentMagnet()
 | 
			
		|||
void ProtocolDetectorTest::testGuessMetalinkFile()
 | 
			
		||||
{
 | 
			
		||||
  ProtocolDetector detector;
 | 
			
		||||
  CPPUNIT_ASSERT(detector.guessMetalinkFile("test.xml"));
 | 
			
		||||
  CPPUNIT_ASSERT(detector.guessMetalinkFile(A2_TEST_DIR"/test.xml"));
 | 
			
		||||
  CPPUNIT_ASSERT(!detector.guessMetalinkFile("http://localhost/test.xml"));
 | 
			
		||||
  CPPUNIT_ASSERT(!detector.guessMetalinkFile("test.torrent"));
 | 
			
		||||
  CPPUNIT_ASSERT(!detector.guessMetalinkFile(A2_TEST_DIR"/test.torrent"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace aria2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,7 +84,7 @@ void RequestGroupManTest::testSaveServerStat()
 | 
			
		|||
    (std::vector<SharedHandle<RequestGroup> >(),0,option_.get());
 | 
			
		||||
  SharedHandle<ServerStat> ss_localhost(new ServerStat("localhost", "http"));
 | 
			
		||||
  rm.addServerStat(ss_localhost);
 | 
			
		||||
  File f("./aria2_RequestGroupManTest_testSaveServerStat");
 | 
			
		||||
  File f(A2_TEST_OUT_DIR"/aria2_RequestGroupManTest_testSaveServerStat");
 | 
			
		||||
  if(f.exists()) {
 | 
			
		||||
    f.remove();
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -98,7 +98,7 @@ void RequestGroupManTest::testSaveServerStat()
 | 
			
		|||
 | 
			
		||||
void RequestGroupManTest::testLoadServerStat()
 | 
			
		||||
{
 | 
			
		||||
  File f("./aria2_RequestGroupManTest_testLoadServerStat");
 | 
			
		||||
  File f(A2_TEST_OUT_DIR"/aria2_RequestGroupManTest_testLoadServerStat");
 | 
			
		||||
  std::ofstream o(f.getPath().c_str(), std::ios::binary);
 | 
			
		||||
  o << "host=localhost, protocol=http, dl_speed=0, last_updated=1219505257,"
 | 
			
		||||
    << "status=OK";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,8 +32,8 @@ void SessionSerializerTest::testSave()
 | 
			
		|||
  const std::string URIs[] =
 | 
			
		||||
    { "http://localhost/file",
 | 
			
		||||
      "http://mirror/file",
 | 
			
		||||
      "test.torrent",
 | 
			
		||||
      "serialize_session.meta4",
 | 
			
		||||
      A2_TEST_DIR"/test.torrent",
 | 
			
		||||
      A2_TEST_DIR"/serialize_session.meta4",
 | 
			
		||||
      "magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C"};
 | 
			
		||||
  std::vector<std::string> uris(vbegin(URIs), vend(URIs));
 | 
			
		||||
  std::vector<SharedHandle<RequestGroup> > result;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ void SignatureTest::testSave()
 | 
			
		|||
{
 | 
			
		||||
  Signature sig;
 | 
			
		||||
  sig.setBody("SIGNATURE");
 | 
			
		||||
  std::string filepath = "./aria2_SignatureTest_testSave";
 | 
			
		||||
  std::string filepath = A2_TEST_OUT_DIR"/aria2_SignatureTest_testSave";
 | 
			
		||||
  File outfile(filepath);
 | 
			
		||||
  if(outfile.exists()) {
 | 
			
		||||
    outfile.remove();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION( SingleFileAllocationIteratorTest );
 | 
			
		|||
 | 
			
		||||
void SingleFileAllocationIteratorTest::testAllocate()
 | 
			
		||||
{
 | 
			
		||||
  std::string dir = "./";
 | 
			
		||||
  std::string dir = A2_TEST_OUT_DIR;
 | 
			
		||||
  std::string fname = "aria2_SingleFileAllocationIteratorTest_testAllocate";
 | 
			
		||||
  std::string fn = dir+"/"+fname;
 | 
			
		||||
  std::ofstream of(fn.c_str(), std::ios::binary);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,7 +33,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(Sqlite3CookieParserTest);
 | 
			
		|||
 | 
			
		||||
void Sqlite3CookieParserTest::testMozParse()
 | 
			
		||||
{
 | 
			
		||||
  Sqlite3MozCookieParser parser("cookies.sqlite");
 | 
			
		||||
  Sqlite3MozCookieParser parser(A2_TEST_DIR"/cookies.sqlite");
 | 
			
		||||
  std::vector<Cookie> cookies;
 | 
			
		||||
  parser.parse(cookies);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)3, cookies.size());
 | 
			
		||||
| 
						 | 
				
			
			@ -92,7 +92,7 @@ void Sqlite3CookieParserTest::testMozParse_fileNotFound()
 | 
			
		|||
 | 
			
		||||
void Sqlite3CookieParserTest::testMozParse_badfile()
 | 
			
		||||
{
 | 
			
		||||
  Sqlite3MozCookieParser parser("badcookies.sqlite");
 | 
			
		||||
  Sqlite3MozCookieParser parser(A2_TEST_DIR"/badcookies.sqlite");
 | 
			
		||||
  try {
 | 
			
		||||
    std::vector<Cookie> cookies;
 | 
			
		||||
    parser.parse(cookies);
 | 
			
		||||
| 
						 | 
				
			
			@ -104,7 +104,7 @@ void Sqlite3CookieParserTest::testMozParse_badfile()
 | 
			
		|||
 | 
			
		||||
void Sqlite3CookieParserTest::testChromumParse()
 | 
			
		||||
{
 | 
			
		||||
  Sqlite3ChromiumCookieParser parser("chromium_cookies.sqlite");
 | 
			
		||||
  Sqlite3ChromiumCookieParser parser(A2_TEST_DIR"/chromium_cookies.sqlite");
 | 
			
		||||
  std::vector<Cookie> cookies;
 | 
			
		||||
  parser.parse(cookies);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)3, cookies.size());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,8 +34,8 @@ public:
 | 
			
		|||
  {
 | 
			
		||||
    option_.reset(new Option());
 | 
			
		||||
    option_->put("HELLO", "WORLD");
 | 
			
		||||
    option_->put(PREF_DIR, ".");
 | 
			
		||||
    dctx_.reset(new DownloadContext(0, 0, "something"));
 | 
			
		||||
    option_->put(PREF_DIR, A2_TEST_OUT_DIR);
 | 
			
		||||
    dctx_.reset(new DownloadContext(0, 0, A2_TEST_OUT_DIR"/something"));
 | 
			
		||||
    requestGroup_.reset(new RequestGroup(option_));
 | 
			
		||||
    requestGroup_->setDownloadContext(dctx_);
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -66,7 +66,7 @@ void UTMetadataPostDownloadHandlerTest::testCanHandle()
 | 
			
		|||
 | 
			
		||||
void UTMetadataPostDownloadHandlerTest::testGetNextRequestGroups()
 | 
			
		||||
{
 | 
			
		||||
  File trfile("cd41c7fdddfd034a15a04d7ff881216e01c4ceaf.torrent");
 | 
			
		||||
  File trfile(A2_TEST_OUT_DIR"/cd41c7fdddfd034a15a04d7ff881216e01c4ceaf.torrent");
 | 
			
		||||
  if(trfile.exists()) {
 | 
			
		||||
    trfile.remove();
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,7 +41,7 @@ std::string UriListParserTest::list2String(const std::vector<std::string>& src)
 | 
			
		|||
 | 
			
		||||
void UriListParserTest::testHasNext()
 | 
			
		||||
{
 | 
			
		||||
  std::ifstream in("filelist1.txt", std::ios::binary);
 | 
			
		||||
  std::ifstream in(A2_TEST_DIR"/filelist1.txt", std::ios::binary);
 | 
			
		||||
 | 
			
		||||
  UriListParser flp(in);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -651,7 +651,7 @@ void UtilTest::testMkdirs()
 | 
			
		|||
  util::mkdirs(dir);
 | 
			
		||||
  CPPUNIT_ASSERT(d.isDir());
 | 
			
		||||
 | 
			
		||||
  std::string file = "./UtilTest.cc";
 | 
			
		||||
  std::string file = A2_TEST_DIR"/UtilTest.cc";
 | 
			
		||||
  File f(file);
 | 
			
		||||
  CPPUNIT_ASSERT(f.isFile());
 | 
			
		||||
  try {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -257,7 +257,7 @@ void XmlRpcMethodTest::testAddTorrent()
 | 
			
		|||
{
 | 
			
		||||
  AddTorrentXmlRpcMethod m;
 | 
			
		||||
  XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), List::g());
 | 
			
		||||
  req.params->append(readFile("single.torrent"));
 | 
			
		||||
  req.params->append(readFile(A2_TEST_DIR"/single.torrent"));
 | 
			
		||||
  SharedHandle<List> uris = List::g();
 | 
			
		||||
  uris->append("http://localhost/aria2-0.8.2.tar.bz2");
 | 
			
		||||
  req.params->append(uris);
 | 
			
		||||
| 
						 | 
				
			
			@ -312,14 +312,14 @@ void XmlRpcMethodTest::testAddTorrent_withPosition()
 | 
			
		|||
{
 | 
			
		||||
  AddTorrentXmlRpcMethod m;
 | 
			
		||||
  XmlRpcRequest req1(AddTorrentXmlRpcMethod::getMethodName(), List::g());
 | 
			
		||||
  req1.params->append(readFile("test.torrent"));
 | 
			
		||||
  req1.params->append(readFile(A2_TEST_DIR"/test.torrent"));
 | 
			
		||||
  req1.params->append(List::g());
 | 
			
		||||
  req1.params->append(Dict::g());
 | 
			
		||||
  XmlRpcResponse res1 = m.execute(req1, e_.get());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(0, res1.code);
 | 
			
		||||
 | 
			
		||||
  XmlRpcRequest req2(AddTorrentXmlRpcMethod::getMethodName(), List::g());
 | 
			
		||||
  req2.params->append(readFile("single.torrent"));
 | 
			
		||||
  req2.params->append(readFile(A2_TEST_DIR"/single.torrent"));
 | 
			
		||||
  req2.params->append(List::g());
 | 
			
		||||
  req2.params->append(Dict::g());
 | 
			
		||||
  req2.params->append(Integer::g(0));
 | 
			
		||||
| 
						 | 
				
			
			@ -337,7 +337,7 @@ void XmlRpcMethodTest::testAddMetalink()
 | 
			
		|||
{
 | 
			
		||||
  AddMetalinkXmlRpcMethod m;
 | 
			
		||||
  XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), List::g());
 | 
			
		||||
  req.params->append(readFile("2files.metalink"));
 | 
			
		||||
  req.params->append(readFile(A2_TEST_DIR"/2files.metalink"));
 | 
			
		||||
  {
 | 
			
		||||
    XmlRpcResponse res = m.execute(req, e_.get());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(0, res.code);
 | 
			
		||||
| 
						 | 
				
			
			@ -399,7 +399,7 @@ void XmlRpcMethodTest::testAddMetalink_withPosition()
 | 
			
		|||
 | 
			
		||||
  AddMetalinkXmlRpcMethod m2;
 | 
			
		||||
  XmlRpcRequest req2("ari2.addMetalink", List::g());
 | 
			
		||||
  req2.params->append(readFile("2files.metalink"));
 | 
			
		||||
  req2.params->append(readFile(A2_TEST_DIR"/2files.metalink"));
 | 
			
		||||
  req2.params->append(Dict::g());
 | 
			
		||||
  req2.params->append(Integer::g(0));
 | 
			
		||||
  XmlRpcResponse res2 = m2.execute(req2, e_.get());
 | 
			
		||||
| 
						 | 
				
			
			@ -614,7 +614,7 @@ void XmlRpcMethodTest::testTellWaiting()
 | 
			
		|||
  addUri("http://2/", e_);
 | 
			
		||||
  addUri("http://3/", e_);
 | 
			
		||||
#ifdef ENABLE_BITTORRENT
 | 
			
		||||
  addTorrent("single.torrent", e_);
 | 
			
		||||
  addTorrent(A2_TEST_DIR"/single.torrent", e_);
 | 
			
		||||
#else // !ENABLE_BITTORRENT
 | 
			
		||||
  addUri("http://4/", e_);
 | 
			
		||||
#endif // !ENABLE_BITTORRENT
 | 
			
		||||
| 
						 | 
				
			
			@ -795,7 +795,7 @@ void XmlRpcMethodTest::testGatherProgressCommon()
 | 
			
		|||
void XmlRpcMethodTest::testGatherBitTorrentMetadata()
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<DownloadContext> dctx(new DownloadContext());
 | 
			
		||||
  bittorrent::load("test.torrent", dctx);
 | 
			
		||||
  bittorrent::load(A2_TEST_DIR"/test.torrent", dctx);
 | 
			
		||||
  SharedHandle<Dict> btDict = Dict::g();
 | 
			
		||||
  gatherBitTorrentMetadata(btDict, bittorrent::getTorrentAttrs(dctx));
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("REDNOAH.COM RULES"),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue