[glom] Self-Hosting test: Check that cleanup works.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Self-Hosting test: Check that cleanup works.
- Date: Mon, 26 Apr 2010 15:20:16 +0000 (UTC)
commit a1b61b71a3c76add39b95cbad92b6c911917375c
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Apr 26 17:17:47 2010 +0200
Self-Hosting test: Check that cleanup works.
* Makefile_tests.am:
* glom/libglom/connectionpool.[h|cc]:
* glom/libglom/connectionpool_backends/backend.[h|cc]:
* glom/libglom/connectionpool_backends/postgres_self.[h|cc]:
* tests/test_selfhosting_new_empty/test_selfhosting_new_empty.cc:
Make cleanup() return a bool, so we can check it, because this fails sometimes.
Use the standard username and password.
ChangeLog | 12 ++++++++++++
Makefile_tests.am | 2 +-
glom/libglom/connectionpool.cc | 8 ++++++--
glom/libglom/connectionpool.h | 2 +-
glom/libglom/connectionpool_backends/backend.cc | 3 ++-
glom/libglom/connectionpool_backends/backend.h | 2 +-
.../connectionpool_backends/postgres_self.cc | 7 +++++--
.../connectionpool_backends/postgres_self.h | 2 +-
.../test_selfhosting_new_empty.cc | 17 +++++++++++------
9 files changed, 40 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 34c2da5..629bc0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-04-26 Murray Cumming <murrayc murrayc com>
+
+ Self-Hosting test: Check that cleanup works.
+
+ * Makefile_tests.am:
+ * glom/libglom/connectionpool.[h|cc]:
+ * glom/libglom/connectionpool_backends/backend.[h|cc]:
+ * glom/libglom/connectionpool_backends/postgres_self.[h|cc]:
+ * tests/test_selfhosting_new_empty/test_selfhosting_new_empty.cc:
+ Make cleanup() return a bool, so we can check it, because this fails sometimes.
+ Use the standard username and password.
+
2010-04-26 Daniel Elstner <danielk openismus com>
Heavily cut the pyglom_reference build magic
diff --git a/Makefile_tests.am b/Makefile_tests.am
index ce52e79..af96533 100644
--- a/Makefile_tests.am
+++ b/Makefile_tests.am
@@ -139,4 +139,4 @@ tests_test_python_execute_script_LDADD = $(tests_ldadd) $(GLOM_LIBS) $(PYTHON_LI
tests_import_test_parsing_LDADD = $(LIBGLOM_LIBS) $(GLOM_LIBS)
tests_import_test_signals_LDADD = $(LIBGLOM_LIBS) $(GLOM_LIBS)
tests_test_glade_derived_instantiation_LDADD = $(glom_all_libs)
-tests_test_selfhosting_new_empty_test_selfhosting_new_empty_LDADD = $(tests_ldadd) $(LIBGLOM_LIBS)
+tests_test_selfhosting_new_empty_test_selfhosting_new_empty_LDADD = $(glom_all_libs)
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index 13b522d..9c572b7 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -588,7 +588,7 @@ bool ConnectionPool::startup(const SlotProgress& slot_progress, bool network_sha
return true;
}
-void ConnectionPool::cleanup(const SlotProgress& slot_progress)
+bool ConnectionPool::cleanup(const SlotProgress& slot_progress)
{
// Without a valid backend instance we should not state that we are ready to
// connect. Fixes crash described in #577821.
@@ -599,8 +599,10 @@ void ConnectionPool::cleanup(const SlotProgress& slot_progress)
// set_not_ready_to_connect()?
set_ready_to_connect(false);
+ bool result = false;
+
if(m_backend.get())
- m_backend->cleanup(slot_progress);
+ result = m_backend->cleanup(slot_progress);
//Make sure that connect() tries to make a new connection:
invalidate_connection();
@@ -614,6 +616,8 @@ void ConnectionPool::cleanup(const SlotProgress& slot_progress)
//We don't need the segfault handler anymore:
signal(SIGSEGV, previous_sig_handler);
previous_sig_handler = SIG_DFL; /* Arbitrary default */
+
+ return result;
}
diff --git a/glom/libglom/connectionpool.h b/glom/libglom/connectionpool.h
index f285534..a881229 100644
--- a/glom/libglom/connectionpool.h
+++ b/glom/libglom/connectionpool.h
@@ -201,7 +201,7 @@ public:
* @param slot_progress A callback to call while the work is still happening.
* @param parent_window The parent window (transient for) of any dialogs shown during this operation.
*/
- void cleanup(const SlotProgress& slot_progress);
+ bool cleanup(const SlotProgress& slot_progress);
/** Change the database server's configration to allow or prevent access from
* other users on the network.
diff --git a/glom/libglom/connectionpool_backends/backend.cc b/glom/libglom/connectionpool_backends/backend.cc
index a0be64b..201786c 100644
--- a/glom/libglom/connectionpool_backends/backend.cc
+++ b/glom/libglom/connectionpool_backends/backend.cc
@@ -55,8 +55,9 @@ bool Backend::startup(const SlotProgress& /* slot_progress */, bool /* network_s
return true;
}
-void Backend::cleanup(const SlotProgress& /* slot_progress */)
+bool Backend::cleanup(const SlotProgress& /* slot_progress */)
{
+ return true;
}
bool Backend::set_network_shared(const SlotProgress& /* slot_progress */, bool /* network_shared */)
diff --git a/glom/libglom/connectionpool_backends/backend.h b/glom/libglom/connectionpool_backends/backend.h
index 241d97a..ed85395 100644
--- a/glom/libglom/connectionpool_backends/backend.h
+++ b/glom/libglom/connectionpool_backends/backend.h
@@ -147,7 +147,7 @@ protected:
*
* @param slot_progress A callback to call while the work is still happening.
*/
- virtual void cleanup(const SlotProgress& slot_progress);
+ virtual bool cleanup(const SlotProgress& slot_progress);
/** Change the database server's configration to allow or prevent access from
* other users on the network.
diff --git a/glom/libglom/connectionpool_backends/postgres_self.cc b/glom/libglom/connectionpool_backends/postgres_self.cc
index fc6b25c..9689bbe 100644
--- a/glom/libglom/connectionpool_backends/postgres_self.cc
+++ b/glom/libglom/connectionpool_backends/postgres_self.cc
@@ -519,14 +519,14 @@ bool PostgresSelfHosted::startup(const SlotProgress& slot_progress, bool network
return true;
}
-void PostgresSelfHosted::cleanup(const SlotProgress& slot_progress)
+bool PostgresSelfHosted::cleanup(const SlotProgress& slot_progress)
{
// This seems to be called twice sometimes, so we don't assert here until
// this is fixed.
//g_assert(get_self_hosting_active());
if(!get_self_hosting_active())
- return; //Don't try to stop it if we have not started it.
+ return true; //Don't try to stop it if we have not started it.
const std::string dbdir_uri = m_self_hosting_data_uri;
const std::string dbdir = Glib::filename_from_uri(dbdir_uri);
@@ -558,10 +558,13 @@ void PostgresSelfHosted::cleanup(const SlotProgress& slot_progress)
if(!result)
{
std::cerr << "Error while attempting (for a second time) to stop self-hosting of the database." << std::endl;
+ return false;
}
}
m_port = 0;
+
+ return true;
}
diff --git a/glom/libglom/connectionpool_backends/postgres_self.h b/glom/libglom/connectionpool_backends/postgres_self.h
index 17af78d..d36769f 100644
--- a/glom/libglom/connectionpool_backends/postgres_self.h
+++ b/glom/libglom/connectionpool_backends/postgres_self.h
@@ -65,7 +65,7 @@ private:
virtual InitErrors initialize(const SlotProgress& slot_progress, const Glib::ustring& initial_username, const Glib::ustring& password, bool network_shared = false);
virtual bool startup(const SlotProgress& slot_progress, bool network_shared = false);
- virtual void cleanup(const SlotProgress& slot_progress);
+ virtual bool cleanup(const SlotProgress& slot_progress);
virtual bool set_network_shared(const SlotProgress& slot_progress, bool network_shared = true);
virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, std::auto_ptr<ExceptionConnection>& error);
diff --git a/tests/test_selfhosting_new_empty/test_selfhosting_new_empty.cc b/tests/test_selfhosting_new_empty/test_selfhosting_new_empty.cc
index 5e6d9c8..562c630 100644
--- a/tests/test_selfhosting_new_empty/test_selfhosting_new_empty.cc
+++ b/tests/test_selfhosting_new_empty/test_selfhosting_new_empty.cc
@@ -21,8 +21,9 @@
#include <libglom/document/document.h>
#include <libglom/connectionpool.h>
#include <libglom/connectionpool_backends/postgres_self.h>
-#include <giomm/file.h>
#include <libglom/init.h>
+#include <glom/glom_privs.h>
+#include <giomm/file.h>
static void on_initialize_progress()
{
@@ -147,19 +148,22 @@ int main()
document.set_hosting_mode(Glom::Document::HOSTING_MODE_POSTGRES_SELF);
document.set_is_example_file(false);
+ document.set_network_shared(false);
const bool saved = document.save();
g_assert(saved);
//Specify the backend and backend-specific details to be used by the connectionpool.
connection_pool->setup_from_document(&document);
- const Glib::ustring password = "testpassword";
- const Glib::ustring user = "testuser";
+ //We must specify a default username and password:
+ Glib::ustring password;
+ const Glib::ustring user = Glom::Privs::get_default_developer_user_name(password);
connection_pool->set_user(user);
connection_pool->set_password(password);
//Create the self-hosting files:
- const Glom::ConnectionPool::InitErrors initialized_errors = connection_pool->initialize( sigc::ptr_fun(&on_initialize_progress) );
+ const Glom::ConnectionPool::InitErrors initialized_errors =
+ connection_pool->initialize( sigc::ptr_fun(&on_initialize_progress) );
g_assert(initialized_errors == Glom::ConnectionPool::Backend::INITERROR_NONE);
//Start self-hosting:
@@ -167,9 +171,10 @@ int main()
const bool started = connection_pool->startup( sigc::ptr_fun(&on_startup_progress) );
g_assert(started);
- connection_pool->cleanup( sigc::ptr_fun(&on_cleanup_progress) );
+ const bool stopped = connection_pool->cleanup( sigc::ptr_fun(&on_cleanup_progress) );
+ g_assert(stopped);
- //Make sure the directory is removed at the end:
+ //Make sure the directory is removed at the end,
{
const Glib::ustring uri = Glib::filename_to_uri(temp_filepath_dir);
delete_directory(uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]