Added some unit testing for netoworking. I will work more on it later
Added changelog entry that was missing from my previous commit (note for me: never do svn ci in src)
This commit is contained in:
parent
2864d82915
commit
5579c291a0
3 changed files with 64 additions and 0 deletions
|
@ -10,6 +10,7 @@ Version 1.3.15+svn:
|
|||
* display reloaded games in yellow instead of green in the game list
|
||||
as they are also a kind of already running games
|
||||
* Made era not required while loading save game
|
||||
* Removed bogus clinet commands about takeing side
|
||||
* Fixed control change when giving own team (bug #6639)
|
||||
* miscellaneous and bug fixes:
|
||||
* Moved destruction of conditional object before the mutex. This should
|
||||
|
|
|
@ -205,6 +205,7 @@ cutter_DEPENDENCIES=libwesnoth-core.a
|
|||
test_SOURCES = \
|
||||
tests/main.cpp \
|
||||
tests/test_util.cpp \
|
||||
tests/test_network_worker.cpp \
|
||||
$(wesnoth_source)
|
||||
|
||||
test_LDADD = $(THELIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) libwesnoth.a
|
||||
|
|
62
src/tests/test_network_worker.cpp
Normal file
62
src/tests/test_network_worker.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* $Id: test_util.cpp 23124 2008-01-21 21:56:39Z noyga $ */
|
||||
/*
|
||||
Copyright (C) 2008 by Pauli Nieminen <paniemin@cc.hut.fi>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
or at your option any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
#include <string>
|
||||
#include "network.hpp"
|
||||
|
||||
//! Initial implementation. I will wokr more on this shortly
|
||||
//! This sohuld be complit test for networking that there won't
|
||||
//! be any crashes even in rarely used code paths.
|
||||
//! It is like that this will need some threading also :(
|
||||
|
||||
const int TEST_PORT = 15010;
|
||||
const int MIN_THREADS = 1;
|
||||
const int MAX_THREADS = 0;
|
||||
const std::string LOCALHOST = "localhost";
|
||||
|
||||
network::manager* manager;
|
||||
network::server_manager* server;
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_network_connect )
|
||||
{
|
||||
int connections = network::nconnections();
|
||||
network::connection client_client;
|
||||
network::connection server_client;
|
||||
BOOST_WARN_MESSAGE(connections == 0, "There is open conenctions before test!");
|
||||
manager = new network::manager(MIN_THREADS,MAX_THREADS);
|
||||
|
||||
server = new network::server_manager(TEST_PORT,network::server_manager::MUST_CREATE_SERVER);
|
||||
BOOST_REQUIRE_MESSAGE(server->is_running(), "Can't start server!");
|
||||
|
||||
client_client = network::connect(LOCALHOST, TEST_PORT);
|
||||
|
||||
BOOST_CHECK_MESSAGE(client_client > 0, "Can't connect to server");
|
||||
|
||||
server_client = network::accept_connection();
|
||||
|
||||
BOOST_CHECK_MESSAGE(server_client > 0, "Can't accept connection");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_network_shutdown )
|
||||
{
|
||||
delete server;
|
||||
delete manager;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4: */
|
||||
|
Loading…
Add table
Reference in a new issue