[dconf: 110/111] test/: finish testing of system source
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf: 110/111] test/: finish testing of system source
- Date: Fri, 13 Jul 2012 18:14:36 +0000 (UTC)
commit 0bd2f8ee907b2c3e74b20c3cd58b0da1b6a586fb
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Jul 13 13:21:10 2012 -0400
test/: finish testing of system source
Use the invalidation capabilities of the mock gvdb backend to test that
the system source handles reopening properly.
tests/engine.c | 37 +++++++++++++++++++++++++++++++------
1 files changed, 31 insertions(+), 6 deletions(-)
---
diff --git a/tests/engine.c b/tests/engine.c
index ecc77fb..37a3e0f 100644
--- a/tests/engine.c
+++ b/tests/engine.c
@@ -328,7 +328,8 @@ static void
test_system_source (void)
{
DConfEngineSource *source;
- GvdbTable *table;
+ GvdbTable *first_table;
+ GvdbTable *next_table;
gboolean reopened;
source = dconf_engine_source_new ("system-db:site");
@@ -351,8 +352,8 @@ test_system_source (void)
g_assert (!reopened);
/* Create the file after the fact and make sure it opens properly */
- table = dconf_mock_gvdb_table_new ();
- dconf_mock_gvdb_install ("/etc/dconf/db/site", table);
+ first_table = dconf_mock_gvdb_table_new ();
+ dconf_mock_gvdb_install ("/etc/dconf/db/site", first_table);
reopened = dconf_engine_source_refresh (source);
g_assert (reopened);
@@ -368,17 +369,41 @@ test_system_source (void)
g_test_trap_assert_stderr_unmatched ("*degraded*degraded*");
/* Create the file before the first refresh attempt */
- table = dconf_mock_gvdb_table_new ();
- dconf_mock_gvdb_install ("/etc/dconf/db/site", table);
+ first_table = dconf_mock_gvdb_table_new ();
+ dconf_mock_gvdb_install ("/etc/dconf/db/site", first_table);
+ /* Hang on to a copy for ourselves for below... */
+ gvdb_table_ref (first_table);
/* See that we get the database. */
reopened = dconf_engine_source_refresh (source);
g_assert (reopened);
- g_assert (source->values != NULL);
+ g_assert (source->values == first_table);
/* Do a refresh, make sure there is no change. */
reopened = dconf_engine_source_refresh (source);
g_assert (!reopened);
+ g_assert (source->values == first_table);
+
+ /* Replace the table on "disk" but don't invalidate the old one */
+ next_table = dconf_mock_gvdb_table_new ();
+ dconf_mock_gvdb_install ("/etc/dconf/db/site", next_table);
+
+ /* Make sure the old table remains open (ie: no IO performed) */
+ reopened = dconf_engine_source_refresh (source);
+ g_assert (!reopened);
+ g_assert (source->values == first_table);
+
+ /* Now mark the first table invalid and reopen */
+ dconf_mock_gvdb_table_invalidate (first_table);
+ gvdb_table_unref (first_table);
+ reopened = dconf_engine_source_refresh (source);
+ g_assert (reopened);
+ g_assert (source->values == next_table);
+
+ /* Remove the file entirely and do the same thing */
+ dconf_mock_gvdb_install ("/etc/dconf/db/site", NULL);
+ reopened = dconf_engine_source_refresh (source);
+ g_assert (!reopened);
dconf_engine_source_free (source);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]