void get_world(Framework *world)
{
- world->_create= world_create;
- world->_destroy= world_destroy;
- world->collections= collection;
+ world->create(world_create);
+ world->destroy(world_destroy);
+ world->collections(collection);
world->set_runner(new MemcachedLightRunner);
}
{
for (test_st *run= _tests; run->name; run++)
{
- long int load_time= 0;
-
if (_frame->match(run->name))
{
continue;
catch (libtest::fatal &e)
{
Error << "Fatal exception was thrown: " << e.what();
- return_code= TEST_FAILURE;
_failed++;
throw;
}
fatal::fatal(const char *file_arg, int line_arg, const char *func_arg, const char *format, ...) :
std::runtime_error(func_arg),
- _file(file_arg),
_line(line_arg),
+ _file(file_arg),
_func(func_arg)
{
va_list args;
Framework::Framework(libtest::SignalThread& signal,
const std::string& only_run_arg,
const std::string& wildcard_arg) :
- collections(NULL),
+ _collections(NULL),
_total(0),
_success(0),
_skipped(0),
_failed(0),
_create(NULL),
_destroy(NULL),
+ _on_error(NULL),
_runner(NULL),
_socket(false),
_creators_ptr(NULL),
{
get_world(this);
- for (collection_st *next= collections; next and next->name; next++)
+ for (collection_st *next= _collections; next and next->name; next++)
{
_collection.push_back(new Collection(this, next));
}
{
delete *iter;
}
- _collection.clear();
}
bool Framework::match(const char* arg)
class Framework {
public:
- collection_st *collections;
-
- /* These methods are called outside of any collection call. */
- test_callback_create_fn *_create;
- test_callback_destroy_fn *_destroy;
public:
test_return_t create();
- /**
- If an error occurs during the test, this is called.
- */
- test_callback_error_fn *_on_error;
+ void create(test_callback_create_fn* arg)
+ {
+ _create= arg;
+ }
+
+ void destroy(test_callback_destroy_fn* arg)
+ {
+ _destroy= arg;
+ }
+
+ void collections(collection_st* arg)
+ {
+ _collections= arg;
+ }
void set_on_error(test_callback_error_fn *arg)
{
{
return _servers;
}
-
- /**
- Runner represents the callers for the tests. If not implemented we will use
- a set of default implementations.
- */
- libtest::Runner *_runner;
void set_runner(libtest::Runner *arg)
{
private:
Framework& operator=(const Framework&);
+ collection_st *_collections;
+
uint32_t _total;
uint32_t _success;
uint32_t _skipped;
uint32_t _failed;
+
+ /* These methods are called outside of any collection call. */
+ test_callback_create_fn *_create;
+ test_callback_destroy_fn *_destroy;
+
+ /**
+ If an error occurs during the test, this is called.
+ */
+ test_callback_error_fn *_on_error;
+
+ /**
+ Runner represents the callers for the tests. If not implemented we will use
+ a set of default implementations.
+ */
+ libtest::Runner *_runner;
libtest::server_startup_st _servers;
bool _socket;
EXTRA_DIST+= libtest/run.gdb
-CLEANFILES+= \
- tmp_chroot/var/drizzle/* \
- tmp_chroot/var/log/* \
- tmp_chroot/var/run/* \
- tmp_chroot/var/tmp/*
+CLEANFILES+= tmp_chroot/etc/*
+CLEANFILES+= tmp_chroot/var/drizzle/*
+CLEANFILES+= tmp_chroot/var/log/*
+CLEANFILES+= tmp_chroot/var/run/*
+CLEANFILES+= tmp_chroot/var/tmp/*
.PHONY: distclean-libtest-check
distclean-libtest-check:
-rm -rf tmp_chroot
noinst_HEADERS+= libtest/timer.hpp
-noinst_HEADERS+= \
- libtest/binaries.h \
- libtest/cpu.hpp \
- libtest/blobslap_worker.h \
- libtest/callbacks.h \
- libtest/cmdline.h \
- libtest/collection.h \
- libtest/common.h \
- libtest/comparison.hpp \
- libtest/core.h \
- libtest/dream.h \
- libtest/error.h \
- libtest/failed.h \
- libtest/fatal.hpp \
- libtest/framework.h \
- libtest/gearmand.h \
- libtest/drizzled.h \
- libtest/get.h \
- libtest/has.hpp \
- libtest/http.hpp \
- libtest/is_pid.hpp \
- libtest/is_local.hpp \
- libtest/killpid.h \
- libtest/libtool.hpp \
- libtest/memcached.h \
- libtest/port.h \
- libtest/runner.h \
- libtest/server.h \
- libtest/server_container.h \
- libtest/signal.h \
- libtest/socket.hpp \
- libtest/stream.h \
- libtest/strerror.h \
- libtest/string.hpp \
- libtest/test.h \
- libtest/test.hpp \
- libtest/tmpfile.hpp \
- libtest/vchar.hpp \
- libtest/visibility.h \
- libtest/wait.h
+noinst_HEADERS+=libtest/binaries.h
+noinst_HEADERS+=libtest/cpu.hpp
+noinst_HEADERS+=libtest/blobslap_worker.h
+noinst_HEADERS+=libtest/callbacks.h
+noinst_HEADERS+=libtest/cmdline.h
+noinst_HEADERS+=libtest/collection.h
+noinst_HEADERS+=libtest/common.h
+noinst_HEADERS+=libtest/comparison.hpp
+noinst_HEADERS+=libtest/core.h
+noinst_HEADERS+=libtest/dream.h
+noinst_HEADERS+=libtest/error.h
+noinst_HEADERS+=libtest/failed.h
+noinst_HEADERS+=libtest/fatal.hpp
+noinst_HEADERS+=libtest/framework.h
+noinst_HEADERS+=libtest/gearmand.h
+noinst_HEADERS+=libtest/drizzled.h
+noinst_HEADERS+=libtest/get.h
+noinst_HEADERS+=libtest/has.hpp
+noinst_HEADERS+=libtest/http.hpp
+noinst_HEADERS+=libtest/is_pid.hpp
+noinst_HEADERS+=libtest/is_local.hpp
+noinst_HEADERS+=libtest/killpid.h
+noinst_HEADERS+=libtest/libtool.hpp
+noinst_HEADERS+=libtest/memcached.h
+noinst_HEADERS+=libtest/port.h
+noinst_HEADERS+=libtest/runner.h
+noinst_HEADERS+=libtest/server.h
+noinst_HEADERS+=libtest/server_container.h
+noinst_HEADERS+=libtest/signal.h
+noinst_HEADERS+=libtest/socket.hpp
+noinst_HEADERS+=libtest/stream.h
+noinst_HEADERS+=libtest/strerror.h
+noinst_HEADERS+=libtest/string.hpp
+noinst_HEADERS+=libtest/test.h
+noinst_HEADERS+=libtest/test.hpp
+noinst_HEADERS+=libtest/tmpfile.hpp
+noinst_HEADERS+=libtest/vchar.hpp
+noinst_HEADERS+=libtest/visibility.h
+noinst_HEADERS+=libtest/wait.h
noinst_LTLIBRARIES+= libtest/libtest.la
libtest_libtest_la_SOURCES+= libtest/server_container.cc
libtest_libtest_la_SOURCES+= libtest/signal.cc
libtest_libtest_la_SOURCES+= libtest/socket.cc
+libtest_libtest_la_SOURCES+= libtest/stream.cc
libtest_libtest_la_SOURCES+= libtest/strerror.cc
libtest_libtest_la_SOURCES+= libtest/timer.cc
libtest_libtest_la_SOURCES+= libtest/tmpfile.cc
libtest_tmp_dir: tmp_chroot/var/log tmp_chroot/var/tmp tmp_chroot/var/run tmp_chroot/var/drizzle
-tmp_chroot:
+tmp_chroot: tmp_chroot/etc
@$(mkdir_p) tmp_chroot
+tmp_chroot/etc:
+ @$(mkdir_p) tmp_chroot/etc
+
tmp_chroot/var: tmp_chroot
@$(mkdir_p) tmp_chroot/var
#include <sys/wait.h>
#include <unistd.h>
+#include <utility>
+#include <vector>
+
#include <signal.h>
#include <libtest/signal.h>
using namespace libtest;
struct socket_st {
- std::vector<int> fd;
+ typedef std::vector< std::pair< int, in_port_t> > socket_port_t;
+ socket_port_t _pair;
+
+ void release(in_port_t _arg)
+ {
+ for(socket_port_t::iterator iter= _pair.begin();
+ iter != _pair.end();
+ iter++)
+ {
+ if ((*iter).second == _arg)
+ {
+ close((*iter).first);
+ }
+ }
+ }
~socket_st()
{
- for(std::vector<int>::iterator iter= fd.begin(); iter != fd.end(); iter++)
+ for(socket_port_t::iterator iter= _pair.begin();
+ iter != _pair.end();
+ iter++)
{
- close(*iter);
+ close((*iter).first);
}
}
};
return global_port;
}
+void release_port(in_port_t arg)
+{
+ all_socket_fd.release(arg);
+}
+
in_port_t get_free_port()
{
in_port_t ret_port= in_port_t(0);
}
}
- all_socket_fd.fd.push_back(sd);
+ all_socket_fd._pair.push_back(std::make_pair(sd, ret_port));
}
if (ret_port > 1024)
LIBTEST_API
in_port_t get_free_port();
+LIBTEST_API
+void release_port(in_port_t arg);
+
} // namespace libtest
return false;
}
+ libtest::release_port(_port);
Application::error_t ret;
if (Application::SUCCESS != (ret= _app.run()))
{
void get_world(Framework *world)
{
- world->_create= world_create;
+ world->create(world_create);
}
make_cerr(const char* filename, int line_number, const char* func) :
detail::log<detail::channelln>(std::cerr, filename, line_number, func)
{ }
+
};
class cerr : public detail::log<detail::channel> {
cerr(const char* filename, int line_number, const char* func) :
detail::log<detail::channel>(std::cout, filename, line_number, func)
{ }
+
};
class clog : public detail::log<detail::channel> {
void get_world(Framework *world)
{
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
{
world->servers().set_servers_to_run(1);
- world->collections= collection;
+ world->collections(collection);
- world->_create= (test_callback_create_fn*)world_create;
- world->_destroy= (test_callback_destroy_fn*)world_destroy;
+ world->create((test_callback_create_fn*)world_create);
+ world->destroy((test_callback_destroy_fn*)world_destroy);
world->set_runner(new LibmemcachedRunner);
void get_world(Framework *world)
{
- world->collections= collection;
+ world->collections(collection);
}
void get_world(Framework *world)
{
- world->collections= collection;
- world->_create= world_create;
- world->_destroy= world_destroy;
+ world->collections(collection);
+ world->create(world_create);
+ world->destroy(world_destroy);
}
world->servers().set_servers_to_run(8);
}
- world->collections= collection;
+ world->collections(collection);
- world->_create= (test_callback_create_fn*)world_create;
- world->_destroy= (test_callback_destroy_fn*)world_destroy;
+ world->create((test_callback_create_fn*)world_create);
+ world->destroy((test_callback_destroy_fn*)world_destroy);
world->set_runner(new LibmemcachedRunner);
void get_world(Framework *world)
{
- world->collections= collection;
+ world->collections(collection);
- world->_create= (test_callback_create_fn*)world_create;
- world->_destroy= (test_callback_destroy_fn*)world_destroy;
+ world->create((test_callback_create_fn*)world_create);
+ world->destroy((test_callback_destroy_fn*)world_destroy);
world->set_runner(new LibmemcachedRunner);
}
void get_world(Framework *world)
{
- world->collections= collection;
+ world->collections(collection);
- world->_create= (test_callback_create_fn*)world_create;
- world->_destroy= (test_callback_destroy_fn*)world_destroy;
+ world->create((test_callback_create_fn*)world_create);
+ world->destroy((test_callback_destroy_fn*)world_destroy);
world->set_runner(new LibmemcachedRunner);
}
void get_world(Framework *frame)
{
- frame->collections= collection;
+ frame->collections(collection);
}
void get_world(Framework *world)
{
- world->collections= collection;
+ world->collections(collection);
- world->_create= world_create;
- world->_destroy= world_destroy;
+ world->create((test_callback_create_fn*)world_create);
+ world->destroy((test_callback_destroy_fn*)world_destroy);
world->set_runner(new LibmemcachedRunner);
}
void get_world(Framework *world)
{
- world->collections= collection;
+ world->collections(collection);
- world->_create= (test_callback_create_fn*)world_create;
- world->_destroy= (test_callback_destroy_fn*)world_destroy;
+ world->create((test_callback_create_fn*)world_create);
+ world->destroy((test_callback_destroy_fn*)world_destroy);
world->set_runner(new LibmemcachedRunner);
void get_world(Framework *world)
{
- world->collections= collection;
+ world->collections(collection);
- world->_create= (test_callback_create_fn*)world_create;
- world->_destroy= (test_callback_destroy_fn*)world_destroy;
+ world->create((test_callback_create_fn*)world_create);
+ world->destroy((test_callback_destroy_fn*)world_destroy);
world->set_runner(new LibmemcachedRunner);
}
void get_world(Framework *world)
{
executable= "./clients/memcapable";
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
executable= "./clients/memflush";
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
executable= "./clients/memslap";
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
executable= "./clients/memtouch";
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
void get_world(Framework *world)
{
- world->collections= collection;
+ world->collections(collection);
}