Test case to make network::manager ready to crash

This commit is contained in:
Pauli Nieminen 2008-06-29 23:55:15 +00:00
parent b7055d18f7
commit 6c824cdcc5
4 changed files with 43 additions and 24 deletions

View file

@ -220,9 +220,9 @@ else:
env.Append(CPPPATH = ["#/src", "#/"])
boost_test_dyn_link = boost_auto_test = False
boost_test_dyn_link = False
if 'test' in COMMAND_LINE_TARGETS:
boost_test_dyn_link = boost_auto_test = conf.CheckBoost('unit_test_framework')
boost_test_dyn_link = conf.CheckBoost('unit_test_framework', require_version = "1.34.0")
have_msgfmt = env["MSGFMT"]
if not have_msgfmt:
@ -273,15 +273,6 @@ installdirs = Split("bindir datadir fifodir icondir desktopdir mandir docdir pyt
for d in installdirs:
env[d] = os.path.join(env["prefix"], env[d])
test_env = env.Clone()
if boost_test_dyn_link:
test_env.Append(CPPDEFINES = "BOOST_TEST_DYN_LINK")
if boost_auto_test:
test_env.Append(CPPDEFINES = "WESNOTH_BOOST_AUTO_TEST_MAIN")
else:
test_env.Append(CPPDEFINES = "WESNOTH_BOOST_TEST_MAIN")
Export("test_env")
if env["PLATFORM"] == 'win32':
env.Append(LIBS = ["wsock32", "intl"], CXXFLAGS = ["-mthreads"], LINKFLAGS = ["-mthreads"])
if env["PLATFORM"] == 'darwin': # Mac OS X
@ -307,6 +298,12 @@ env.AppendUnique(**builds[build])
env.Append(CXXFLAGS = os.environ.get('CXXFLAGS', []), LINKFLAGS = os.environ.get('LDFLAGS', []))
env.MergeFlags(env["extra_flags_" + build])
test_env = env.Clone()
if boost_test_dyn_link:
test_env.Append(CPPDEFINES = "BOOST_TEST_DYN_LINK")
Export("test_env")
SConscript("src/SConscript", build_dir = os.path.join("build", build), exports = "env")
Import(binaries + ["sources"])
binary_nodes = map(eval, binaries)
@ -319,6 +316,7 @@ env.Alias("all", map(Alias, binaries))
env.Default(map(Alias, env["default_targets"]))
all = env.Alias("all")
#
# Utility productions (Unix-like systems only)
#

View file

@ -317,8 +317,9 @@ env.WesnothProgram("exploder", exploder_sources + [libcutter, libwesnoth_core, l
test_sources = Split("""
tests/main.cpp
tests/test_util.cpp
tests/test_network_worker.cpp
""")
test = test_env.Program("test", test_sources + [libwesnoth_core, libwesnoth])
test = test_env.Program("test", test_sources + [libwesnoth_core, libwesnothd])
Export("test")
if env["svnrev"] != "" and env["svnrev"] != "exported":

View file

@ -11,15 +11,9 @@
See the COPYING file for more details.
*/
#ifdef WESNOTH_BOOST_AUTO_TEST_MAIN
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#else
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#endif
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#if WESNOTH_BOOST_TEST_MAIN
struct wesnoth_global_fixture {
wesnoth_global_fixture()
@ -34,7 +28,6 @@ struct wesnoth_global_fixture {
BOOST_GLOBAL_FIXTURE( wesnoth_global_fixture );
#endif
/*
* This is a main compilation unit for the test program.

View file

@ -25,7 +25,7 @@
const int TEST_PORT = 15010;
const int MIN_THREADS = 1;
const int MAX_THREADS = 0;
const int MAX_THREADS = 1;
const std::string LOCALHOST = "localhost";
network::manager* manager;
@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE( test_connect )
BOOST_WARN_MESSAGE(connections == 0, "There is open "<< connections <<" connections before test!");
::manager = new network::manager(MIN_THREADS,MAX_THREADS);
::server = new network::server_manager(TEST_PORT,network::server_manager::MUST_CREATE_SERVER);
server = new network::server_manager(TEST_PORT,network::server_manager::MUST_CREATE_SERVER);
BOOST_REQUIRE_MESSAGE(server->is_running(), "Can't start server!");
client_client1 = network::connect(LOCALHOST, TEST_PORT);
@ -97,8 +97,35 @@ BOOST_AUTO_TEST_CASE( test_send_client )
}
BOOST_AUTO_TEST_CASE( test_send_server )
BOOST_AUTO_TEST_CASE( test_sdl_thread_wait_crash )
{
delete server;
delete ::manager;
#if 0
::manager = new network::manager(MIN_THREADS,MAX_THREADS);
client_client1 = network::connect(LOCALHOST, TEST_PORT);
BOOST_CHECK_MESSAGE(client_client1 > 0, "Can't connect to server");
delete ::manager;
::manager = new network::manager(MIN_THREADS,MAX_THREADS);
client_client1 = network::connect(LOCALHOST, TEST_PORT);
BOOST_CHECK_MESSAGE(client_client1 > 0, "Can't connect to server");
delete ::manager;
::manager = new network::manager(MIN_THREADS,MAX_THREADS);
server = new network::server_manager(TEST_PORT,network::server_manager::MUST_CREATE_SERVER);
client_client1 = network::connect(LOCALHOST, TEST_PORT);
BOOST_CHECK_MESSAGE(client_client1 > 0, "Can't connect to server");
delete ::server;
delete ::manager;
::manager = new network::manager(MIN_THREADS,MAX_THREADS);
client_client1 = network::connect(LOCALHOST, TEST_PORT);
BOOST_CHECK_MESSAGE(client_client1 > 0, "Can't connect to server");
delete ::manager;
#endif
::manager = new network::manager(MIN_THREADS,MAX_THREADS);
server = new network::server_manager(TEST_PORT,network::server_manager::MUST_CREATE_SERVER);
}
BOOST_AUTO_TEST_CASE( test_multiple_connections )