After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 711715 - gtk object tests: run under local environment
gtk object tests: run under local environment
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-11-09 00:28 UTC by Lars Karlitski
Modified: 2013-12-03 13:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtk object tests: run under local environment (5.80 KB, patch)
2013-11-09 00:28 UTC, Lars Karlitski
needs-work Details | Review
gtk object tests: run under local environment (6.55 KB, patch)
2013-12-02 14:06 UTC, Lars Karlitski
committed Details | Review

Description Lars Karlitski 2013-11-09 00:28:47 UTC
This patch makes the object sanity tests run uninstalled. It generates a local
gschemas.compiled and wraps tests in a GTestDBus.

Can we set the gsettings and gvfs environment variables in gtk_test_init()
instead of duplicating that code in every test?
Comment 1 Lars Karlitski 2013-11-09 00:28:50 UTC
Created attachment 259305 [details] [review]
gtk object tests: run under local environment

Make sure that the tests don't access the host's session bus or
installed gsettings schemas.

Also disable tests for some classes that leak a connection to the
session bus.
Comment 2 Matthias Clasen 2013-11-09 17:58:32 UTC
Shouldn't we fix those leaks instead ?
Comment 3 Lars Karlitski 2013-11-09 18:25:31 UTC
Of course.

The primary purpose of this patch is to have a working `make check` on a system that does not have gtk installed (or an older version). I had to blacklist a few classes in one of the tests because of the leaks I mentioned. (Note that the test already had other classes blacklisted.)

I plan on fixing the leaks, but that will be in separate patches. I'm okay if you don't want to land this until then.
Comment 4 Matthias Clasen 2013-11-10 00:15:50 UTC
Review of attachment 259305 [details] [review]:

Shouldn't we fix those leaks instead?

::: testsuite/gtk/defaultvalue.c
@@ +397,3 @@
+  /* These must be set before before gtk_test_init */
+  g_setenv ("GIO_USE_VFS", "local", TRUE);
+  g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);

Why do you have to set these ? The tests here don't write any settings, afaics...

::: testsuite/gtk/object.c
@@ +310,3 @@
   guint i;
+
+  g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);

Same question here - what goes wrong if you don't set this ?
Comment 5 Allison Karlitskaya (desrt) 2013-11-29 15:36:08 UTC
Review of attachment 259305 [details] [review]:

::: testsuite/gtk/object.c
@@ +310,3 @@
   guint i;
+
+  g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);

you're going to want to set GSETTINGS_SCHEMA_DIR here, as with the other tests...
Comment 6 Lars Karlitski 2013-12-02 14:06:51 UTC
Created attachment 263300 [details] [review]
gtk object tests: run under local environment

Set GSETTINGS_SCHEMA_DIR in object.c. Thanks Ryan.

Get rid of the file glob for settings schemas in Makefile.am as discussed with
Ryan on irc. I'm using --schema-file now, but would feel more comfortable doing
so if that was a publicly documented option.
Comment 7 Lars Karlitski 2013-12-02 14:10:23 UTC
(In reply to comment #4)
> ::: testsuite/gtk/defaultvalue.c
> @@ +397,3 @@
> +  /* These must be set before before gtk_test_init */
> +  g_setenv ("GIO_USE_VFS", "local", TRUE);
> +  g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
> 
> Why do you have to set these ? The tests here don't write any settings,
> afaics...

No, but they might read them which can fail on systems that don't have dconf running.
Comment 8 Allison Karlitskaya (desrt) 2013-12-02 14:32:10 UTC
(In reply to comment #7)
> No, but they might read them which can fail on systems that don't have dconf
> running.

This doesn't really make sense...  dconf doesn't need to be 'running' for reads... OTOH, GSettings will emit a warning about using the memory backend if not explicitly selected and this warning may cause gtester to trap, so maybe it's a good thing to do this explicitly?
Comment 9 Lars Karlitski 2013-12-02 14:37:25 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > No, but they might read them which can fail on systems that don't have dconf
> > running.
> 
> This doesn't really make sense...  dconf doesn't need to be 'running' for
> reads... OTOH, GSettings will emit a warning about using the memory backend if
> not explicitly selected and this warning may cause gtester to trap, so maybe
> it's a good thing to do this explicitly?

Ah sorry, you're right.

Another reason is that we want the tests to operate on default values, not the ones set on the system that the test is running on.
Comment 10 Allison Karlitskaya (desrt) 2013-12-02 14:49:35 UTC
Review of attachment 263300 [details] [review]:

Overall this now looks OK to me...

::: testsuite/gtk/defaultvalue.c
@@ +92,3 @@
+    return;
+
+  /* These leak their GDBusConnections */

GSettings also leaks its D-Bus connection, perhaps explaining your concerns...
Comment 11 Matthias Clasen 2013-12-03 12:13:41 UTC
Review of attachment 263300 [details] [review]:

ok, lets go with this for now then
Comment 12 Lars Karlitski 2013-12-03 13:22:51 UTC
Attachment 263300 [details] pushed as fbff02f - gtk object tests: run under local environment