summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2012-07-12 22:58:26 -0400
committerRyan Lortie <desrt@desrt.ca>2012-07-12 22:58:26 -0400
commit2b182bb83a3fbaa72446f0f30f09b39a6f9c6c5f (patch)
tree07cc1abbd7d974c3a1a6952d5567eba31b0ae606
parent8b08defe6463ad1f2e74d3e8708dd2af7d597d04 (diff)
downloaddconf-2b182bb83a3fbaa72446f0f30f09b39a6f9c6c5f.tar.gz
tests/: add test for system source
-rw-r--r--tests/engine.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/engine.c b/tests/engine.c
index 6018cd1..84d7de5 100644
--- a/tests/engine.c
+++ b/tests/engine.c
@@ -324,6 +324,65 @@ test_user_source (void)
dconf_mock_shm_reset ();
}
+static void
+test_system_source (void)
+{
+ DConfEngineSource *source;
+ DConfMockGvdbTable *table;
+ gboolean reopened;
+
+ source = dconf_engine_source_new ("system-db:site");
+ g_assert (source != NULL);
+
+ /* Check to see that we get the warning about the missing file. */
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_log_set_always_fatal (G_LOG_LEVEL_ERROR);
+
+ /* Failing to open should return FALSE from refresh */
+ reopened = dconf_engine_source_refresh (source);
+ g_assert (!reopened);
+ g_assert (source->values == NULL);
+
+ /* Attempt the reopen to make sure we don't get two warnings.
+ * We should see FALSE again since we go from NULL to NULL.
+ */
+ reopened = dconf_engine_source_refresh (source);
+ 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);
+
+ reopened = dconf_engine_source_refresh (source);
+ g_assert (reopened);
+ g_assert (source->values != NULL);
+
+ dconf_engine_source_free (source);
+
+ exit (0);
+ }
+ g_test_trap_assert_passed ();
+ /* Check that we only saw the warning, but only one time. */
+ g_test_trap_assert_stderr ("*this gvdb does not exist; expect degraded performance*");
+ 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);
+
+ /* See that we get the database. */
+ reopened = dconf_engine_source_refresh (source);
+ g_assert (reopened);
+ g_assert (source->values != NULL);
+
+ /* Do a refresh, make sure there is no change. */
+ reopened = dconf_engine_source_refresh (source);
+ g_assert (!reopened);
+
+ dconf_engine_source_free (source);
+}
+
int
main (int argc, char **argv)
{
@@ -337,6 +396,7 @@ main (int argc, char **argv)
g_test_add_func ("/engine/profile-parser", test_profile_parser);
g_test_add_func ("/engine/signal-threadsafety", test_signal_threadsafety);
g_test_add_func ("/engine/sources/user", test_user_source);
+ g_test_add_func ("/engine/sources/system", test_system_source);
return g_test_run ();
}