1 /* GLib testing framework examples and tests
2 * Copyright (C) 2007 Imendio AB
3 * Authors: Tim Janik
4 *
5 * This work is provided "as is"; redistribution and modification
6 * in whole or in part, in any medium, physical or electronic is
7 * permitted without restriction.
8 *
9 * This work is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 *
13 * In no event shall the authors or contributors be liable for any
14 * direct, indirect, incidental, special, exemplary, or consequential
15 * damages (including, but not limited to, procurement of substitute
16 * goods or services; loss of use, data, or profits; or business
17 * interruption) however caused and on any theory of liability, whether
18 * in contract, strict liability, or tort (including negligence or
19 * otherwise) arising in any way out of the use of this software, even
20 * if advised of the possibility of such damage.
21 */
22
23 #include "config.h"
24
25 /* We want to distinguish between messages originating from libglib
26 * and messages originating from this program.
27 */
28 #undef G_LOG_DOMAIN
29 #define G_LOG_DOMAIN "testing"
30
31 #include <glib.h>
32 #include <locale.h>
33 #include <stdlib.h>
34 #include <string.h>
35
36 /* test assertion variants */
37 static void
test_assertions_bad_cmpvariant_types(void)38 test_assertions_bad_cmpvariant_types (void)
39 {
40 GVariant *v1, *v2;
41
42 v1 = g_variant_new_boolean (TRUE);
43 v2 = g_variant_new_string ("hello");
44
45 g_assert_cmpvariant (v1, v2);
46
47 g_variant_unref (v2);
48 g_variant_unref (v1);
49
50 exit (0);
51 }
52
53 static void
test_assertions_bad_cmpvariant_values(void)54 test_assertions_bad_cmpvariant_values (void)
55 {
56 GVariant *v1, *v2;
57
58 v1 = g_variant_new_string ("goodbye");
59 v2 = g_variant_new_string ("hello");
60
61 g_assert_cmpvariant (v1, v2);
62
63 g_variant_unref (v2);
64 g_variant_unref (v1);
65
66 exit (0);
67 }
68
69 static void
test_assertions_bad_cmpstrv_null1(void)70 test_assertions_bad_cmpstrv_null1 (void)
71 {
72 const char *strv[] = { "one", "two", "three", NULL };
73 g_assert_cmpstrv (strv, NULL);
74 exit (0);
75 }
76
77 static void
test_assertions_bad_cmpstrv_null2(void)78 test_assertions_bad_cmpstrv_null2 (void)
79 {
80 const char *strv[] = { "one", "two", "three", NULL };
81 g_assert_cmpstrv (NULL, strv);
82 exit (0);
83 }
84
85 static void
test_assertions_bad_cmpstrv_length(void)86 test_assertions_bad_cmpstrv_length (void)
87 {
88 const char *strv1[] = { "one", "two", "three", NULL };
89 const char *strv2[] = { "one", "two", NULL };
90 g_assert_cmpstrv (strv1, strv2);
91 exit (0);
92 }
93
94 static void
test_assertions_bad_cmpstrv_values(void)95 test_assertions_bad_cmpstrv_values (void)
96 {
97 const char *strv1[] = { "one", "two", "three", NULL };
98 const char *strv2[] = { "one", "too", "three", NULL };
99 g_assert_cmpstrv (strv1, strv2);
100 exit (0);
101 }
102
103 static void
test_assertions_bad_cmpstr(void)104 test_assertions_bad_cmpstr (void)
105 {
106 g_assert_cmpstr ("fzz", !=, "fzz");
107 exit (0);
108 }
109
110 static void
test_assertions_bad_cmpint(void)111 test_assertions_bad_cmpint (void)
112 {
113 g_assert_cmpint (4, !=, 4);
114 exit (0);
115 }
116
117 static void
test_assertions_bad_cmpmem_len(void)118 test_assertions_bad_cmpmem_len (void)
119 {
120 g_assert_cmpmem ("foo", 3, "foot", 4);
121 exit (0);
122 }
123
124 static void
test_assertions_bad_cmpmem_data(void)125 test_assertions_bad_cmpmem_data (void)
126 {
127 g_assert_cmpmem ("foo", 3, "fzz", 3);
128 exit (0);
129 }
130
131 static void
test_assertions_bad_cmpmem_null(void)132 test_assertions_bad_cmpmem_null (void)
133 {
134 g_assert_cmpmem (NULL, 3, NULL, 3);
135 exit (0);
136 }
137
138 static void
test_assertions_bad_cmpfloat_epsilon(void)139 test_assertions_bad_cmpfloat_epsilon (void)
140 {
141 g_assert_cmpfloat_with_epsilon (3.14, 3.15, 0.001);
142 exit (0);
143 }
144
145 /* Emulates something like rmdir() failing. */
146 static int
return_errno(void)147 return_errno (void)
148 {
149 errno = ERANGE; /* arbitrary non-zero value */
150 return -1;
151 }
152
153 /* Emulates something like rmdir() succeeding. */
154 static int
return_no_errno(void)155 return_no_errno (void)
156 {
157 return 0;
158 }
159
160 static void
test_assertions_bad_no_errno(void)161 test_assertions_bad_no_errno (void)
162 {
163 g_assert_no_errno (return_errno ());
164 }
165
166 static void
test_assertions(void)167 test_assertions (void)
168 {
169 const char *strv1[] = { "one", "two", "three", NULL };
170 const char *strv2[] = { "one", "two", "three", NULL };
171 GVariant *v1, *v2;
172 gchar *fuu;
173
174 g_assert_cmpint (1, >, 0);
175 g_assert_cmphex (2, ==, 2);
176 g_assert_cmpfloat (3.3, !=, 7);
177 g_assert_cmpfloat (7, <=, 3 + 4);
178 g_assert_cmpfloat_with_epsilon (3.14, 3.15, 0.01);
179 g_assert_cmpfloat_with_epsilon (3.14159, 3.1416, 0.0001);
180 g_assert (TRUE);
181 g_assert_true (TRUE);
182 g_assert_cmpstr ("foo", !=, "faa");
183 fuu = g_strdup_printf ("f%s", "uu");
184 g_test_queue_free (fuu);
185 g_assert_cmpstr ("foo", !=, fuu);
186 g_assert_cmpstr ("fuu", ==, fuu);
187 g_assert_cmpstr (NULL, <, "");
188 g_assert_cmpstr (NULL, ==, NULL);
189 g_assert_cmpstr ("", >, NULL);
190 g_assert_cmpstr ("foo", <, "fzz");
191 g_assert_cmpstr ("fzz", >, "faa");
192 g_assert_cmpstr ("fzz", ==, "fzz");
193 g_assert_cmpmem ("foo", 3, "foot", 3);
194 g_assert_cmpmem (NULL, 0, NULL, 0);
195 g_assert_cmpmem (NULL, 0, "foot", 0);
196 g_assert_cmpmem ("foo", 0, NULL, 0);
197 g_assert_no_errno (return_no_errno ());
198
199 g_assert_cmpstrv (NULL, NULL);
200 g_assert_cmpstrv (strv1, strv2);
201
202 v1 = g_variant_new_parsed ("['hello', 'there']");
203 v2 = g_variant_new_parsed ("['hello', 'there']");
204
205 g_assert_cmpvariant (v1, v1);
206 g_assert_cmpvariant (v1, v2);
207
208 g_variant_unref (v2);
209 g_variant_unref (v1);
210
211 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpvariant_types", 0, 0);
212 g_test_trap_assert_failed ();
213 g_test_trap_assert_stderr ("*assertion failed*");
214
215 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpvariant_values", 0, 0);
216 g_test_trap_assert_failed ();
217 g_test_trap_assert_stderr ("*assertion failed*");
218
219 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpstr", 0, 0);
220 g_test_trap_assert_failed ();
221 g_test_trap_assert_stderr ("*assertion failed*");
222
223 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpstrv_null1", 0, 0);
224 g_test_trap_assert_failed ();
225 g_test_trap_assert_stderr ("*assertion failed*");
226
227 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpstrv_null2", 0, 0);
228 g_test_trap_assert_failed ();
229 g_test_trap_assert_stderr ("*assertion failed*");
230
231 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpstrv_length", 0, 0);
232 g_test_trap_assert_failed ();
233 g_test_trap_assert_stderr ("*assertion failed*");
234
235 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpstrv_values", 0, 0);
236 g_test_trap_assert_failed ();
237 g_test_trap_assert_stderr ("*assertion failed*");
238
239 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpint", 0, 0);
240 g_test_trap_assert_failed ();
241 g_test_trap_assert_stderr ("*assertion failed*");
242
243 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpmem_len", 0, 0);
244 g_test_trap_assert_failed ();
245 g_test_trap_assert_stderr ("*assertion failed*len*");
246
247 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpmem_data", 0, 0);
248 g_test_trap_assert_failed ();
249 g_test_trap_assert_stderr ("*assertion failed*");
250 g_test_trap_assert_stderr_unmatched ("*assertion failed*len*");
251
252 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpmem_null", 0, 0);
253 g_test_trap_assert_failed ();
254 g_test_trap_assert_stderr ("*assertion failed*NULL*");
255
256 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_cmpfloat_epsilon", 0, 0);
257 g_test_trap_assert_failed ();
258 g_test_trap_assert_stderr ("*assertion failed*");
259
260 g_test_trap_subprocess ("/misc/assertions/subprocess/bad_no_errno", 0, 0);
261 g_test_trap_assert_failed ();
262 g_test_trap_assert_stderr ("*assertion failed*");
263 }
264
265 /* test g_test_timer* API */
266 static void
test_timer(void)267 test_timer (void)
268 {
269 double ttime;
270 g_test_timer_start();
271 g_assert_cmpfloat (g_test_timer_last(), ==, 0);
272 g_usleep (25 * 1000);
273 ttime = g_test_timer_elapsed();
274 g_assert_cmpfloat (ttime, >, 0);
275 g_assert_cmpfloat (g_test_timer_last(), ==, ttime);
276 g_test_minimized_result (ttime, "timer-test-time: %fsec", ttime);
277 g_test_maximized_result (5, "bogus-quantity: %ddummies", 5); /* simple API test */
278 }
279
280 #ifdef G_OS_UNIX
281 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
282
283 /* fork out for a failing test */
284 static void
test_fork_fail(void)285 test_fork_fail (void)
286 {
287 if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
288 {
289 g_assert_not_reached();
290 }
291 g_test_trap_assert_failed();
292 g_test_trap_assert_stderr ("*ERROR*test_fork_fail*should not be reached*");
293 }
294
295 /* fork out to assert stdout and stderr patterns */
296 static void
test_fork_patterns(void)297 test_fork_patterns (void)
298 {
299 if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
300 {
301 g_print ("some stdout text: somagic17\n");
302 g_printerr ("some stderr text: semagic43\n");
303 exit (0);
304 }
305 g_test_trap_assert_passed();
306 g_test_trap_assert_stdout ("*somagic17*");
307 g_test_trap_assert_stderr ("*semagic43*");
308 }
309
310 /* fork out for a timeout test */
311 static void
test_fork_timeout(void)312 test_fork_timeout (void)
313 {
314 /* allow child to run for only a fraction of a second */
315 if (g_test_trap_fork (0.11 * 1000000, 0))
316 {
317 /* loop and sleep forever */
318 while (TRUE)
319 g_usleep (1000 * 1000);
320 }
321 g_test_trap_assert_failed();
322 g_assert_true (g_test_trap_reached_timeout());
323 }
324
325 G_GNUC_END_IGNORE_DEPRECATIONS
326 #endif /* G_OS_UNIX */
327
328 static void
test_subprocess_fail(void)329 test_subprocess_fail (void)
330 {
331 if (g_test_subprocess ())
332 {
333 g_assert_not_reached ();
334 return;
335 }
336
337 g_test_trap_subprocess (NULL, 0, 0);
338 g_test_trap_assert_failed ();
339 g_test_trap_assert_stderr ("*ERROR*test_subprocess_fail*should not be reached*");
340 }
341
342 static void
test_subprocess_no_such_test(void)343 test_subprocess_no_such_test (void)
344 {
345 if (g_test_subprocess ())
346 {
347 g_test_trap_subprocess ("/trap_subprocess/this-test-does-not-exist", 0, 0);
348 g_assert_not_reached ();
349 return;
350 }
351 g_test_trap_subprocess (NULL, 0, 0);
352 g_test_trap_assert_failed ();
353 g_test_trap_assert_stderr ("*test does not exist*");
354 g_test_trap_assert_stderr_unmatched ("*should not be reached*");
355 }
356
357 static void
test_subprocess_patterns(void)358 test_subprocess_patterns (void)
359 {
360 if (g_test_subprocess ())
361 {
362 g_print ("some stdout text: somagic17\n");
363 g_printerr ("some stderr text: semagic43\n");
364 exit (0);
365 }
366 g_test_trap_subprocess (NULL, 0, 0);
367 g_test_trap_assert_passed ();
368 g_test_trap_assert_stdout ("*somagic17*");
369 g_test_trap_assert_stderr ("*semagic43*");
370 }
371
372 static void
test_subprocess_timeout(void)373 test_subprocess_timeout (void)
374 {
375 if (g_test_subprocess ())
376 {
377 /* loop and sleep forever */
378 while (TRUE)
379 g_usleep (1000 * 1000);
380 return;
381 }
382 /* allow child to run for only a fraction of a second */
383 g_test_trap_subprocess (NULL, 0.11 * 1000000, 0);
384 g_test_trap_assert_failed ();
385 g_assert_true (g_test_trap_reached_timeout ());
386 }
387
388 /* run a test with fixture setup and teardown */
389 typedef struct {
390 guint seed;
391 guint prime;
392 gchar *msg;
393 } Fixturetest;
394 static void
fixturetest_setup(Fixturetest * fix,gconstpointer test_data)395 fixturetest_setup (Fixturetest *fix,
396 gconstpointer test_data)
397 {
398 g_assert_true (test_data == (void*) 0xc0cac01a);
399 fix->seed = 18;
400 fix->prime = 19;
401 fix->msg = g_strdup_printf ("%d", fix->prime);
402 }
403 static void
fixturetest_test(Fixturetest * fix,gconstpointer test_data)404 fixturetest_test (Fixturetest *fix,
405 gconstpointer test_data)
406 {
407 guint prime = g_spaced_primes_closest (fix->seed);
408 g_assert_cmpint (prime, ==, fix->prime);
409 prime = g_ascii_strtoull (fix->msg, NULL, 0);
410 g_assert_cmpint (prime, ==, fix->prime);
411 g_assert_true (test_data == (void*) 0xc0cac01a);
412 }
413 static void
fixturetest_teardown(Fixturetest * fix,gconstpointer test_data)414 fixturetest_teardown (Fixturetest *fix,
415 gconstpointer test_data)
416 {
417 g_assert_true (test_data == (void*) 0xc0cac01a);
418 g_free (fix->msg);
419 }
420
421 static struct {
422 int bit, vint1, vint2, irange;
423 long double vdouble, drange;
424 } shared_rand_state;
425
426 static void
test_rand1(void)427 test_rand1 (void)
428 {
429 shared_rand_state.bit = g_test_rand_bit();
430 shared_rand_state.vint1 = g_test_rand_int();
431 shared_rand_state.vint2 = g_test_rand_int();
432 g_assert_cmpint (shared_rand_state.vint1, !=, shared_rand_state.vint2);
433 shared_rand_state.irange = g_test_rand_int_range (17, 35);
434 g_assert_cmpint (shared_rand_state.irange, >=, 17);
435 g_assert_cmpint (shared_rand_state.irange, <=, 35);
436 shared_rand_state.vdouble = g_test_rand_double();
437 shared_rand_state.drange = g_test_rand_double_range (-999, +17);
438 g_assert_cmpfloat (shared_rand_state.drange, >=, -999);
439 g_assert_cmpfloat (shared_rand_state.drange, <=, +17);
440 }
441
442 static void
test_rand2(void)443 test_rand2 (void)
444 {
445 /* this test only works if run after test1.
446 * we do this to check that random number generators
447 * are reseeded upon fixture setup.
448 */
449 g_assert_cmpint (shared_rand_state.bit, ==, g_test_rand_bit());
450 g_assert_cmpint (shared_rand_state.vint1, ==, g_test_rand_int());
451 g_assert_cmpint (shared_rand_state.vint2, ==, g_test_rand_int());
452 g_assert_cmpint (shared_rand_state.irange, ==, g_test_rand_int_range (17, 35));
453 g_assert_cmpfloat (shared_rand_state.vdouble, ==, g_test_rand_double());
454 g_assert_cmpfloat (shared_rand_state.drange, ==, g_test_rand_double_range (-999, +17));
455 }
456
457 static void
test_data_test(gconstpointer test_data)458 test_data_test (gconstpointer test_data)
459 {
460 g_assert_true (test_data == (void*) 0xc0c0baba);
461 }
462
463 static void
test_random_conversions(void)464 test_random_conversions (void)
465 {
466 /* very simple conversion test using random numbers */
467 int vint = g_test_rand_int();
468 char *err, *str = g_strdup_printf ("%d", vint);
469 gint64 vint64 = g_ascii_strtoll (str, &err, 10);
470 g_assert_cmphex (vint, ==, vint64);
471 g_assert_true (!err || *err == 0);
472 g_free (str);
473 }
474
475 static gboolean
fatal_handler(const gchar * log_domain,GLogLevelFlags log_level,const gchar * message,gpointer user_data)476 fatal_handler (const gchar *log_domain,
477 GLogLevelFlags log_level,
478 const gchar *message,
479 gpointer user_data)
480 {
481 return FALSE;
482 }
483
484 static void
test_fatal_log_handler_critical_pass(void)485 test_fatal_log_handler_critical_pass (void)
486 {
487 g_test_log_set_fatal_handler (fatal_handler, NULL);
488 g_str_has_prefix (NULL, "file://");
489 g_critical ("Test passing");
490 exit (0);
491 }
492
493 static void
test_fatal_log_handler_error_fail(void)494 test_fatal_log_handler_error_fail (void)
495 {
496 g_error ("Test failing");
497 exit (0);
498 }
499
500 static void
test_fatal_log_handler_critical_fail(void)501 test_fatal_log_handler_critical_fail (void)
502 {
503 g_str_has_prefix (NULL, "file://");
504 g_critical ("Test passing");
505 exit (0);
506 }
507
508 static void
test_fatal_log_handler(void)509 test_fatal_log_handler (void)
510 {
511 g_test_trap_subprocess ("/misc/fatal-log-handler/subprocess/critical-pass", 0, 0);
512 g_test_trap_assert_passed ();
513 g_test_trap_assert_stderr ("*CRITICAL*g_str_has_prefix*");
514 g_test_trap_assert_stderr ("*CRITICAL*Test passing*");
515
516 g_test_trap_subprocess ("/misc/fatal-log-handler/subprocess/error-fail", 0, 0);
517 g_test_trap_assert_failed ();
518 g_test_trap_assert_stderr ("*ERROR*Test failing*");
519
520 g_test_trap_subprocess ("/misc/fatal-log-handler/subprocess/critical-fail", 0, 0);
521 g_test_trap_assert_failed ();
522 g_test_trap_assert_stderr ("*CRITICAL*g_str_has_prefix*");
523 g_test_trap_assert_stderr_unmatched ("*CRITICAL*Test passing*");
524 }
525
526 static void
test_expected_messages_warning(void)527 test_expected_messages_warning (void)
528 {
529 g_warning ("This is a %d warning", g_random_int ());
530 g_return_if_reached ();
531 }
532
533 static void
test_expected_messages_expect_warning(void)534 test_expected_messages_expect_warning (void)
535 {
536 g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
537 "This is a * warning");
538 test_expected_messages_warning ();
539 }
540
541 static void
test_expected_messages_wrong_warning(void)542 test_expected_messages_wrong_warning (void)
543 {
544 g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
545 "*should not be *");
546 test_expected_messages_warning ();
547 }
548
549 static void
test_expected_messages_expected(void)550 test_expected_messages_expected (void)
551 {
552 g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
553 "This is a * warning");
554 g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
555 "*should not be reached");
556
557 test_expected_messages_warning ();
558
559 g_test_assert_expected_messages ();
560 exit (0);
561 }
562
563 static void
test_expected_messages_null_domain(void)564 test_expected_messages_null_domain (void)
565 {
566 g_test_expect_message (NULL, G_LOG_LEVEL_WARNING, "no domain");
567 g_log (NULL, G_LOG_LEVEL_WARNING, "no domain");
568 g_test_assert_expected_messages ();
569 }
570
571 static void
test_expected_messages_expect_error(void)572 test_expected_messages_expect_error (void)
573 {
574 /* make sure we can't try to expect a g_error() */
575 g_test_expect_message ("GLib", G_LOG_LEVEL_CRITICAL, "*G_LOG_LEVEL_ERROR*");
576 g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, "this won't work");
577 g_test_assert_expected_messages ();
578 }
579
580 static void
test_expected_messages_extra_warning(void)581 test_expected_messages_extra_warning (void)
582 {
583 g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
584 "This is a * warning");
585 g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
586 "*should not be reached");
587 g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
588 "nope");
589
590 test_expected_messages_warning ();
591
592 /* If we don't assert, it won't notice the missing message */
593 exit (0);
594 }
595
596 static void
test_expected_messages_unexpected_extra_warning(void)597 test_expected_messages_unexpected_extra_warning (void)
598 {
599 g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
600 "This is a * warning");
601 g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
602 "*should not be reached");
603 g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
604 "nope");
605
606 test_expected_messages_warning ();
607
608 g_test_assert_expected_messages ();
609 exit (0);
610 }
611
612 static void
test_expected_messages(void)613 test_expected_messages (void)
614 {
615 g_test_trap_subprocess ("/misc/expected-messages/subprocess/warning", 0, 0);
616 g_test_trap_assert_failed ();
617 g_test_trap_assert_stderr ("*This is a * warning*");
618 g_test_trap_assert_stderr_unmatched ("*should not be reached*");
619
620 g_test_trap_subprocess ("/misc/expected-messages/subprocess/expect-warning", 0, 0);
621 g_test_trap_assert_failed ();
622 g_test_trap_assert_stderr_unmatched ("*This is a * warning*");
623 g_test_trap_assert_stderr ("*should not be reached*");
624
625 g_test_trap_subprocess ("/misc/expected-messages/subprocess/wrong-warning", 0, 0);
626 g_test_trap_assert_failed ();
627 g_test_trap_assert_stderr_unmatched ("*should not be reached*");
628 g_test_trap_assert_stderr ("*GLib-CRITICAL*Did not see expected message testing-CRITICAL*should not be *WARNING*This is a * warning*");
629
630 g_test_trap_subprocess ("/misc/expected-messages/subprocess/expected", 0, 0);
631 g_test_trap_assert_passed ();
632 g_test_trap_assert_stderr ("");
633
634 g_test_trap_subprocess ("/misc/expected-messages/subprocess/null-domain", 0, 0);
635 g_test_trap_assert_passed ();
636 g_test_trap_assert_stderr ("");
637
638 g_test_trap_subprocess ("/misc/expected-messages/subprocess/extra-warning", 0, 0);
639 g_test_trap_assert_passed ();
640 g_test_trap_assert_stderr ("");
641
642 g_test_trap_subprocess ("/misc/expected-messages/subprocess/unexpected-extra-warning", 0, 0);
643 g_test_trap_assert_failed ();
644 g_test_trap_assert_stderr ("*GLib:ERROR*Did not see expected message testing-CRITICAL*nope*");
645 }
646
647 static void
test_expected_messages_debug(void)648 test_expected_messages_debug (void)
649 {
650 g_test_expect_message ("Test", G_LOG_LEVEL_WARNING, "warning message");
651 g_log ("Test", G_LOG_LEVEL_DEBUG, "should be ignored");
652 g_log ("Test", G_LOG_LEVEL_WARNING, "warning message");
653 g_test_assert_expected_messages ();
654
655 g_test_expect_message ("Test", G_LOG_LEVEL_DEBUG, "debug message");
656 g_log ("Test", G_LOG_LEVEL_DEBUG, "debug message");
657 g_test_assert_expected_messages ();
658 }
659
660 static void
test_dash_p_hidden(void)661 test_dash_p_hidden (void)
662 {
663 if (!g_test_subprocess ())
664 g_assert_not_reached ();
665
666 g_print ("Test /misc/dash-p/subprocess/hidden ran\n");
667 }
668
669 static void
test_dash_p_hidden_sub(void)670 test_dash_p_hidden_sub (void)
671 {
672 if (!g_test_subprocess ())
673 g_assert_not_reached ();
674
675 g_print ("Test /misc/dash-p/subprocess/hidden/sub ran\n");
676 }
677
678 /* The rest of the dash_p tests will get run by the toplevel test
679 * process, but they shouldn't do anything there.
680 */
681
682 static void
test_dash_p_child(void)683 test_dash_p_child (void)
684 {
685 if (!g_test_subprocess ())
686 return;
687
688 g_print ("Test /misc/dash-p/child ran\n");
689 }
690
691 static void
test_dash_p_child_sub(void)692 test_dash_p_child_sub (void)
693 {
694 if (!g_test_subprocess ())
695 return;
696
697 g_print ("Test /misc/dash-p/child/sub ran\n");
698 }
699
700 static void
test_dash_p_child_sub2(void)701 test_dash_p_child_sub2 (void)
702 {
703 if (!g_test_subprocess ())
704 return;
705
706 g_print ("Test /misc/dash-p/child/sub2 ran\n");
707 }
708
709 static void
test_dash_p_child_sub_child(void)710 test_dash_p_child_sub_child (void)
711 {
712 if (!g_test_subprocess ())
713 return;
714
715 g_print ("Test /misc/dash-p/child/subprocess ran\n");
716 }
717
718 static void
test_dash_p(void)719 test_dash_p (void)
720 {
721 g_test_trap_subprocess ("/misc/dash-p/subprocess/hidden", 0, 0);
722 g_test_trap_assert_passed ();
723 g_test_trap_assert_stdout ("*Test /misc/dash-p/subprocess/hidden ran*");
724 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/subprocess/hidden/sub ran*");
725 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/subprocess/hidden/sub2 ran*");
726 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/subprocess/hidden/sub/subprocess ran*");
727 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/child*");
728
729 g_test_trap_subprocess ("/misc/dash-p/subprocess/hidden/sub", 0, 0);
730 g_test_trap_assert_passed ();
731 g_test_trap_assert_stdout ("*Test /misc/dash-p/subprocess/hidden/sub ran*");
732 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/subprocess/hidden ran*");
733 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/subprocess/hidden/sub2 ran*");
734 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/subprocess/hidden/subprocess ran*");
735 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/child*");
736
737 g_test_trap_subprocess ("/misc/dash-p/child", 0, 0);
738 g_test_trap_assert_passed ();
739 g_test_trap_assert_stdout ("*Test /misc/dash-p/child ran*");
740 g_test_trap_assert_stdout ("*Test /misc/dash-p/child/sub ran*");
741 g_test_trap_assert_stdout ("*Test /misc/dash-p/child/sub2 ran*");
742 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/child/subprocess ran*");
743 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/subprocess/hidden*");
744
745 g_test_trap_subprocess ("/misc/dash-p/child/sub", 0, 0);
746 g_test_trap_assert_passed ();
747 g_test_trap_assert_stdout ("*Test /misc/dash-p/child/sub ran*");
748 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/child ran*");
749 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/child/sub2 ran*");
750 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/child/subprocess ran*");
751 g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/subprocess/hidden*");
752 }
753
754 static void
test_nonfatal(void)755 test_nonfatal (void)
756 {
757 if (g_test_subprocess ())
758 {
759 g_test_set_nonfatal_assertions ();
760 g_assert_cmpint (4, ==, 5);
761 g_print ("The End\n");
762 return;
763 }
764 g_test_trap_subprocess (NULL, 0, 0);
765 g_test_trap_assert_failed ();
766 g_test_trap_assert_stderr ("*assertion failed*4 == 5*");
767 g_test_trap_assert_stdout ("*The End*");
768 }
769
770 static void
test_skip(void)771 test_skip (void)
772 {
773 g_test_skip ("Skipped should count as passed, not failed");
774 /* This function really means "the test concluded with a non-successful
775 * status" rather than "the test failed": it is documented to return
776 * true for skipped and incomplete tests, not just for failures. */
777 g_assert_true (g_test_failed ());
778 }
779
780 static void
test_pass(void)781 test_pass (void)
782 {
783 }
784
785 static void
subprocess_fail(void)786 subprocess_fail (void)
787 {
788 /* Exit 1 instead of raising SIGABRT so that we can make assertions about
789 * how this combines with skipped/incomplete tests */
790 g_test_set_nonfatal_assertions ();
791 g_test_fail ();
792 g_assert_true (g_test_failed ());
793 }
794
795 static void
test_fail(void)796 test_fail (void)
797 {
798 if (g_test_subprocess ())
799 {
800 subprocess_fail ();
801 return;
802 }
803 g_test_trap_subprocess (NULL, 0, 0);
804 g_test_trap_assert_failed ();
805 }
806
807 static void
subprocess_incomplete(void)808 subprocess_incomplete (void)
809 {
810 g_test_incomplete ("not done");
811 /* This function really means "the test concluded with a non-successful
812 * status" rather than "the test failed": it is documented to return
813 * true for skipped and incomplete tests, not just for failures. */
814 g_assert_true (g_test_failed ());
815 }
816
817 static void
test_incomplete(void)818 test_incomplete (void)
819 {
820 if (g_test_subprocess ())
821 {
822 subprocess_incomplete ();
823 return;
824 }
825 g_test_trap_subprocess (NULL, 0, 0);
826 /* An incomplete test represents functionality that is known not to be
827 * implemented yet (an expected failure), so it does not cause test
828 * failure; but it does count as the test having been skipped, which
829 * causes nonzero exit status 77, which is treated as failure by
830 * g_test_trap_subprocess(). */
831 g_test_trap_assert_failed ();
832 }
833
834 static void
test_subprocess_timed_out(void)835 test_subprocess_timed_out (void)
836 {
837 if (g_test_subprocess ())
838 {
839 g_usleep (1000000);
840 return;
841 }
842 g_test_trap_subprocess (NULL, 50000, 0);
843 g_assert_true (g_test_trap_reached_timeout ());
844 }
845
846 static void
test_path_first(void)847 test_path_first (void)
848 {
849 g_assert_cmpstr (g_test_get_path (), ==, "/misc/path/first");
850 }
851
852 static void
test_path_second(void)853 test_path_second (void)
854 {
855 g_assert_cmpstr (g_test_get_path (), ==, "/misc/path/second");
856 }
857
858 static const char *argv0;
859
860 static void
test_combining(void)861 test_combining (void)
862 {
863 GPtrArray *argv;
864 GError *error = NULL;
865 int status;
866
867 g_test_message ("single test case skipped -> overall status 77");
868 argv = g_ptr_array_new ();
869 g_ptr_array_add (argv, (char *) argv0);
870 g_ptr_array_add (argv, "--GTestSubprocess");
871 g_ptr_array_add (argv, "-p");
872 g_ptr_array_add (argv, "/misc/skip");
873 g_ptr_array_add (argv, NULL);
874
875 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
876 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
877 NULL, NULL, NULL, NULL, &status,
878 &error);
879 g_assert_no_error (error);
880
881 g_spawn_check_wait_status (status, &error);
882 g_assert_error (error, G_SPAWN_EXIT_ERROR, 77);
883 g_clear_error (&error);
884
885 g_test_message ("each test case skipped -> overall status 77");
886 g_ptr_array_set_size (argv, 0);
887 g_ptr_array_add (argv, (char *) argv0);
888 g_ptr_array_add (argv, "--GTestSubprocess");
889 g_ptr_array_add (argv, "-p");
890 g_ptr_array_add (argv, "/misc/skip");
891 g_ptr_array_add (argv, "-p");
892 g_ptr_array_add (argv, "/misc/combining/subprocess/skip1");
893 g_ptr_array_add (argv, "-p");
894 g_ptr_array_add (argv, "/misc/combining/subprocess/skip2");
895 g_ptr_array_add (argv, NULL);
896
897 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
898 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
899 NULL, NULL, NULL, NULL, &status,
900 &error);
901 g_assert_no_error (error);
902
903 g_spawn_check_wait_status (status, &error);
904 g_assert_error (error, G_SPAWN_EXIT_ERROR, 77);
905 g_clear_error (&error);
906
907 g_test_message ("single test case incomplete -> overall status 77");
908 g_ptr_array_set_size (argv, 0);
909 g_ptr_array_add (argv, (char *) argv0);
910 g_ptr_array_add (argv, "--GTestSubprocess");
911 g_ptr_array_add (argv, "-p");
912 g_ptr_array_add (argv, "/misc/combining/subprocess/incomplete");
913 g_ptr_array_add (argv, NULL);
914
915 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
916 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
917 NULL, NULL, NULL, NULL, &status,
918 &error);
919 g_assert_no_error (error);
920
921 g_spawn_check_wait_status (status, &error);
922 g_assert_error (error, G_SPAWN_EXIT_ERROR, 77);
923 g_clear_error (&error);
924
925 g_test_message ("one pass and some skipped -> overall status 0");
926 g_ptr_array_set_size (argv, 0);
927 g_ptr_array_add (argv, (char *) argv0);
928 g_ptr_array_add (argv, "--GTestSubprocess");
929 g_ptr_array_add (argv, "-p");
930 g_ptr_array_add (argv, "/misc/skip");
931 g_ptr_array_add (argv, "-p");
932 g_ptr_array_add (argv, "/misc/combining/subprocess/pass");
933 g_ptr_array_add (argv, "-p");
934 g_ptr_array_add (argv, "/misc/combining/subprocess/skip1");
935 g_ptr_array_add (argv, NULL);
936
937 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
938 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
939 NULL, NULL, NULL, NULL, &status,
940 &error);
941 g_assert_no_error (error);
942
943 g_spawn_check_wait_status (status, &error);
944 g_assert_no_error (error);
945
946 g_test_message ("one pass and some incomplete -> overall status 0");
947 g_ptr_array_set_size (argv, 0);
948 g_ptr_array_add (argv, (char *) argv0);
949 g_ptr_array_add (argv, "--GTestSubprocess");
950 g_ptr_array_add (argv, "-p");
951 g_ptr_array_add (argv, "/misc/combining/subprocess/pass");
952 g_ptr_array_add (argv, "-p");
953 g_ptr_array_add (argv, "/misc/combining/subprocess/incomplete");
954 g_ptr_array_add (argv, NULL);
955
956 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
957 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
958 NULL, NULL, NULL, NULL, &status,
959 &error);
960 g_assert_no_error (error);
961
962 g_spawn_check_wait_status (status, &error);
963 g_assert_no_error (error);
964
965 g_test_message ("one pass and mix of skipped and incomplete -> overall status 0");
966 g_ptr_array_set_size (argv, 0);
967 g_ptr_array_add (argv, (char *) argv0);
968 g_ptr_array_add (argv, "--GTestSubprocess");
969 g_ptr_array_add (argv, "-p");
970 g_ptr_array_add (argv, "/misc/combining/subprocess/pass");
971 g_ptr_array_add (argv, "-p");
972 g_ptr_array_add (argv, "/misc/combining/subprocess/skip1");
973 g_ptr_array_add (argv, "-p");
974 g_ptr_array_add (argv, "/misc/combining/subprocess/incomplete");
975 g_ptr_array_add (argv, NULL);
976
977 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
978 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
979 NULL, NULL, NULL, NULL, &status,
980 &error);
981 g_assert_no_error (error);
982
983 g_spawn_check_wait_status (status, &error);
984 g_assert_no_error (error);
985
986 g_test_message ("one fail and some skipped -> overall status fail");
987 g_ptr_array_set_size (argv, 0);
988 g_ptr_array_add (argv, (char *) argv0);
989 g_ptr_array_add (argv, "--GTestSubprocess");
990 g_ptr_array_add (argv, "-p");
991 g_ptr_array_add (argv, "/misc/skip");
992 g_ptr_array_add (argv, "-p");
993 g_ptr_array_add (argv, "/misc/combining/subprocess/fail");
994 g_ptr_array_add (argv, "-p");
995 g_ptr_array_add (argv, "/misc/combining/subprocess/skip1");
996 g_ptr_array_add (argv, NULL);
997
998 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
999 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
1000 NULL, NULL, NULL, NULL, &status,
1001 &error);
1002 g_assert_no_error (error);
1003
1004 g_spawn_check_wait_status (status, &error);
1005 g_assert_error (error, G_SPAWN_EXIT_ERROR, 1);
1006 g_clear_error (&error);
1007
1008 g_test_message ("one fail and some incomplete -> overall status fail");
1009 g_ptr_array_set_size (argv, 0);
1010 g_ptr_array_add (argv, (char *) argv0);
1011 g_ptr_array_add (argv, "--GTestSubprocess");
1012 g_ptr_array_add (argv, "-p");
1013 g_ptr_array_add (argv, "/misc/combining/subprocess/fail");
1014 g_ptr_array_add (argv, "-p");
1015 g_ptr_array_add (argv, "/misc/combining/subprocess/incomplete");
1016 g_ptr_array_add (argv, NULL);
1017
1018 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1019 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
1020 NULL, NULL, NULL, NULL, &status,
1021 &error);
1022 g_assert_no_error (error);
1023
1024 g_spawn_check_wait_status (status, &error);
1025 g_assert_error (error, G_SPAWN_EXIT_ERROR, 1);
1026 g_clear_error (&error);
1027
1028 g_test_message ("one fail and mix of skipped and incomplete -> overall status fail");
1029 g_ptr_array_set_size (argv, 0);
1030 g_ptr_array_add (argv, (char *) argv0);
1031 g_ptr_array_add (argv, "--GTestSubprocess");
1032 g_ptr_array_add (argv, "-p");
1033 g_ptr_array_add (argv, "/misc/combining/subprocess/fail");
1034 g_ptr_array_add (argv, "-p");
1035 g_ptr_array_add (argv, "/misc/combining/subprocess/skip1");
1036 g_ptr_array_add (argv, "-p");
1037 g_ptr_array_add (argv, "/misc/combining/subprocess/incomplete");
1038 g_ptr_array_add (argv, NULL);
1039
1040 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1041 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
1042 NULL, NULL, NULL, NULL, &status,
1043 &error);
1044 g_assert_no_error (error);
1045
1046 g_spawn_check_wait_status (status, &error);
1047 g_assert_error (error, G_SPAWN_EXIT_ERROR, 1);
1048 g_clear_error (&error);
1049
1050 g_ptr_array_unref (argv);
1051 }
1052
1053 /* Test the TAP output when a test suite is run with --tap. */
1054 static void
test_tap(void)1055 test_tap (void)
1056 {
1057 const char *testing_helper;
1058 GPtrArray *argv;
1059 GError *error = NULL;
1060 int status;
1061 gchar *output;
1062
1063 testing_helper = g_test_get_filename (G_TEST_BUILT, "testing-helper" EXEEXT, NULL);
1064
1065 g_test_message ("pass");
1066 argv = g_ptr_array_new ();
1067 g_ptr_array_add (argv, (char *) testing_helper);
1068 g_ptr_array_add (argv, "pass");
1069 g_ptr_array_add (argv, "--tap");
1070 g_ptr_array_add (argv, NULL);
1071
1072 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1073 G_SPAWN_STDERR_TO_DEV_NULL,
1074 NULL, NULL, &output, NULL, &status,
1075 &error);
1076 g_assert_no_error (error);
1077
1078 g_spawn_check_wait_status (status, &error);
1079 g_assert_no_error (error);
1080 g_assert_nonnull (strstr (output, "\nok 1 /pass\n"));
1081 g_free (output);
1082 g_ptr_array_unref (argv);
1083
1084 g_test_message ("skip");
1085 argv = g_ptr_array_new ();
1086 g_ptr_array_add (argv, (char *) testing_helper);
1087 g_ptr_array_add (argv, "skip");
1088 g_ptr_array_add (argv, "--tap");
1089 g_ptr_array_add (argv, NULL);
1090
1091 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1092 G_SPAWN_STDERR_TO_DEV_NULL,
1093 NULL, NULL, &output, NULL, &status,
1094 &error);
1095 g_assert_no_error (error);
1096
1097 g_spawn_check_wait_status (status, &error);
1098 g_assert_no_error (error);
1099 g_assert_nonnull (strstr (output, "\nok 1 /skip # SKIP not enough tea\n"));
1100 g_free (output);
1101 g_ptr_array_unref (argv);
1102
1103 g_test_message ("skip with printf format");
1104 argv = g_ptr_array_new ();
1105 g_ptr_array_add (argv, (char *) testing_helper);
1106 g_ptr_array_add (argv, "skip-printf");
1107 g_ptr_array_add (argv, "--tap");
1108 g_ptr_array_add (argv, NULL);
1109
1110 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1111 G_SPAWN_STDERR_TO_DEV_NULL,
1112 NULL, NULL, &output, NULL, &status,
1113 &error);
1114 g_assert_no_error (error);
1115
1116 g_spawn_check_wait_status (status, &error);
1117 g_assert_no_error (error);
1118 g_assert_nonnull (strstr (output, "\nok 1 /skip-printf # SKIP not enough coffee\n"));
1119 g_free (output);
1120 g_ptr_array_unref (argv);
1121
1122 g_test_message ("incomplete");
1123 argv = g_ptr_array_new ();
1124 g_ptr_array_add (argv, (char *) testing_helper);
1125 g_ptr_array_add (argv, "incomplete");
1126 g_ptr_array_add (argv, "--tap");
1127 g_ptr_array_add (argv, NULL);
1128
1129 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1130 G_SPAWN_STDERR_TO_DEV_NULL,
1131 NULL, NULL, &output, NULL, &status,
1132 &error);
1133 g_assert_no_error (error);
1134
1135 g_spawn_check_wait_status (status, &error);
1136 g_assert_no_error (error);
1137 g_assert_nonnull (strstr (output, "\nnot ok 1 /incomplete # TODO mind reading not implemented yet\n"));
1138 g_free (output);
1139 g_ptr_array_unref (argv);
1140
1141 g_test_message ("incomplete with printf format");
1142 argv = g_ptr_array_new ();
1143 g_ptr_array_add (argv, (char *) testing_helper);
1144 g_ptr_array_add (argv, "incomplete-printf");
1145 g_ptr_array_add (argv, "--tap");
1146 g_ptr_array_add (argv, NULL);
1147
1148 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1149 G_SPAWN_STDERR_TO_DEV_NULL,
1150 NULL, NULL, &output, NULL, &status,
1151 &error);
1152 g_assert_no_error (error);
1153
1154 g_spawn_check_wait_status (status, &error);
1155 g_assert_no_error (error);
1156 g_assert_nonnull (strstr (output, "\nnot ok 1 /incomplete-printf # TODO telekinesis not implemented yet\n"));
1157 g_free (output);
1158 g_ptr_array_unref (argv);
1159
1160 g_test_message ("fail");
1161 argv = g_ptr_array_new ();
1162 g_ptr_array_add (argv, (char *) testing_helper);
1163 g_ptr_array_add (argv, "fail");
1164 g_ptr_array_add (argv, "--tap");
1165 g_ptr_array_add (argv, NULL);
1166
1167 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1168 G_SPAWN_STDERR_TO_DEV_NULL,
1169 NULL, NULL, &output, NULL, &status,
1170 &error);
1171 g_assert_no_error (error);
1172
1173 g_spawn_check_wait_status (status, &error);
1174 g_assert_error (error, G_SPAWN_EXIT_ERROR, 1);
1175 g_assert_nonnull (strstr (output, "\nnot ok 1 /fail\n"));
1176 g_free (output);
1177 g_clear_error (&error);
1178 g_ptr_array_unref (argv);
1179
1180 g_test_message ("fail with message");
1181 argv = g_ptr_array_new ();
1182 g_ptr_array_add (argv, (char *) testing_helper);
1183 g_ptr_array_add (argv, "fail-printf");
1184 g_ptr_array_add (argv, "--tap");
1185 g_ptr_array_add (argv, NULL);
1186
1187 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1188 G_SPAWN_STDERR_TO_DEV_NULL,
1189 NULL, NULL, &output, NULL, &status,
1190 &error);
1191 g_assert_no_error (error);
1192
1193 g_spawn_check_wait_status (status, &error);
1194 g_assert_error (error, G_SPAWN_EXIT_ERROR, 1);
1195 g_assert_nonnull (strstr (output, "\nnot ok 1 /fail-printf - this test intentionally left failing\n"));
1196 g_free (output);
1197 g_clear_error (&error);
1198 g_ptr_array_unref (argv);
1199
1200 g_test_message ("all");
1201 argv = g_ptr_array_new ();
1202 g_ptr_array_add (argv, (char *) testing_helper);
1203 g_ptr_array_add (argv, "all");
1204 g_ptr_array_add (argv, "--tap");
1205 g_ptr_array_add (argv, NULL);
1206
1207 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1208 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
1209 NULL, NULL, NULL, NULL, &status,
1210 &error);
1211 g_assert_no_error (error);
1212
1213 g_spawn_check_wait_status (status, &error);
1214 g_assert_error (error, G_SPAWN_EXIT_ERROR, 1);
1215 g_clear_error (&error);
1216 g_ptr_array_unref (argv);
1217
1218 g_test_message ("all-non-failures");
1219 argv = g_ptr_array_new ();
1220 g_ptr_array_add (argv, (char *) testing_helper);
1221 g_ptr_array_add (argv, "all-non-failures");
1222 g_ptr_array_add (argv, "--tap");
1223 g_ptr_array_add (argv, NULL);
1224
1225 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1226 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
1227 NULL, NULL, NULL, NULL, &status,
1228 &error);
1229 g_assert_no_error (error);
1230
1231 g_spawn_check_wait_status (status, &error);
1232 g_assert_no_error (error);
1233
1234 g_ptr_array_unref (argv);
1235
1236 g_test_message ("--GTestSkipCount");
1237 argv = g_ptr_array_new ();
1238 g_ptr_array_add (argv, (char *) testing_helper);
1239 g_ptr_array_add (argv, "skip-options");
1240 g_ptr_array_add (argv, "--tap");
1241 g_ptr_array_add (argv, "--GTestSkipCount");
1242 g_ptr_array_add (argv, "2");
1243 g_ptr_array_add (argv, NULL);
1244
1245 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1246 G_SPAWN_STDERR_TO_DEV_NULL,
1247 NULL, NULL, &output, NULL, &status,
1248 &error);
1249 g_assert_no_error (error);
1250 g_assert_nonnull (strstr (output, "1..10\n"));
1251 g_assert_nonnull (strstr (output, "\nok 1 /a # SKIP\n"));
1252 g_assert_nonnull (strstr (output, "\nok 2 /b # SKIP\n"));
1253 g_assert_nonnull (strstr (output, "\nok 3 /b/a\n"));
1254 g_assert_nonnull (strstr (output, "\nok 4 /b/b\n"));
1255 g_assert_nonnull (strstr (output, "\nok 5 /b/b/a\n"));
1256 g_assert_nonnull (strstr (output, "\nok 6 /prefix/a\n"));
1257 g_assert_nonnull (strstr (output, "\nok 7 /prefix/b/b\n"));
1258 g_assert_nonnull (strstr (output, "\nok 8 /prefix-long/a\n"));
1259 g_assert_nonnull (strstr (output, "\nok 9 /c/a\n"));
1260 g_assert_nonnull (strstr (output, "\nok 10 /d/a\n"));
1261
1262 g_spawn_check_wait_status (status, &error);
1263 g_assert_no_error (error);
1264
1265 g_free (output);
1266 g_ptr_array_unref (argv);
1267
1268 g_test_message ("--GTestSkipCount=0 is the same as omitting it");
1269 argv = g_ptr_array_new ();
1270 g_ptr_array_add (argv, (char *) testing_helper);
1271 g_ptr_array_add (argv, "skip-options");
1272 g_ptr_array_add (argv, "--tap");
1273 g_ptr_array_add (argv, "--GTestSkipCount");
1274 g_ptr_array_add (argv, "0");
1275 g_ptr_array_add (argv, NULL);
1276
1277 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1278 G_SPAWN_STDERR_TO_DEV_NULL,
1279 NULL, NULL, &output, NULL, &status,
1280 &error);
1281 g_assert_no_error (error);
1282 g_assert_nonnull (strstr (output, "1..10\n"));
1283 g_assert_nonnull (strstr (output, "\nok 1 /a\n"));
1284 g_assert_nonnull (strstr (output, "\nok 2 /b\n"));
1285 g_assert_nonnull (strstr (output, "\nok 3 /b/a\n"));
1286 g_assert_nonnull (strstr (output, "\nok 4 /b/b\n"));
1287 g_assert_nonnull (strstr (output, "\nok 5 /b/b/a\n"));
1288 g_assert_nonnull (strstr (output, "\nok 6 /prefix/a\n"));
1289 g_assert_nonnull (strstr (output, "\nok 7 /prefix/b/b\n"));
1290 g_assert_nonnull (strstr (output, "\nok 8 /prefix-long/a\n"));
1291 g_assert_nonnull (strstr (output, "\nok 9 /c/a\n"));
1292 g_assert_nonnull (strstr (output, "\nok 10 /d/a\n"));
1293
1294 g_spawn_check_wait_status (status, &error);
1295 g_assert_no_error (error);
1296
1297 g_free (output);
1298 g_ptr_array_unref (argv);
1299
1300 g_test_message ("--GTestSkipCount > number of tests skips all");
1301 argv = g_ptr_array_new ();
1302 g_ptr_array_add (argv, (char *) testing_helper);
1303 g_ptr_array_add (argv, "skip-options");
1304 g_ptr_array_add (argv, "--tap");
1305 g_ptr_array_add (argv, "--GTestSkipCount");
1306 g_ptr_array_add (argv, "11");
1307 g_ptr_array_add (argv, NULL);
1308
1309 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1310 G_SPAWN_STDERR_TO_DEV_NULL,
1311 NULL, NULL, &output, NULL, &status,
1312 &error);
1313 g_assert_no_error (error);
1314 g_assert_nonnull (strstr (output, "1..10\n"));
1315 g_assert_nonnull (strstr (output, "\nok 1 /a # SKIP\n"));
1316 g_assert_nonnull (strstr (output, "\nok 2 /b # SKIP\n"));
1317 g_assert_nonnull (strstr (output, "\nok 3 /b/a # SKIP\n"));
1318 g_assert_nonnull (strstr (output, "\nok 4 /b/b # SKIP\n"));
1319 g_assert_nonnull (strstr (output, "\nok 5 /b/b/a # SKIP\n"));
1320 g_assert_nonnull (strstr (output, "\nok 6 /prefix/a # SKIP\n"));
1321 g_assert_nonnull (strstr (output, "\nok 7 /prefix/b/b # SKIP\n"));
1322 g_assert_nonnull (strstr (output, "\nok 8 /prefix-long/a # SKIP\n"));
1323 g_assert_nonnull (strstr (output, "\nok 9 /c/a # SKIP\n"));
1324 g_assert_nonnull (strstr (output, "\nok 10 /d/a # SKIP\n"));
1325
1326 g_spawn_check_wait_status (status, &error);
1327 g_assert_no_error (error);
1328
1329 g_free (output);
1330 g_ptr_array_unref (argv);
1331
1332 g_test_message ("-p");
1333 argv = g_ptr_array_new ();
1334 g_ptr_array_add (argv, (char *) testing_helper);
1335 g_ptr_array_add (argv, "skip-options");
1336 g_ptr_array_add (argv, "--tap");
1337 g_ptr_array_add (argv, "-p");
1338 g_ptr_array_add (argv, "/c/a");
1339 g_ptr_array_add (argv, "-p");
1340 g_ptr_array_add (argv, "/c/a");
1341 g_ptr_array_add (argv, "-p");
1342 g_ptr_array_add (argv, "/b");
1343 g_ptr_array_add (argv, NULL);
1344
1345 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1346 G_SPAWN_STDERR_TO_DEV_NULL,
1347 NULL, NULL, &output, NULL, &status,
1348 &error);
1349 g_assert_no_error (error);
1350 g_assert_nonnull (strstr (output, "\nok 1 /c/a\n"));
1351 g_assert_nonnull (strstr (output, "\nok 2 /c/a\n"));
1352 g_assert_nonnull (strstr (output, "\nok 3 /b\n"));
1353 g_assert_nonnull (strstr (output, "\nok 4 /b/a\n"));
1354 g_assert_nonnull (strstr (output, "\nok 5 /b/b\n"));
1355 g_assert_nonnull (strstr (output, "\n1..5\n"));
1356
1357 g_spawn_check_wait_status (status, &error);
1358 g_assert_no_error (error);
1359
1360 g_free (output);
1361 g_ptr_array_unref (argv);
1362
1363 g_test_message ("--run-prefix");
1364 argv = g_ptr_array_new ();
1365 g_ptr_array_add (argv, (char *) testing_helper);
1366 g_ptr_array_add (argv, "skip-options");
1367 g_ptr_array_add (argv, "--tap");
1368 g_ptr_array_add (argv, "-r");
1369 g_ptr_array_add (argv, "/c/a");
1370 g_ptr_array_add (argv, "-r");
1371 g_ptr_array_add (argv, "/c/a");
1372 g_ptr_array_add (argv, "--run-prefix");
1373 g_ptr_array_add (argv, "/b");
1374 g_ptr_array_add (argv, NULL);
1375
1376 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1377 G_SPAWN_STDERR_TO_DEV_NULL,
1378 NULL, NULL, &output, NULL, &status,
1379 &error);
1380 g_assert_no_error (error);
1381 g_assert_nonnull (strstr (output, "\nok 1 /c/a\n"));
1382 g_assert_nonnull (strstr (output, "\nok 2 /c/a\n"));
1383 g_assert_nonnull (strstr (output, "\nok 3 /b\n"));
1384 g_assert_nonnull (strstr (output, "\nok 4 /b/a\n"));
1385 g_assert_nonnull (strstr (output, "\nok 5 /b/b\n"));
1386 g_assert_nonnull (strstr (output, "\nok 6 /b/b/a\n"));
1387 g_assert_nonnull (strstr (output, "\n1..6\n"));
1388
1389 g_spawn_check_wait_status (status, &error);
1390 g_assert_no_error (error);
1391
1392 g_free (output);
1393 g_ptr_array_unref (argv);
1394
1395 g_test_message ("--run-prefix 2");
1396 argv = g_ptr_array_new ();
1397 g_ptr_array_add (argv, (char *) testing_helper);
1398 g_ptr_array_add (argv, "skip-options");
1399 g_ptr_array_add (argv, "--tap");
1400 g_ptr_array_add (argv, "-r");
1401 g_ptr_array_add (argv, "/pre");
1402 g_ptr_array_add (argv, "--run-prefix");
1403 g_ptr_array_add (argv, "/b/b");
1404 g_ptr_array_add (argv, NULL);
1405
1406 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1407 G_SPAWN_STDERR_TO_DEV_NULL,
1408 NULL, NULL, &output, NULL, &status,
1409 &error);
1410 g_assert_no_error (error);
1411 g_assert_nonnull (strstr (output, "\nok 1 /b/b\n"));
1412 g_assert_nonnull (strstr (output, "\nok 2 /b/b/a\n"));
1413 g_assert_nonnull (strstr (output, "\n1..2\n"));
1414
1415 g_spawn_check_wait_status (status, &error);
1416 g_assert_no_error (error);
1417
1418 g_free (output);
1419 g_ptr_array_unref (argv);
1420
1421 g_test_message ("--run-prefix conflict");
1422 argv = g_ptr_array_new ();
1423 g_ptr_array_add (argv, (char *) testing_helper);
1424 g_ptr_array_add (argv, "skip-options");
1425 g_ptr_array_add (argv, "--tap");
1426 g_ptr_array_add (argv, "-r");
1427 g_ptr_array_add (argv, "/c/a");
1428 g_ptr_array_add (argv, "-p");
1429 g_ptr_array_add (argv, "/c/a");
1430 g_ptr_array_add (argv, "--run-prefix");
1431 g_ptr_array_add (argv, "/b");
1432 g_ptr_array_add (argv, NULL);
1433
1434 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1435 G_SPAWN_STDERR_TO_DEV_NULL,
1436 NULL, NULL, &output, NULL, &status,
1437 &error);
1438 g_assert_no_error (error);
1439 g_spawn_check_wait_status (status, &error);
1440 g_assert_nonnull (error);
1441 g_assert_nonnull (strstr (output, "do not mix [-r | --run-prefix] with '-p'\n"));
1442 g_clear_error (&error);
1443
1444 g_free (output);
1445 g_ptr_array_unref (argv);
1446
1447 g_test_message ("-s");
1448 argv = g_ptr_array_new ();
1449 g_ptr_array_add (argv, (char *) testing_helper);
1450 g_ptr_array_add (argv, "skip-options");
1451 g_ptr_array_add (argv, "--tap");
1452 g_ptr_array_add (argv, "-s");
1453 g_ptr_array_add (argv, "/a");
1454 g_ptr_array_add (argv, "-s");
1455 g_ptr_array_add (argv, "/b");
1456 g_ptr_array_add (argv, "-s");
1457 g_ptr_array_add (argv, "/pre");
1458 g_ptr_array_add (argv, "-s");
1459 g_ptr_array_add (argv, "/c/a");
1460 g_ptr_array_add (argv, NULL);
1461
1462 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1463 G_SPAWN_STDERR_TO_DEV_NULL,
1464 NULL, NULL, &output, NULL, &status,
1465 &error);
1466 g_assert_no_error (error);
1467 g_assert_nonnull (strstr (output, "1..10\n"));
1468 g_assert_nonnull (strstr (output, "\nok 1 /a # SKIP by request"));
1469 g_assert_nonnull (strstr (output, "\nok 2 /b # SKIP by request"));
1470 /* "-s /b" would skip a test named exactly /b, but not a test named
1471 * /b/anything */
1472 g_assert_nonnull (strstr (output, "\nok 3 /b/a\n"));
1473 g_assert_nonnull (strstr (output, "\nok 4 /b/b\n"));
1474 g_assert_nonnull (strstr (output, "\nok 5 /b/b/a\n"));
1475 g_assert_nonnull (strstr (output, "\nok 6 /prefix/a\n"));
1476 g_assert_nonnull (strstr (output, "\nok 7 /prefix/b/b\n"));
1477 g_assert_nonnull (strstr (output, "\nok 8 /prefix-long/a\n"));
1478 g_assert_nonnull (strstr (output, "\nok 9 /c/a # SKIP by request"));
1479 g_assert_nonnull (strstr (output, "\nok 10 /d/a\n"));
1480
1481 g_spawn_check_wait_status (status, &error);
1482 g_assert_no_error (error);
1483
1484 g_free (output);
1485 g_ptr_array_unref (argv);
1486
1487 g_test_message ("--skip-prefix");
1488 argv = g_ptr_array_new ();
1489 g_ptr_array_add (argv, (char *) testing_helper);
1490 g_ptr_array_add (argv, "skip-options");
1491 g_ptr_array_add (argv, "--tap");
1492 g_ptr_array_add (argv, "-x");
1493 g_ptr_array_add (argv, "/a");
1494 g_ptr_array_add (argv, "--skip-prefix");
1495 g_ptr_array_add (argv, "/pre");
1496 g_ptr_array_add (argv, "-x");
1497 g_ptr_array_add (argv, "/c/a");
1498 g_ptr_array_add (argv, NULL);
1499
1500 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1501 G_SPAWN_STDERR_TO_DEV_NULL,
1502 NULL, NULL, &output, NULL, &status,
1503 &error);
1504 g_assert_no_error (error);
1505 g_assert_nonnull (strstr (output, "1..10\n"));
1506 g_assert_nonnull (strstr (output, "\nok 1 /a # SKIP by request"));
1507 g_assert_nonnull (strstr (output, "\nok 2 /b\n"));
1508 g_assert_nonnull (strstr (output, "\nok 3 /b/a\n"));
1509 g_assert_nonnull (strstr (output, "\nok 4 /b/b\n"));
1510 g_assert_nonnull (strstr (output, "\nok 5 /b/b/a\n"));
1511 /* "--skip-prefix /pre" will skip all test path which begins with /pre */
1512 g_assert_nonnull (strstr (output, "\nok 6 /prefix/a # SKIP by request"));
1513 g_assert_nonnull (strstr (output, "\nok 7 /prefix/b/b # SKIP by request"));
1514 g_assert_nonnull (strstr (output, "\nok 8 /prefix-long/a # SKIP by request"));
1515 g_assert_nonnull (strstr (output, "\nok 9 /c/a # SKIP by request"));
1516 g_assert_nonnull (strstr (output, "\nok 10 /d/a\n"));
1517
1518 g_spawn_check_wait_status (status, &error);
1519 g_assert_no_error (error);
1520
1521 g_free (output);
1522 g_ptr_array_unref (argv);
1523
1524 g_test_message ("--skip-prefix conflict");
1525 argv = g_ptr_array_new ();
1526 g_ptr_array_add (argv, (char *) testing_helper);
1527 g_ptr_array_add (argv, "skip-options");
1528 g_ptr_array_add (argv, "--tap");
1529 g_ptr_array_add (argv, "-s");
1530 g_ptr_array_add (argv, "/a");
1531 g_ptr_array_add (argv, "--skip-prefix");
1532 g_ptr_array_add (argv, "/pre");
1533 g_ptr_array_add (argv, "-x");
1534 g_ptr_array_add (argv, "/c/a");
1535 g_ptr_array_add (argv, NULL);
1536
1537 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1538 G_SPAWN_STDERR_TO_DEV_NULL,
1539 NULL, NULL, &output, NULL, &status,
1540 &error);
1541 g_assert_no_error (error);
1542 g_spawn_check_wait_status (status, &error);
1543 g_assert_nonnull (error);
1544 g_assert_nonnull (strstr (output, "do not mix [-x | --skip-prefix] with '-s'\n"));
1545 g_clear_error (&error);
1546
1547 g_free (output);
1548 g_ptr_array_unref (argv);
1549 }
1550
1551 static void
test_tap_summary(void)1552 test_tap_summary (void)
1553 {
1554 const char *testing_helper;
1555 GPtrArray *argv;
1556 GError *error = NULL;
1557 int status;
1558 gchar *output;
1559
1560 g_test_summary ("Test the output of g_test_summary() from the TAP output of a test.");
1561
1562 testing_helper = g_test_get_filename (G_TEST_BUILT, "testing-helper" EXEEXT, NULL);
1563
1564 argv = g_ptr_array_new ();
1565 g_ptr_array_add (argv, (char *) testing_helper);
1566 g_ptr_array_add (argv, "summary");
1567 g_ptr_array_add (argv, "--tap");
1568 g_ptr_array_add (argv, NULL);
1569
1570 g_spawn_sync (NULL, (char **) argv->pdata, NULL,
1571 G_SPAWN_STDERR_TO_DEV_NULL,
1572 NULL, NULL, &output, NULL, &status,
1573 &error);
1574 g_assert_no_error (error);
1575
1576 g_spawn_check_wait_status (status, &error);
1577 g_assert_no_error (error);
1578 /* Note: The test path in the output is not `/tap/summary` because it’s the
1579 * test path from testing-helper, not from this function. */
1580 g_assert_nonnull (strstr (output, "\n# /summary summary: Tests that g_test_summary() "
1581 "works with TAP, by outputting a known "
1582 "summary message in testing-helper, and "
1583 "checking for it in the TAP output later.\n"));
1584 g_free (output);
1585 g_ptr_array_unref (argv);
1586 }
1587
1588 int
main(int argc,char * argv[])1589 main (int argc,
1590 char *argv[])
1591 {
1592 argv0 = argv[0];
1593
1594 setlocale (LC_ALL, "");
1595
1596 g_test_init (&argc, &argv, NULL);
1597
1598 g_test_add_func ("/random-generator/rand-1", test_rand1);
1599 g_test_add_func ("/random-generator/rand-2", test_rand2);
1600 g_test_add_func ("/random-generator/random-conversions", test_random_conversions);
1601 g_test_add_func ("/misc/assertions", test_assertions);
1602 g_test_add_func ("/misc/assertions/subprocess/bad_cmpvariant_types", test_assertions_bad_cmpvariant_types);
1603 g_test_add_func ("/misc/assertions/subprocess/bad_cmpvariant_values", test_assertions_bad_cmpvariant_values);
1604 g_test_add_func ("/misc/assertions/subprocess/bad_cmpstr", test_assertions_bad_cmpstr);
1605 g_test_add_func ("/misc/assertions/subprocess/bad_cmpstrv_null1", test_assertions_bad_cmpstrv_null1);
1606 g_test_add_func ("/misc/assertions/subprocess/bad_cmpstrv_null2", test_assertions_bad_cmpstrv_null2);
1607 g_test_add_func ("/misc/assertions/subprocess/bad_cmpstrv_length", test_assertions_bad_cmpstrv_length);
1608 g_test_add_func ("/misc/assertions/subprocess/bad_cmpstrv_values", test_assertions_bad_cmpstrv_values);
1609 g_test_add_func ("/misc/assertions/subprocess/bad_cmpint", test_assertions_bad_cmpint);
1610 g_test_add_func ("/misc/assertions/subprocess/bad_cmpmem_len", test_assertions_bad_cmpmem_len);
1611 g_test_add_func ("/misc/assertions/subprocess/bad_cmpmem_data", test_assertions_bad_cmpmem_data);
1612 g_test_add_func ("/misc/assertions/subprocess/bad_cmpmem_null", test_assertions_bad_cmpmem_null);
1613 g_test_add_func ("/misc/assertions/subprocess/bad_cmpfloat_epsilon", test_assertions_bad_cmpfloat_epsilon);
1614 g_test_add_func ("/misc/assertions/subprocess/bad_no_errno", test_assertions_bad_no_errno);
1615 g_test_add_data_func ("/misc/test-data", (void*) 0xc0c0baba, test_data_test);
1616 g_test_add ("/misc/primetoul", Fixturetest, (void*) 0xc0cac01a, fixturetest_setup, fixturetest_test, fixturetest_teardown);
1617 if (g_test_perf())
1618 g_test_add_func ("/misc/timer", test_timer);
1619
1620 #ifdef G_OS_UNIX
1621 g_test_add_func ("/forking/fail assertion", test_fork_fail);
1622 g_test_add_func ("/forking/patterns", test_fork_patterns);
1623 if (g_test_slow())
1624 g_test_add_func ("/forking/timeout", test_fork_timeout);
1625 #endif
1626
1627 g_test_add_func ("/trap_subprocess/fail", test_subprocess_fail);
1628 g_test_add_func ("/trap_subprocess/no-such-test", test_subprocess_no_such_test);
1629 if (g_test_slow ())
1630 g_test_add_func ("/trap_subprocess/timeout", test_subprocess_timeout);
1631
1632 g_test_add_func ("/trap_subprocess/patterns", test_subprocess_patterns);
1633
1634 g_test_add_func ("/misc/fatal-log-handler", test_fatal_log_handler);
1635 g_test_add_func ("/misc/fatal-log-handler/subprocess/critical-pass", test_fatal_log_handler_critical_pass);
1636 g_test_add_func ("/misc/fatal-log-handler/subprocess/error-fail", test_fatal_log_handler_error_fail);
1637 g_test_add_func ("/misc/fatal-log-handler/subprocess/critical-fail", test_fatal_log_handler_critical_fail);
1638
1639 g_test_add_func ("/misc/expected-messages", test_expected_messages);
1640 g_test_add_func ("/misc/expected-messages/subprocess/warning", test_expected_messages_warning);
1641 g_test_add_func ("/misc/expected-messages/subprocess/expect-warning", test_expected_messages_expect_warning);
1642 g_test_add_func ("/misc/expected-messages/subprocess/wrong-warning", test_expected_messages_wrong_warning);
1643 g_test_add_func ("/misc/expected-messages/subprocess/expected", test_expected_messages_expected);
1644 g_test_add_func ("/misc/expected-messages/subprocess/null-domain", test_expected_messages_null_domain);
1645 g_test_add_func ("/misc/expected-messages/subprocess/extra-warning", test_expected_messages_extra_warning);
1646 g_test_add_func ("/misc/expected-messages/subprocess/unexpected-extra-warning", test_expected_messages_unexpected_extra_warning);
1647 g_test_add_func ("/misc/expected-messages/expect-error", test_expected_messages_expect_error);
1648 g_test_add_func ("/misc/expected-messages/skip-debug", test_expected_messages_debug);
1649
1650 g_test_add_func ("/misc/dash-p", test_dash_p);
1651 g_test_add_func ("/misc/dash-p/child", test_dash_p_child);
1652 g_test_add_func ("/misc/dash-p/child/sub", test_dash_p_child_sub);
1653 g_test_add_func ("/misc/dash-p/child/sub/subprocess", test_dash_p_child_sub_child);
1654 g_test_add_func ("/misc/dash-p/child/sub/subprocess/child", test_dash_p_child_sub_child);
1655 g_test_add_func ("/misc/dash-p/child/sub2", test_dash_p_child_sub2);
1656 g_test_add_func ("/misc/dash-p/subprocess/hidden", test_dash_p_hidden);
1657 g_test_add_func ("/misc/dash-p/subprocess/hidden/sub", test_dash_p_hidden_sub);
1658
1659 g_test_add_func ("/misc/nonfatal", test_nonfatal);
1660
1661 g_test_add_func ("/misc/skip", test_skip);
1662 g_test_add_func ("/misc/combining", test_combining);
1663 g_test_add_func ("/misc/combining/subprocess/fail", subprocess_fail);
1664 g_test_add_func ("/misc/combining/subprocess/skip1", test_skip);
1665 g_test_add_func ("/misc/combining/subprocess/skip2", test_skip);
1666 g_test_add_func ("/misc/combining/subprocess/incomplete", subprocess_incomplete);
1667 g_test_add_func ("/misc/combining/subprocess/pass", test_pass);
1668 g_test_add_func ("/misc/fail", test_fail);
1669 g_test_add_func ("/misc/incomplete", test_incomplete);
1670 g_test_add_func ("/misc/timeout", test_subprocess_timed_out);
1671
1672 g_test_add_func ("/misc/path/first", test_path_first);
1673 g_test_add_func ("/misc/path/second", test_path_second);
1674
1675 g_test_add_func ("/tap", test_tap);
1676 g_test_add_func ("/tap/summary", test_tap_summary);
1677
1678 return g_test_run();
1679 }
1680