• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Unit tests for utilities
2  * Copyright (C) 2010 Red Hat, Inc.
3  *
4  * This work is provided "as is"; redistribution and modification
5  * in whole or in part, in any medium, physical or electronic is
6  * permitted without restriction.
7  *
8  * This work is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  *
12  * In no event shall the authors or contributors be liable for any
13  * direct, indirect, incidental, special, exemplary, or consequential
14  * damages (including, but not limited to, procurement of substitute
15  * goods or services; loss of use, data, or profits; or business
16  * interruption) however caused and on any theory of liability, whether
17  * in contract, strict liability, or tort (including negligence or
18  * otherwise) arising in any way out of the use of this software, even
19  * if advised of the possibility of such damage.
20  *
21  * Author: Matthias Clasen
22  */
23 
24 #define GLIB_DISABLE_DEPRECATION_WARNINGS
25 
26 #include "glib.h"
27 #include "glib-private.h"
28 
29 #include <stdlib.h>
30 #include <string.h>
31 #include <stdarg.h>
32 #ifdef G_OS_WIN32
33 #include <windows.h>
34 #endif
35 
36 static gboolean
strv_check(const gchar * const * strv,...)37 strv_check (const gchar * const *strv, ...)
38 {
39   va_list args;
40   gchar *s;
41   gint i;
42 
43   va_start (args, strv);
44   for (i = 0; strv[i]; i++)
45     {
46       s = va_arg (args, gchar*);
47       if (g_strcmp0 (strv[i], s) != 0)
48         {
49           va_end (args);
50           return FALSE;
51         }
52     }
53 
54   va_end (args);
55 
56   return TRUE;
57 }
58 
59 static void
test_language_names(void)60 test_language_names (void)
61 {
62   const gchar * const *names;
63 
64   g_setenv ("LANGUAGE", "de:en_US", TRUE);
65   names = g_get_language_names ();
66   g_assert (strv_check (names, "de", "en_US", "en", "C", NULL));
67 
68   g_setenv ("LANGUAGE", "tt_RU.UTF-8@iqtelif", TRUE);
69   names = g_get_language_names ();
70   g_assert (strv_check (names,
71                         "tt_RU.UTF-8@iqtelif",
72                         "tt_RU@iqtelif",
73                         "tt.UTF-8@iqtelif",
74                         "tt@iqtelif",
75                         "tt_RU.UTF-8",
76                         "tt_RU",
77                         "tt.UTF-8",
78                         "tt",
79                         "C",
80                         NULL));
81 }
82 
83 static void
test_locale_variants(void)84 test_locale_variants (void)
85 {
86   char **v;
87 
88   v = g_get_locale_variants ("fr_BE");
89   g_assert (strv_check ((const gchar * const *) v, "fr_BE", "fr", NULL));
90   g_strfreev (v);
91 
92   v = g_get_locale_variants ("sr_SR@latin");
93   g_assert (strv_check ((const gchar * const *) v, "sr_SR@latin", "sr@latin", "sr_SR", "sr", NULL));
94   g_strfreev (v);
95 }
96 
97 static void
test_version(void)98 test_version (void)
99 {
100   if (g_test_verbose ())
101     g_printerr ("(header %d.%d.%d library %d.%d.%d) ",
102               GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION,
103               glib_major_version, glib_minor_version, glib_micro_version);
104 
105   g_assert (glib_check_version (GLIB_MAJOR_VERSION,
106                                 GLIB_MINOR_VERSION,
107                                 GLIB_MICRO_VERSION) == NULL);
108   g_assert (glib_check_version (GLIB_MAJOR_VERSION,
109                                 GLIB_MINOR_VERSION,
110                                 0) == NULL);
111   g_assert (glib_check_version (GLIB_MAJOR_VERSION - 1,
112                                 0,
113                                 0) != NULL);
114   g_assert (glib_check_version (GLIB_MAJOR_VERSION + 1,
115                                 0,
116                                 0) != NULL);
117   g_assert (glib_check_version (GLIB_MAJOR_VERSION,
118                                 GLIB_MINOR_VERSION + 1,
119                                 0) != NULL);
120   /* don't use + 1 here, since a +/-1 difference can
121    * happen due to post-release version bumps in git
122    */
123   g_assert (glib_check_version (GLIB_MAJOR_VERSION,
124                                 GLIB_MINOR_VERSION,
125                                 GLIB_MICRO_VERSION + 3) != NULL);
126 }
127 
128 static const gchar *argv0;
129 
130 static void
test_appname(void)131 test_appname (void)
132 {
133   const gchar *prgname;
134   const gchar *appname;
135 
136   prgname = g_get_prgname ();
137   appname = g_get_application_name ();
138   g_assert_cmpstr (prgname, ==, argv0);
139   g_assert_cmpstr (appname, ==, prgname);
140 
141   g_set_prgname ("prgname");
142 
143   prgname = g_get_prgname ();
144   appname = g_get_application_name ();
145   g_assert_cmpstr (prgname, ==, "prgname");
146   g_assert_cmpstr (appname, ==, "prgname");
147 
148   g_set_application_name ("appname");
149 
150   prgname = g_get_prgname ();
151   appname = g_get_application_name ();
152   g_assert_cmpstr (prgname, ==, "prgname");
153   g_assert_cmpstr (appname, ==, "appname");
154 }
155 
156 static void
test_tmpdir(void)157 test_tmpdir (void)
158 {
159   g_test_bug ("627969");
160   g_assert_cmpstr (g_get_tmp_dir (), !=, "");
161 }
162 
163 static void
test_bits(void)164 test_bits (void)
165 {
166   gulong mask;
167   gint max_bit;
168   gint i, pos;
169 
170   pos = g_bit_nth_lsf (0, -1);
171   g_assert_cmpint (pos, ==, -1);
172 
173   max_bit = sizeof (gulong) * 8;
174   for (i = 0; i < max_bit; i++)
175     {
176       mask = 1UL << i;
177 
178       pos = g_bit_nth_lsf (mask, -1);
179       g_assert_cmpint (pos, ==, i);
180 
181       pos = g_bit_nth_lsf (mask, i - 3);
182       g_assert_cmpint (pos , ==, i);
183 
184       pos = g_bit_nth_lsf (mask, i);
185       g_assert_cmpint (pos , ==, -1);
186 
187       pos = g_bit_nth_lsf (mask, i + 1);
188       g_assert_cmpint (pos , ==, -1);
189     }
190 
191   pos = g_bit_nth_msf (0, -1);
192   g_assert_cmpint (pos, ==, -1);
193 
194   for (i = 0; i < max_bit; i++)
195     {
196       mask = 1UL << i;
197 
198       pos = g_bit_nth_msf (mask, -1);
199       g_assert_cmpint (pos, ==, i);
200 
201       pos = g_bit_nth_msf (mask, i + 3);
202       g_assert_cmpint (pos , ==, i);
203 
204       pos = g_bit_nth_msf (mask, i);
205       g_assert_cmpint (pos , ==, -1);
206 
207       if (i > 0)
208         {
209           pos = g_bit_nth_msf (mask, i - 1);
210           g_assert_cmpint (pos , ==, -1);
211         }
212     }
213 }
214 
215 static void
test_swap(void)216 test_swap (void)
217 {
218   guint16 a16, b16;
219   guint32 a32, b32;
220   guint64 a64, b64;
221 
222   a16 = 0xaabb;
223   b16 = 0xbbaa;
224 
225   g_assert_cmpint (GUINT16_SWAP_LE_BE (a16), ==, b16);
226 
227   a32 = 0xaaaabbbb;
228   b32 = 0xbbbbaaaa;
229 
230   g_assert_cmpint (GUINT32_SWAP_LE_BE (a32), ==, b32);
231 
232   a64 = G_GUINT64_CONSTANT(0xaaaaaaaabbbbbbbb);
233   b64 = G_GUINT64_CONSTANT(0xbbbbbbbbaaaaaaaa);
234 
235   g_assert_cmpint (GUINT64_SWAP_LE_BE (a64), ==, b64);
236 }
237 
238 static void
test_find_program(void)239 test_find_program (void)
240 {
241   gchar *res;
242 
243 #ifdef G_OS_UNIX
244   res = g_find_program_in_path ("sh");
245   g_assert (res != NULL);
246   g_free (res);
247 
248   res = g_find_program_in_path ("/bin/sh");
249   g_assert (res != NULL);
250   g_free (res);
251 #else
252   /* There's not a lot we can search for that would reliably work both
253    * on real Windows and mingw.
254    */
255 #endif
256 
257   res = g_find_program_in_path ("this_program_does_not_exit");
258   g_assert (res == NULL);
259 
260   res = g_find_program_in_path ("/bin");
261   g_assert (res == NULL);
262 
263   res = g_find_program_in_path ("/etc/passwd");
264   g_assert (res == NULL);
265 }
266 
267 static void
test_debug(void)268 test_debug (void)
269 {
270   GDebugKey keys[] = {
271     { "key1", 1 },
272     { "key2", 2 },
273     { "key3", 4 },
274   };
275   guint res;
276 
277   res = g_parse_debug_string (NULL, keys, G_N_ELEMENTS (keys));
278   g_assert_cmpint (res, ==, 0);
279 
280   res = g_parse_debug_string ("foobabla;#!%!$%112 223", keys, G_N_ELEMENTS (keys));
281   g_assert_cmpint (res, ==, 0);
282 
283   res = g_parse_debug_string ("key1:key2", keys, G_N_ELEMENTS (keys));
284   g_assert_cmpint (res, ==, 3);
285 
286   res = g_parse_debug_string ("key1;key2", keys, G_N_ELEMENTS (keys));
287   g_assert_cmpint (res, ==, 3);
288 
289   res = g_parse_debug_string ("key1,key2", keys, G_N_ELEMENTS (keys));
290   g_assert_cmpint (res, ==, 3);
291 
292   res = g_parse_debug_string ("key1   key2", keys, G_N_ELEMENTS (keys));
293   g_assert_cmpint (res, ==, 3);
294 
295   res = g_parse_debug_string ("key1\tkey2", keys, G_N_ELEMENTS (keys));
296   g_assert_cmpint (res, ==, 3);
297 
298   res = g_parse_debug_string ("all", keys, G_N_ELEMENTS (keys));
299   g_assert_cmpint (res, ==, 7);
300 
301   if (g_test_subprocess ())
302     {
303       res = g_parse_debug_string ("help", keys, G_N_ELEMENTS (keys));
304       g_assert_cmpint (res, ==, 0);
305       return;
306     }
307   g_test_trap_subprocess (NULL, 0, 0);
308   g_test_trap_assert_passed ();
309   g_test_trap_assert_stderr ("*Supported debug values: key1 key2 key3 all help*");
310 }
311 
312 static void
test_codeset(void)313 test_codeset (void)
314 {
315   gchar *c;
316   const gchar *c2;
317 
318   c = g_get_codeset ();
319   g_get_charset (&c2);
320 
321   g_assert_cmpstr (c, ==, c2);
322 
323   g_free (c);
324 }
325 
326 static void
test_codeset2(void)327 test_codeset2 (void)
328 {
329   if (g_test_subprocess ())
330     {
331       const gchar *c;
332       g_setenv ("CHARSET", "UTF-8", TRUE);
333       g_get_charset (&c);
334       g_assert_cmpstr (c, ==, "UTF-8");
335       return;
336     }
337   g_test_trap_subprocess (NULL, 0, 0);
338   g_test_trap_assert_passed ();
339 }
340 
341 static void
test_console_charset(void)342 test_console_charset (void)
343 {
344   const gchar *c1;
345   const gchar *c2;
346 
347 #ifdef G_OS_WIN32
348   /* store current environment and unset $LANG to make sure it does not interfere */
349   const unsigned int initial_cp = GetConsoleOutputCP ();
350   gchar *initial_lang = g_strdup (g_getenv ("LANG"));
351   g_unsetenv ("LANG");
352 
353   /* set console output codepage to something specific (ISO-8859-1 aka CP28591) and query it */
354   SetConsoleOutputCP (28591);
355   g_get_console_charset (&c1);
356   g_assert_cmpstr (c1, ==, "ISO-8859-1");
357 
358   /* set $LANG to something specific (should override the console output codepage) and query it */
359   g_setenv ("LANG", "de_DE.ISO-8859-15@euro", TRUE);
360   g_get_console_charset (&c2);
361   g_assert_cmpstr (c2, ==, "ISO-8859-15");
362 
363   /* reset environment */
364   if (initial_cp)
365     SetConsoleOutputCP (initial_cp);
366   if (initial_lang)
367     g_setenv ("LANG", initial_lang, TRUE);
368   g_free (initial_lang);
369 #else
370   g_get_charset (&c1);
371   g_get_console_charset (&c2);
372 
373   g_assert_cmpstr (c1, ==, c2);
374 #endif
375 }
376 
377 static void
test_basename(void)378 test_basename (void)
379 {
380   const gchar *path = "/path/to/a/file/deep/down.sh";
381   const gchar *b;
382 
383   b = g_basename (path);
384 
385   g_assert_cmpstr (b, ==, "down.sh");
386 }
387 
388 extern const gchar *glib_pgettext (const gchar *msgidctxt, gsize msgidoffset);
389 
390 static void
test_gettext(void)391 test_gettext (void)
392 {
393   const gchar *am0, *am1, *am2, *am3;
394 
395   am0 = glib_pgettext ("GDateTime\004AM", strlen ("GDateTime") + 1);
396   am1 = g_dpgettext ("glib20", "GDateTime\004AM", strlen ("GDateTime") + 1);
397   am2 = g_dpgettext ("glib20", "GDateTime|AM", 0);
398   am3 = g_dpgettext2 ("glib20", "GDateTime", "AM");
399 
400   g_assert_cmpstr (am0, ==, am1);
401   g_assert_cmpstr (am1, ==, am2);
402   g_assert_cmpstr (am2, ==, am3);
403 }
404 
405 static void
test_username(void)406 test_username (void)
407 {
408   const gchar *name;
409 
410   name = g_get_user_name ();
411 
412   g_assert (name != NULL);
413 }
414 
415 static void
test_realname(void)416 test_realname (void)
417 {
418   const gchar *name;
419 
420   name = g_get_real_name ();
421 
422   g_assert (name != NULL);
423 }
424 
425 static void
test_hostname(void)426 test_hostname (void)
427 {
428   const gchar *name;
429 
430   name = g_get_host_name ();
431 
432   g_assert (name != NULL);
433   g_assert_true (g_utf8_validate (name, -1, NULL));
434 }
435 
436 #ifdef G_OS_UNIX
437 static void
test_xdg_dirs(void)438 test_xdg_dirs (void)
439 {
440   gchar *xdg;
441   const gchar *dir;
442   const gchar * const *dirs;
443   gchar *s;
444 
445   xdg = g_strdup (g_getenv ("XDG_CONFIG_HOME"));
446   if (!xdg)
447     xdg = g_build_filename (g_get_home_dir (), ".config", NULL);
448 
449   dir = g_get_user_config_dir ();
450 
451   g_assert_cmpstr (dir, ==, xdg);
452   g_free (xdg);
453 
454   xdg = g_strdup (g_getenv ("XDG_DATA_HOME"));
455   if (!xdg)
456     xdg = g_build_filename (g_get_home_dir (), ".local", "share", NULL);
457 
458   dir = g_get_user_data_dir ();
459 
460   g_assert_cmpstr (dir, ==, xdg);
461   g_free (xdg);
462 
463   xdg = g_strdup (g_getenv ("XDG_CACHE_HOME"));
464   if (!xdg)
465     xdg = g_build_filename (g_get_home_dir (), ".cache", NULL);
466 
467   dir = g_get_user_cache_dir ();
468 
469   g_assert_cmpstr (dir, ==, xdg);
470   g_free (xdg);
471 
472   xdg = g_strdup (g_getenv ("XDG_RUNTIME_DIR"));
473   if (!xdg)
474     xdg = g_strdup (g_get_user_cache_dir ());
475 
476   dir = g_get_user_runtime_dir ();
477 
478   g_assert_cmpstr (dir, ==, xdg);
479   g_free (xdg);
480 
481   xdg = (gchar *)g_getenv ("XDG_CONFIG_DIRS");
482   if (!xdg)
483     xdg = "/etc/xdg";
484 
485   dirs = g_get_system_config_dirs ();
486 
487   s = g_strjoinv (":", (gchar **)dirs);
488 
489   g_assert_cmpstr (s, ==, xdg);
490 
491   g_free (s);
492 }
493 #endif
494 
495 static void
test_special_dir(void)496 test_special_dir (void)
497 {
498   const gchar *dir, *dir2;
499 
500   dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
501   g_reload_user_special_dirs_cache ();
502   dir2 = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
503 
504   g_assert_cmpstr (dir, ==, dir2);
505 }
506 
507 static void
test_desktop_special_dir(void)508 test_desktop_special_dir (void)
509 {
510   const gchar *dir, *dir2;
511 
512   dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
513   g_assert (dir != NULL);
514 
515   g_reload_user_special_dirs_cache ();
516   dir2 = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
517   g_assert (dir2 != NULL);
518 }
519 
520 static gboolean
source_test(gpointer data)521 source_test (gpointer data)
522 {
523   g_assert_not_reached ();
524   return G_SOURCE_REMOVE;
525 }
526 
527 static void
test_clear_source(void)528 test_clear_source (void)
529 {
530   guint id;
531 
532   id = g_idle_add (source_test, NULL);
533   g_assert_cmpuint (id, >, 0);
534 
535   g_clear_handle_id (&id, g_source_remove);
536   g_assert_cmpuint (id, ==, 0);
537 
538   id = g_timeout_add (100, source_test, NULL);
539   g_assert_cmpuint (id, >, 0);
540 
541   g_clear_handle_id (&id, g_source_remove);
542   g_assert_cmpuint (id, ==, 0);
543 }
544 
545 static void
test_clear_pointer(void)546 test_clear_pointer (void)
547 {
548   gpointer a;
549 
550   a = g_malloc (5);
551   g_clear_pointer (&a, g_free);
552   g_assert (a == NULL);
553 
554   a = g_malloc (5);
555   (g_clear_pointer) (&a, g_free);
556   g_assert (a == NULL);
557 }
558 
559 /* Test that g_clear_pointer() works with a GDestroyNotify which contains a cast.
560  * See https://gitlab.gnome.org/GNOME/glib/issues/1425 */
561 static void
test_clear_pointer_cast(void)562 test_clear_pointer_cast (void)
563 {
564   GHashTable *hash_table = NULL;
565 
566   hash_table = g_hash_table_new (g_str_hash, g_str_equal);
567 
568   g_assert_nonnull (hash_table);
569 
570   g_clear_pointer (&hash_table, (void (*) (GHashTable *)) g_hash_table_destroy);
571 
572   g_assert_null (hash_table);
573 }
574 
575 /* Test that the macro version of g_clear_pointer() only evaluates its argument
576  * once, just like the function version would. */
577 static void
test_clear_pointer_side_effects(void)578 test_clear_pointer_side_effects (void)
579 {
580   gchar **my_string_array, **i;
581 
582   my_string_array = g_new0 (gchar*, 3);
583   my_string_array[0] = g_strdup ("hello");
584   my_string_array[1] = g_strdup ("there");
585   my_string_array[2] = NULL;
586 
587   i = my_string_array;
588 
589   g_clear_pointer (i++, g_free);
590 
591   g_assert_true (i == &my_string_array[1]);
592   g_assert_null (my_string_array[0]);
593   g_assert_nonnull (my_string_array[1]);
594   g_assert_null (my_string_array[2]);
595 
596   g_free (my_string_array[1]);
597   g_free (my_string_array[2]);
598   g_free (my_string_array);
599 }
600 
601 static int obj_count;
602 
603 static void
get_obj(gpointer * obj_out)604 get_obj (gpointer *obj_out)
605 {
606   gpointer obj = g_malloc (5);
607   obj_count++;
608 
609   if (obj_out)
610     *obj_out = g_steal_pointer (&obj);
611 
612   if (obj)
613     {
614       g_free (obj);
615       obj_count--;
616     }
617 }
618 
619 static void
test_take_pointer(void)620 test_take_pointer (void)
621 {
622   gpointer a;
623   gpointer b;
624 
625   get_obj (NULL);
626 
627   get_obj (&a);
628   g_assert (a);
629 
630   /* ensure that it works to skip the macro */
631   b = (g_steal_pointer) (&a);
632   g_assert (!a);
633   obj_count--;
634   g_free (b);
635 
636   g_assert (!obj_count);
637 }
638 
639 static void
test_misc_mem(void)640 test_misc_mem (void)
641 {
642   gpointer a;
643 
644   a = g_try_malloc (0);
645   g_assert (a == NULL);
646 
647   a = g_try_malloc0 (0);
648   g_assert (a == NULL);
649 
650   a = g_malloc (16);
651   a = g_try_realloc (a, 20);
652   a = g_try_realloc (a, 0);
653 
654   g_assert (a == NULL);
655 }
656 
657 static void
test_nullify(void)658 test_nullify (void)
659 {
660   gpointer p = &test_nullify;
661 
662   g_assert (p != NULL);
663 
664   g_nullify_pointer (&p);
665 
666   g_assert (p == NULL);
667 }
668 
669 static void
atexit_func(void)670 atexit_func (void)
671 {
672   g_print ("atexit called");
673 }
674 
675 static void
test_atexit(void)676 test_atexit (void)
677 {
678   if (g_test_subprocess ())
679     {
680       g_atexit (atexit_func);
681       return;
682     }
683   g_test_trap_subprocess (NULL, 0, 0);
684   g_test_trap_assert_passed ();
685   g_test_trap_assert_stdout ("*atexit called*");
686 }
687 
688 static void
test_check_setuid(void)689 test_check_setuid (void)
690 {
691   gboolean res;
692 
693   res = GLIB_PRIVATE_CALL(g_check_setuid) ();
694   g_assert (!res);
695 }
696 
697 /* Test the defined integer limits are correct, as some compilers have had
698  * problems with signed/unsigned conversion in the past. These limits should not
699  * vary between platforms, compilers or architectures.
700  *
701  * Use string comparisons to avoid the same systematic problems with unary minus
702  * application in C++. See https://gitlab.gnome.org/GNOME/glib/issues/1663. */
703 static void
test_int_limits(void)704 test_int_limits (void)
705 {
706   gchar *str = NULL;
707 
708   g_test_bug ("https://gitlab.gnome.org/GNOME/glib/issues/1663");
709 
710   str = g_strdup_printf ("%d %d %u\n"
711                          "%" G_GINT16_FORMAT " %" G_GINT16_FORMAT " %" G_GUINT16_FORMAT "\n"
712                          "%" G_GINT32_FORMAT " %" G_GINT32_FORMAT " %" G_GUINT32_FORMAT "\n"
713                          "%" G_GINT64_FORMAT " %" G_GINT64_FORMAT " %" G_GUINT64_FORMAT "\n",
714                          G_MININT8, G_MAXINT8, G_MAXUINT8,
715                          G_MININT16, G_MAXINT16, G_MAXUINT16,
716                          G_MININT32, G_MAXINT32, G_MAXUINT32,
717                          G_MININT64, G_MAXINT64, G_MAXUINT64);
718 
719   g_assert_cmpstr (str, ==,
720                    "-128 127 255\n"
721                    "-32768 32767 65535\n"
722                    "-2147483648 2147483647 4294967295\n"
723                    "-9223372036854775808 9223372036854775807 18446744073709551615\n");
724   g_free (str);
725 }
726 
727 int
main(int argc,char * argv[])728 main (int   argc,
729       char *argv[])
730 {
731   argv0 = argv[0];
732 
733   /* for tmpdir test, need to do this early before g_get_any_init */
734   g_setenv ("TMPDIR", "", TRUE);
735   g_unsetenv ("TMP");
736   g_unsetenv ("TEMP");
737 
738   /* g_test_init() only calls g_set_prgname() if g_get_prgname()
739    * returns %NULL, but g_get_prgname() on Windows never returns NULL.
740    * So we need to do this by hand to make test_appname() work on
741    * Windows.
742    */
743   g_set_prgname (argv[0]);
744 
745   g_test_init (&argc, &argv, NULL);
746   g_test_bug_base ("http://bugzilla.gnome.org/");
747 
748   g_test_add_func ("/utils/language-names", test_language_names);
749   g_test_add_func ("/utils/locale-variants", test_locale_variants);
750   g_test_add_func ("/utils/version", test_version);
751   g_test_add_func ("/utils/appname", test_appname);
752   g_test_add_func ("/utils/tmpdir", test_tmpdir);
753   g_test_add_func ("/utils/bits", test_bits);
754   g_test_add_func ("/utils/swap", test_swap);
755   g_test_add_func ("/utils/find-program", test_find_program);
756   g_test_add_func ("/utils/debug", test_debug);
757   g_test_add_func ("/utils/codeset", test_codeset);
758   g_test_add_func ("/utils/codeset2", test_codeset2);
759   g_test_add_func ("/utils/console-charset", test_console_charset);
760   g_test_add_func ("/utils/basename", test_basename);
761   g_test_add_func ("/utils/gettext", test_gettext);
762   g_test_add_func ("/utils/username", test_username);
763   g_test_add_func ("/utils/realname", test_realname);
764   g_test_add_func ("/utils/hostname", test_hostname);
765 #ifdef G_OS_UNIX
766   g_test_add_func ("/utils/xdgdirs", test_xdg_dirs);
767 #endif
768   g_test_add_func ("/utils/specialdir", test_special_dir);
769   g_test_add_func ("/utils/specialdir/desktop", test_desktop_special_dir);
770   g_test_add_func ("/utils/clear-pointer", test_clear_pointer);
771   g_test_add_func ("/utils/clear-pointer-cast", test_clear_pointer_cast);
772   g_test_add_func ("/utils/clear-pointer/side-effects", test_clear_pointer_side_effects);
773   g_test_add_func ("/utils/take-pointer", test_take_pointer);
774   g_test_add_func ("/utils/clear-source", test_clear_source);
775   g_test_add_func ("/utils/misc-mem", test_misc_mem);
776   g_test_add_func ("/utils/nullify", test_nullify);
777   g_test_add_func ("/utils/atexit", test_atexit);
778   g_test_add_func ("/utils/check-setuid", test_check_setuid);
779   g_test_add_func ("/utils/int-limits", test_int_limits);
780 
781   return g_test_run ();
782 }
783