make tests run in separate directories, to have them never interfere with eachother
This commit is contained in:
parent
7f23627581
commit
1774e989f0
3
clean.py
3
clean.py
|
@ -7,7 +7,8 @@ to_delete = [
|
||||||
'dht.log',
|
'dht.log',
|
||||||
'upnp.log',
|
'upnp.log',
|
||||||
'natpmp.log',
|
'natpmp.log',
|
||||||
'bin'
|
'bin',
|
||||||
|
'test_tmp_*'
|
||||||
]
|
]
|
||||||
|
|
||||||
directories = [
|
directories = [
|
||||||
|
|
|
@ -41,6 +41,7 @@ int test_main();
|
||||||
extern bool tests_failure;
|
extern bool tests_failure;
|
||||||
|
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
|
#include "libtorrent/file.hpp"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
void sig_handler(int sig)
|
void sig_handler(int sig)
|
||||||
|
@ -74,6 +75,8 @@ void sig_handler(int sig)
|
||||||
exit(138);
|
exit(138);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace libtorrent;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#ifdef O_NONBLOCK
|
#ifdef O_NONBLOCK
|
||||||
|
@ -97,6 +100,18 @@ int main()
|
||||||
signal(SIGSYS, &sig_handler);
|
signal(SIGSYS, &sig_handler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
char dir[40];
|
||||||
|
snprintf(dir, sizeof(dir), "test_tmp_%u", rand());
|
||||||
|
std::string test_dir = complete(dir);
|
||||||
|
error_code ec;
|
||||||
|
create_directory(test_dir, ec);
|
||||||
|
if (ec)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to create test directory: %s\n", ec.message().c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
chdir(dir);
|
||||||
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -117,6 +132,9 @@ int main()
|
||||||
#endif
|
#endif
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
remove_all(test_dir, ec);
|
||||||
|
if (ec)
|
||||||
|
fprintf(stderr, "failed to remove test dir: %s\n", ec.message().c_str());
|
||||||
return tests_failure ? 1 : 0;
|
return tests_failure ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -650,6 +650,7 @@ void stop_web_server()
|
||||||
web_server->join();
|
web_server->join();
|
||||||
web_server.reset();
|
web_server.reset();
|
||||||
}
|
}
|
||||||
|
remove("server.pem");
|
||||||
fprintf(stderr, "done\n");
|
fprintf(stderr, "done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,11 +133,11 @@ void test_feed(std::string const& filename, rss_expect const& expect)
|
||||||
|
|
||||||
int test_main()
|
int test_main()
|
||||||
{
|
{
|
||||||
test_feed("eztv.xml", rss_expect(30, "http://torrent.zoink.it/The.Daily.Show.2012.02.16.(HDTV-LMAO)[VTV].torrent", "The Daily Show 2012-02-16 [HDTV - LMAO]", 183442338));
|
test_feed(combine_path("..", "eztv.xml"), rss_expect(30, "http://torrent.zoink.it/The.Daily.Show.2012.02.16.(HDTV-LMAO)[VTV].torrent", "The Daily Show 2012-02-16 [HDTV - LMAO]", 183442338));
|
||||||
test_feed("cb.xml", rss_expect(50, "http://www.clearbits.net/get/1911-norbergfestival-2011.torrent", "Norbergfestival 2011", 1160773632));
|
test_feed(combine_path("..", "cb.xml"), rss_expect(50, "http://www.clearbits.net/get/1911-norbergfestival-2011.torrent", "Norbergfestival 2011", 1160773632));
|
||||||
test_feed("kat.xml", rss_expect(25, "http://kat.ph/torrents/benito-di-paula-1975-benito-di-paula-lp-rip-ogg-at-500-jarax4u-t6194897/", "Benito Di Paula - 1975 - Benito Di Paula (LP Rip OGG at 500) [jarax4u]", 168773863));
|
test_feed(combine_path("..", "kat.xml"), rss_expect(25, "http://kat.ph/torrents/benito-di-paula-1975-benito-di-paula-lp-rip-ogg-at-500-jarax4u-t6194897/", "Benito Di Paula - 1975 - Benito Di Paula (LP Rip OGG at 500) [jarax4u]", 168773863));
|
||||||
test_feed("mn.xml", rss_expect(20, "http://www.mininova.org/get/13203100", "Dexcell - January TwentyTwelve Mix", 137311179));
|
test_feed(combine_path("..", "mn.xml"), rss_expect(20, "http://www.mininova.org/get/13203100", "Dexcell - January TwentyTwelve Mix", 137311179));
|
||||||
test_feed("pb.xml", rss_expect(60, "magnet:?xt=urn:btih:FD4CDDB7BBE722D17A018EFD875EB0695ED7159C&dn=Thompson+Twins+-+1989+-+Big+Trash+%5BMP3%5D", "Thompson Twins - 1989 - Big Trash [MP3]", 100160904));
|
test_feed(combine_path("..", "pb.xml"), rss_expect(60, "magnet:?xt=urn:btih:FD4CDDB7BBE722D17A018EFD875EB0695ED7159C&dn=Thompson+Twins+-+1989+-+Big+Trash+%5BMP3%5D", "Thompson Twins - 1989 - Big Trash [MP3]", 100160904));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ int test_main()
|
||||||
{
|
{
|
||||||
error_code ec;
|
error_code ec;
|
||||||
fprintf(stderr, "loading %s\n", test_torrents[i].file);
|
fprintf(stderr, "loading %s\n", test_torrents[i].file);
|
||||||
boost::intrusive_ptr<torrent_info> ti(new torrent_info(combine_path("test_torrents", test_torrents[i].file), ec));
|
boost::intrusive_ptr<torrent_info> ti(new torrent_info(combine_path(combine_path("..", "test_torrents"), test_torrents[i].file), ec));
|
||||||
TEST_CHECK(!ec);
|
TEST_CHECK(!ec);
|
||||||
if (ec) fprintf(stderr, " -> failed %s\n", ec.message().c_str());
|
if (ec) fprintf(stderr, " -> failed %s\n", ec.message().c_str());
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ int test_main()
|
||||||
{
|
{
|
||||||
error_code ec;
|
error_code ec;
|
||||||
fprintf(stderr, "loading %s\n", test_error_torrents[i].file);
|
fprintf(stderr, "loading %s\n", test_error_torrents[i].file);
|
||||||
boost::intrusive_ptr<torrent_info> ti(new torrent_info(combine_path("test_torrents", test_error_torrents[i].file), ec));
|
boost::intrusive_ptr<torrent_info> ti(new torrent_info(combine_path(combine_path("..", "test_torrents"), test_error_torrents[i].file), ec));
|
||||||
fprintf(stderr, "E: %s\nexpected: %s\n", ec.message().c_str(), test_error_torrents[i].error.message().c_str());
|
fprintf(stderr, "E: %s\nexpected: %s\n", ec.message().c_str(), test_error_torrents[i].error.message().c_str());
|
||||||
TEST_EQUAL(ec, test_error_torrents[i].error);
|
TEST_EQUAL(ec, test_error_torrents[i].error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,8 +194,8 @@ int run_upnp_test(char const* root_filename, char const* router_model, char cons
|
||||||
|
|
||||||
int test_main()
|
int test_main()
|
||||||
{
|
{
|
||||||
run_upnp_test("root1.xml", "Xtreme N GIGABIT Router", "wipconn");
|
run_upnp_test(combine_path("..", "root1.xml").c_str(), "Xtreme N GIGABIT Router", "wipconn");
|
||||||
run_upnp_test("root2.xml", "D-Link Router", "WANIPConnection");
|
run_upnp_test(combine_path("..", "root2.xml").c_str(), "D-Link Router", "WANIPConnection");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue