mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 07:26:15 +01:00
Make the tests silent on success.
2005-07-14 Matthias Clasen <mclasen@redhat.com> * tests/spawn-test.c: * tests/uri-test.c: * tests/thread-test.c: * tests/queue-test.c: * tests/mainloop-test.c: * tests/iochannel-test.c: * tests/gio-test.c: * tests/child-test.c: Make the tests silent on success.
This commit is contained in:
parent
b36f775177
commit
7221f500f5
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2005-07-14 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/spawn-test.c:
|
||||
* tests/uri-test.c:
|
||||
* tests/thread-test.c:
|
||||
* tests/queue-test.c:
|
||||
* tests/mainloop-test.c:
|
||||
* tests/iochannel-test.c:
|
||||
* tests/gio-test.c:
|
||||
* tests/child-test.c: Make the tests silent on success.
|
||||
|
||||
2005-07-13 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gfileutils.c (g_mkdir_with_parents): Fix a
|
||||
|
@ -1,3 +1,14 @@
|
||||
2005-07-14 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/spawn-test.c:
|
||||
* tests/uri-test.c:
|
||||
* tests/thread-test.c:
|
||||
* tests/queue-test.c:
|
||||
* tests/mainloop-test.c:
|
||||
* tests/iochannel-test.c:
|
||||
* tests/gio-test.c:
|
||||
* tests/child-test.c: Make the tests silent on success.
|
||||
|
||||
2005-07-13 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gfileutils.c (g_mkdir_with_parents): Fix a
|
||||
|
@ -1,3 +1,14 @@
|
||||
2005-07-14 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/spawn-test.c:
|
||||
* tests/uri-test.c:
|
||||
* tests/thread-test.c:
|
||||
* tests/queue-test.c:
|
||||
* tests/mainloop-test.c:
|
||||
* tests/iochannel-test.c:
|
||||
* tests/gio-test.c:
|
||||
* tests/child-test.c: Make the tests silent on success.
|
||||
|
||||
2005-07-13 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gfileutils.c (g_mkdir_with_parents): Fix a
|
||||
|
@ -1,3 +1,14 @@
|
||||
2005-07-14 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/spawn-test.c:
|
||||
* tests/uri-test.c:
|
||||
* tests/thread-test.c:
|
||||
* tests/queue-test.c:
|
||||
* tests/mainloop-test.c:
|
||||
* tests/iochannel-test.c:
|
||||
* tests/gio-test.c:
|
||||
* tests/child-test.c: Make the tests silent on success.
|
||||
|
||||
2005-07-13 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gfileutils.c (g_mkdir_with_parents): Fix a
|
||||
|
@ -92,9 +92,11 @@ get_a_child (gint ttl)
|
||||
gboolean
|
||||
child_watch_callback (GPid pid, gint status, gpointer data)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
gint ttl = GPOINTER_TO_INT (data);
|
||||
|
||||
g_print ("child " GPID_FORMAT " (ttl %d) exited, status %d\n", pid, ttl, status);
|
||||
#endif
|
||||
|
||||
g_spawn_close_pid (pid);
|
||||
|
||||
@ -104,6 +106,16 @@ child_watch_callback (GPid pid, gint status, gpointer data)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
quit_loop (gpointer data)
|
||||
{
|
||||
GMainLoop *main_loop = data;
|
||||
|
||||
g_main_loop_quit (main_loop);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef TEST_THREAD
|
||||
static gpointer
|
||||
test_thread (gpointer data)
|
||||
@ -121,7 +133,9 @@ test_thread (gpointer data)
|
||||
g_source_attach (source, g_main_loop_get_context (new_main_loop));
|
||||
g_source_unref (source);
|
||||
|
||||
#ifdef VERBOSE
|
||||
g_print ("whee! created pid: " GPID_FORMAT " (ttl %d)\n", pid, ttl);
|
||||
#endif
|
||||
|
||||
g_main_loop_run (new_main_loop);
|
||||
|
||||
@ -164,6 +178,8 @@ main (int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
alive = 2;
|
||||
g_timeout_add (30000, quit_loop, main_loop);
|
||||
|
||||
#ifdef TEST_THREAD
|
||||
g_thread_create (test_thread, GINT_TO_POINTER (10), FALSE, NULL);
|
||||
g_thread_create (test_thread, GINT_TO_POINTER (20), FALSE, NULL);
|
||||
@ -178,6 +194,12 @@ main (int argc, char *argv[])
|
||||
|
||||
g_main_loop_run (main_loop);
|
||||
|
||||
if (alive > 0)
|
||||
{
|
||||
g_warning ("%d children still alive\n", alive);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -117,11 +117,13 @@ recv_message (GIOChannel *channel,
|
||||
gint fd = g_io_channel_unix_get_fd (channel);
|
||||
gboolean retval = TRUE;
|
||||
|
||||
#ifdef VERBOSE
|
||||
g_print ("gio-test: ...from %d:%s%s%s%s\n", fd,
|
||||
(cond & G_IO_ERR) ? " ERR" : "",
|
||||
(cond & G_IO_HUP) ? " HUP" : "",
|
||||
(cond & G_IO_IN) ? " IN" : "",
|
||||
(cond & G_IO_PRI) ? " PRI" : "");
|
||||
#endif
|
||||
|
||||
if (cond & (G_IO_ERR | G_IO_HUP))
|
||||
{
|
||||
@ -142,7 +144,9 @@ recv_message (GIOChannel *channel,
|
||||
{
|
||||
if (nb == 0)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
g_print ("gio-test: ...from %d: EOF\n", fd);
|
||||
#endif
|
||||
shutdown_source (data);
|
||||
return FALSE;
|
||||
}
|
||||
@ -170,7 +174,9 @@ recv_message (GIOChannel *channel,
|
||||
|
||||
if (nb == 0)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
g_print ("gio-test: ...from %d: EOF\n", fd);
|
||||
#endif
|
||||
shutdown_source (data);
|
||||
return FALSE;
|
||||
}
|
||||
@ -183,9 +189,9 @@ recv_message (GIOChannel *channel,
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
g_assert (nbytes >= 0 && nbytes < BUFSIZE);
|
||||
|
||||
#ifdef VERBOSE
|
||||
g_print ("gio-test: ...from %d: %d bytes\n", fd, nbytes);
|
||||
|
||||
#endif
|
||||
if (nbytes > 0)
|
||||
{
|
||||
error = read_all (fd, channel, buf, nbytes, &nb);
|
||||
@ -195,7 +201,9 @@ recv_message (GIOChannel *channel,
|
||||
|
||||
if (nb == 0)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
g_print ("gio-test: ...from %d: EOF\n", fd);
|
||||
#endif
|
||||
shutdown_source (data);
|
||||
return FALSE;
|
||||
}
|
||||
@ -207,7 +215,9 @@ recv_message (GIOChannel *channel,
|
||||
fd, j, buf[j], 'a' + ((nbytes + j) % 32));
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
g_print ("gio-test: ...from %d: OK\n", fd);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
@ -401,8 +411,10 @@ main (int argc,
|
||||
buflen = rand() % BUFSIZE;
|
||||
for (j = 0; j < buflen; j++)
|
||||
buf[j] = ' ' + ((buflen + j) % 95);
|
||||
#ifdef VERBOSE
|
||||
g_print ("gio-test: child writing %d+%d bytes to %d\n",
|
||||
(int)(sizeof(i) + sizeof(buflen)), buflen, writefd);
|
||||
#endif
|
||||
write (writefd, &i, sizeof (i));
|
||||
write (writefd, &buflen, sizeof (buflen));
|
||||
write (writefd, buf, buflen);
|
||||
@ -419,7 +431,9 @@ main (int argc,
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
g_print ("gio-test: child exiting, closing %d\n", writefd);
|
||||
#endif
|
||||
close (writefd);
|
||||
}
|
||||
else
|
||||
|
@ -21,7 +21,6 @@ gint main (gint argc, gchar * argv[])
|
||||
gint rlength = 0;
|
||||
glong wlength = 0;
|
||||
gsize length_out;
|
||||
gboolean block;
|
||||
const gchar encoding[] = "EUC-JP";
|
||||
GIOStatus status;
|
||||
GIOFlags flags;
|
||||
@ -30,28 +29,28 @@ gint main (gint argc, gchar * argv[])
|
||||
srcdir = ".";
|
||||
filename = g_strconcat (srcdir, G_DIR_SEPARATOR_S, "iochannel-test-infile", NULL);
|
||||
|
||||
setbuf(stdout, NULL); /* For debugging */
|
||||
setbuf (stdout, NULL); /* For debugging */
|
||||
|
||||
gio_r = g_io_channel_new_file (filename, "r", &gerr);
|
||||
if (gerr)
|
||||
{
|
||||
g_warning("Unable to open file %s: %s", filename, gerr->message);
|
||||
g_error_free(gerr);
|
||||
g_warning ("Unable to open file %s: %s", filename, gerr->message);
|
||||
g_error_free (gerr);
|
||||
return 1;
|
||||
}
|
||||
gio_w = g_io_channel_new_file( "iochannel-test-outfile", "w", &gerr);
|
||||
gio_w = g_io_channel_new_file ("iochannel-test-outfile", "w", &gerr);
|
||||
if (gerr)
|
||||
{
|
||||
g_warning("Unable to open file %s: %s", "iochannel-test-outfile", gerr->message);
|
||||
g_error_free(gerr);
|
||||
g_warning ("Unable to open file %s: %s", "iochannel-test-outfile", gerr->message);
|
||||
g_error_free (gerr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_io_channel_set_encoding (gio_r, encoding, &gerr);
|
||||
if (gerr)
|
||||
{
|
||||
g_warning(gerr->message);
|
||||
g_error_free(gerr);
|
||||
g_warning (gerr->message);
|
||||
g_error_free (gerr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -60,17 +59,11 @@ gint main (gint argc, gchar * argv[])
|
||||
status = g_io_channel_set_flags (gio_r, G_IO_FLAG_NONBLOCK, &gerr);
|
||||
if (status == G_IO_STATUS_ERROR)
|
||||
{
|
||||
g_warning(gerr->message);
|
||||
g_error_free(gerr);
|
||||
g_warning (gerr->message);
|
||||
g_error_free (gerr);
|
||||
gerr = NULL;
|
||||
}
|
||||
flags = g_io_channel_get_flags (gio_r);
|
||||
block = ! (flags & G_IO_FLAG_NONBLOCK);
|
||||
if (block)
|
||||
g_print (" BLOCKING TRUE \n\n");
|
||||
else
|
||||
g_print (" BLOCKING FALSE \n\n");
|
||||
|
||||
buffer = g_string_sized_new (BUFFER_SIZE);
|
||||
|
||||
while (TRUE)
|
||||
@ -95,7 +88,9 @@ gint main (gint argc, gchar * argv[])
|
||||
if (length_out < buffer->len)
|
||||
g_warning ("Only wrote part of the line.");
|
||||
|
||||
#ifdef VERBOSE
|
||||
g_print ("%s", buffer->str);
|
||||
#endif
|
||||
g_string_truncate (buffer, 0);
|
||||
}
|
||||
|
||||
@ -119,12 +114,14 @@ gint main (gint argc, gchar * argv[])
|
||||
|
||||
if (status == G_IO_STATUS_ERROR)
|
||||
{
|
||||
g_warning(gerr->message);
|
||||
g_error_free(gerr);
|
||||
g_warning (gerr->message);
|
||||
g_error_free (gerr);
|
||||
gerr = NULL;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
g_print ("read %d bytes, wrote %ld bytes\n", rlength, wlength);
|
||||
#endif
|
||||
|
||||
g_io_channel_unref(gio_r);
|
||||
g_io_channel_unref(gio_w);
|
||||
|
@ -176,7 +176,9 @@ adder_thread (gpointer data)
|
||||
|
||||
g_main_loop_unref (addr_data.loop);
|
||||
|
||||
#ifdef VERBOSE
|
||||
g_print ("Timeout run %d times\n", addr_data.count);
|
||||
#endif
|
||||
|
||||
g_mutex_lock (context_array_mutex);
|
||||
g_ptr_array_remove (context_array, context);
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static gboolean verbose = FALSE;
|
||||
|
||||
static void
|
||||
check_integrity (GQueue *queue)
|
||||
{
|
||||
@ -225,7 +227,9 @@ random_test (int seed)
|
||||
QueueOp op;
|
||||
QueueInfo queues[N_QUEUES];
|
||||
|
||||
g_print ("seed: %d\n", seed);
|
||||
if (verbose)
|
||||
g_print ("seed: %d\n", seed);
|
||||
|
||||
g_random_set_seed (seed);
|
||||
|
||||
for (i = 0; i < N_QUEUES; ++i)
|
||||
@ -748,6 +752,9 @@ int main(int argc, gchar *args[])
|
||||
gpointer data;
|
||||
int i;
|
||||
|
||||
if (argc > 1 && args[1][0] == '-' && args[1][1] == 'v')
|
||||
verbose = TRUE;
|
||||
|
||||
q = g_queue_new ();
|
||||
|
||||
g_assert (g_queue_is_empty (q) == TRUE);
|
||||
@ -944,6 +951,8 @@ int main(int argc, gchar *args[])
|
||||
|
||||
g_queue_free (q);
|
||||
|
||||
if (argc > 2 && args[1][0] == '-' && args[1][1] == 'v')
|
||||
random_test (strtol (args[2], NULL, 0));
|
||||
if (argc > 1)
|
||||
random_test (strtol (args[1], NULL, 0));
|
||||
else
|
||||
|
@ -49,27 +49,31 @@ run_tests (void)
|
||||
gchar **argv = 0;
|
||||
#endif
|
||||
|
||||
printf ("The following errors are supposed to occur:\n");
|
||||
|
||||
err = NULL;
|
||||
if (!g_spawn_command_line_sync ("nonexistent_application foo 'bar baz' blah blah",
|
||||
NULL, NULL, NULL,
|
||||
&err))
|
||||
{
|
||||
fprintf (stderr, "Error (normal, supposed to happen): %s\n", err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("no error for sync spawn of nonexistent application");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
err = NULL;
|
||||
if (!g_spawn_command_line_async ("nonexistent_application foo bar baz \"blah blah\"",
|
||||
&err))
|
||||
{
|
||||
fprintf (stderr, "Error (normal, supposed to happen): %s\n", err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("no error for async spawn of nonexistent application");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
printf ("Errors after this are not supposed to happen:\n");
|
||||
|
||||
err = NULL;
|
||||
#ifdef G_OS_UNIX
|
||||
if (!g_spawn_command_line_sync ("/bin/sh -c 'echo hello'",
|
||||
|
@ -374,15 +374,10 @@ void
|
||||
run_all_tests()
|
||||
{
|
||||
test_g_mutex ();
|
||||
g_print (".");
|
||||
test_g_static_rec_mutex ();
|
||||
g_print (".");
|
||||
test_g_static_private ();
|
||||
g_print (".");
|
||||
test_g_static_rw_lock ();
|
||||
g_print (".");
|
||||
test_g_thread_once ();
|
||||
g_print (".");
|
||||
}
|
||||
|
||||
int
|
||||
@ -401,7 +396,6 @@ main (int argc,
|
||||
|
||||
g_thread_use_default_impl = FALSE;
|
||||
run_all_tests ();
|
||||
g_print ("\n");
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
|
@ -219,9 +219,6 @@ run_to_uri_tests (void)
|
||||
g_print ("Error message: %s\n", error->message);
|
||||
any_failed = TRUE;
|
||||
}
|
||||
|
||||
/* Give some output */
|
||||
g_print (".");
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,9 +300,6 @@ run_from_uri_tests (void)
|
||||
any_failed = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Give some output */
|
||||
g_print (".");
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,11 +359,7 @@ run_roundtrip_tests (void)
|
||||
i, to_uri_tests[i].hostname, hostname);
|
||||
any_failed = TRUE;
|
||||
}
|
||||
|
||||
/* Give some output */
|
||||
g_print (".");
|
||||
}
|
||||
g_print ("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user