-/* uTest Copyright (C) 2011 Data Differential, http://datadifferential.com/
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
*
- * Use and distribution licensed under the BSD license. See
- * the COPYING file in the parent directory for full text.
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <libtest/common.h>
-test_return_t Framework::destroy(void* arg)
-{
- if (_destroy)
- {
- return _destroy(arg);
- }
+#include <config.h>
+#include <libtest/common.h>
+#include <iostream>
- return TEST_SUCCESS;
-}
+using namespace libtest;
-test_return_t Framework::Item::flush(void* arg, test_st* run)
+Framework::Framework() :
+ collections(NULL),
+ _create(NULL),
+ _destroy(NULL),
+ _runner(NULL),
+ _socket(false),
+ _creators_ptr(NULL)
{
- if (run->requires_flush and _flush)
- {
- return _flush(arg);
- }
-
- return TEST_SUCCESS;
}
-test_return_t Framework::on_error(const test_return_t rc, void* arg)
+Framework::~Framework()
{
- if (_on_error and test_failed(_on_error(rc, arg)))
+ if (_destroy and _destroy(_creators_ptr))
{
- return TEST_FAILURE;
+ Error << "Failure in _destroy(), some resources may not have been cleaned up.";
}
- return TEST_SUCCESS;
+ _servers.shutdown();
+
+ delete _runner;
}
-test_return_t Framework::startup(void* arg)
+libtest::Runner *Framework::runner()
{
- if (collection_startup)
+ if (_runner == NULL)
{
- return collection_startup(arg);
+ _runner= new Runner;
}
+ _runner->set_servers(_servers);
- return TEST_SUCCESS;
+ return _runner;
}
-test_return_t Framework::Item::startup(void* arg)
+void* Framework::create(test_return_t& arg)
{
- if (_startup)
+ arg= TEST_SUCCESS;
+ if (_create)
{
- return _startup(arg);
+ return _creators_ptr= _create(_servers, arg);
}
- return TEST_SUCCESS;
+ return NULL;
}