* if advised of the possibility of such damage.
*/
+/* We want to distinguish between messages originating from libglib
+ * and messages originating from this program.
+ */
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "testing"
+
#include <glib.h>
#include <stdlib.h>
test_expected_messages_expect_error (void)
{
/* make sure we can't try to expect a g_error() */
- g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*G_LOG_LEVEL_ERROR*");
+ g_test_expect_message ("GLib", G_LOG_LEVEL_CRITICAL, "*G_LOG_LEVEL_ERROR*");
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, "this won't work");
g_test_assert_expected_messages ();
}
g_test_trap_subprocess ("/misc/expected-messages/subprocess/wrong-warning", 0, 0);
g_test_trap_assert_failed ();
g_test_trap_assert_stderr_unmatched ("*should not be reached*");
- g_test_trap_assert_stderr ("*Did not see expected message CRITICAL*should not be *WARNING*This is a * warning*");
+ g_test_trap_assert_stderr ("*GLib-CRITICAL*Did not see expected message testing-CRITICAL*should not be *WARNING*This is a * warning*");
g_test_trap_subprocess ("/misc/expected-messages/subprocess/expected", 0, 0);
g_test_trap_assert_passed ();
g_test_trap_subprocess ("/misc/expected-messages/subprocess/unexpected-extra-warning", 0, 0);
g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*Did not see expected message CRITICAL*nope*");
+ g_test_trap_assert_stderr ("*GLib:ERROR*Did not see expected message testing-CRITICAL*nope*");
}
static void
{
}
+static void
+test_fail (void)
+{
+ if (g_test_subprocess ())
+ {
+ g_test_fail ();
+ g_assert (g_test_failed ());
+ return;
+ }
+ g_test_trap_subprocess (NULL, 0, 0);
+ g_test_trap_assert_failed ();
+}
+
+static void
+test_incomplete (void)
+{
+ if (g_test_subprocess ())
+ {
+ g_test_incomplete ("not done");
+ g_assert (g_test_failed ());
+ return;
+ }
+ g_test_trap_subprocess (NULL, 0, 0);
+ g_test_trap_assert_failed ();
+}
+
+static void
+test_subprocess_timed_out (void)
+{
+ if (g_test_subprocess ())
+ {
+ g_usleep (1000000);
+ return;
+ }
+ g_test_trap_subprocess (NULL, 50000, 0);
+ g_assert (g_test_trap_reached_timeout ());
+}
+
static const char *argv0;
static void
g_test_add_func ("/misc/skip-all/subprocess/skip1", test_skip);
g_test_add_func ("/misc/skip-all/subprocess/skip2", test_skip);
g_test_add_func ("/misc/skip-all/subprocess/pass", test_pass);
+ g_test_add_func ("/misc/fail", test_fail);
+ g_test_add_func ("/misc/incomplete", test_incomplete);
+ g_test_add_func ("/misc/timeout", test_subprocess_timed_out);
return g_test_run();
}