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.
12 files changed:
+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
2005-07-13 Matthias Clasen <mclasen@redhat.com>
* glib/gfileutils.c (g_mkdir_with_parents): Fix a
+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
2005-07-13 Matthias Clasen <mclasen@redhat.com>
* glib/gfileutils.c (g_mkdir_with_parents): Fix a
+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
2005-07-13 Matthias Clasen <mclasen@redhat.com>
* glib/gfileutils.c (g_mkdir_with_parents): Fix a
+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
2005-07-13 Matthias Clasen <mclasen@redhat.com>
* glib/gfileutils.c (g_mkdir_with_parents): Fix a
gboolean
child_watch_callback (GPid pid, gint status, gpointer data)
{
gboolean
child_watch_callback (GPid pid, gint status, gpointer data)
{
gint ttl = GPOINTER_TO_INT (data);
g_print ("child " GPID_FORMAT " (ttl %d) exited, status %d\n", pid, ttl, status);
gint ttl = GPOINTER_TO_INT (data);
g_print ("child " GPID_FORMAT " (ttl %d) exited, status %d\n", pid, ttl, status);
+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)
#ifdef TEST_THREAD
static gpointer
test_thread (gpointer data)
g_source_attach (source, g_main_loop_get_context (new_main_loop));
g_source_unref (source);
g_source_attach (source, g_main_loop_get_context (new_main_loop));
g_source_unref (source);
g_print ("whee! created pid: " GPID_FORMAT " (ttl %d)\n", pid, ttl);
g_print ("whee! created pid: " GPID_FORMAT " (ttl %d)\n", pid, ttl);
g_main_loop_run (new_main_loop);
g_main_loop_run (new_main_loop);
+ 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);
#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);
g_main_loop_run (main_loop);
g_main_loop_run (main_loop);
+ if (alive > 0)
+ {
+ g_warning ("%d children still alive\n", alive);
+ return 1;
+ }
+
gint fd = g_io_channel_unix_get_fd (channel);
gboolean retval = TRUE;
gint fd = g_io_channel_unix_get_fd (channel);
gboolean retval = TRUE;
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" : "");
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" : "");
if (cond & (G_IO_ERR | G_IO_HUP))
{
if (cond & (G_IO_ERR | G_IO_HUP))
{
g_print ("gio-test: ...from %d: EOF\n", fd);
g_print ("gio-test: ...from %d: EOF\n", fd);
shutdown_source (data);
return FALSE;
}
shutdown_source (data);
return FALSE;
}
g_print ("gio-test: ...from %d: EOF\n", fd);
g_print ("gio-test: ...from %d: EOF\n", fd);
shutdown_source (data);
return FALSE;
}
shutdown_source (data);
return FALSE;
}
g_assert_not_reached ();
}
g_assert (nbytes >= 0 && nbytes < BUFSIZE);
g_assert_not_reached ();
}
g_assert (nbytes >= 0 && nbytes < BUFSIZE);
g_print ("gio-test: ...from %d: %d bytes\n", fd, nbytes);
g_print ("gio-test: ...from %d: %d bytes\n", fd, nbytes);
if (nbytes > 0)
{
error = read_all (fd, channel, buf, nbytes, &nb);
if (nbytes > 0)
{
error = read_all (fd, channel, buf, nbytes, &nb);
g_print ("gio-test: ...from %d: EOF\n", fd);
g_print ("gio-test: ...from %d: EOF\n", fd);
shutdown_source (data);
return FALSE;
}
shutdown_source (data);
return FALSE;
}
fd, j, buf[j], 'a' + ((nbytes + j) % 32));
g_assert_not_reached ();
}
fd, j, buf[j], 'a' + ((nbytes + j) % 32));
g_assert_not_reached ();
}
g_print ("gio-test: ...from %d: OK\n", fd);
g_print ("gio-test: ...from %d: OK\n", fd);
buflen = rand() % BUFSIZE;
for (j = 0; j < buflen; j++)
buf[j] = ' ' + ((buflen + j) % 95);
buflen = rand() % BUFSIZE;
for (j = 0; j < buflen; j++)
buf[j] = ' ' + ((buflen + j) % 95);
g_print ("gio-test: child writing %d+%d bytes to %d\n",
(int)(sizeof(i) + sizeof(buflen)), buflen, writefd);
g_print ("gio-test: child writing %d+%d bytes to %d\n",
(int)(sizeof(i) + sizeof(buflen)), buflen, writefd);
write (writefd, &i, sizeof (i));
write (writefd, &buflen, sizeof (buflen));
write (writefd, buf, buflen);
write (writefd, &i, sizeof (i));
write (writefd, &buflen, sizeof (buflen));
write (writefd, buf, buflen);
g_print ("gio-test: child exiting, closing %d\n", writefd);
g_print ("gio-test: child exiting, closing %d\n", writefd);
gint rlength = 0;
glong wlength = 0;
gsize length_out;
gint rlength = 0;
glong wlength = 0;
gsize length_out;
const gchar encoding[] = "EUC-JP";
GIOStatus status;
GIOFlags flags;
const gchar encoding[] = "EUC-JP";
GIOStatus status;
GIOFlags flags;
srcdir = ".";
filename = g_strconcat (srcdir, G_DIR_SEPARATOR_S, "iochannel-test-infile", NULL);
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)
{
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);
- gio_w = g_io_channel_new_file( "iochannel-test-outfile", "w", &gerr);
+ gio_w = g_io_channel_new_file ("iochannel-test-outfile", "w", &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)
{
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);
status = g_io_channel_set_flags (gio_r, G_IO_FLAG_NONBLOCK, &gerr);
if (status == G_IO_STATUS_ERROR)
{
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);
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)
buffer = g_string_sized_new (BUFFER_SIZE);
while (TRUE)
if (length_out < buffer->len)
g_warning ("Only wrote part of the line.");
if (length_out < buffer->len)
g_warning ("Only wrote part of the line.");
g_print ("%s", buffer->str);
g_print ("%s", buffer->str);
g_string_truncate (buffer, 0);
}
g_string_truncate (buffer, 0);
}
if (status == G_IO_STATUS_ERROR)
{
if (status == G_IO_STATUS_ERROR)
{
- g_warning(gerr->message);
- g_error_free(gerr);
+ g_warning (gerr->message);
+ g_error_free (gerr);
g_print ("read %d bytes, wrote %ld bytes\n", rlength, wlength);
g_print ("read %d bytes, wrote %ld bytes\n", rlength, wlength);
g_io_channel_unref(gio_r);
g_io_channel_unref(gio_w);
g_io_channel_unref(gio_r);
g_io_channel_unref(gio_w);
g_main_loop_unref (addr_data.loop);
g_main_loop_unref (addr_data.loop);
g_print ("Timeout run %d times\n", addr_data.count);
g_print ("Timeout run %d times\n", addr_data.count);
g_mutex_lock (context_array_mutex);
g_ptr_array_remove (context_array, context);
g_mutex_lock (context_array_mutex);
g_ptr_array_remove (context_array, context);
#include <time.h>
#include <stdlib.h>
#include <time.h>
#include <stdlib.h>
+static gboolean verbose = FALSE;
+
static void
check_integrity (GQueue *queue)
{
static void
check_integrity (GQueue *queue)
{
QueueOp op;
QueueInfo queues[N_QUEUES];
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)
g_random_set_seed (seed);
for (i = 0; i < N_QUEUES; ++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);
q = g_queue_new ();
g_assert (g_queue_is_empty (q) == TRUE);
+ 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
if (argc > 1)
random_test (strtol (args[1], NULL, 0));
else
- 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))
{
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);
+ 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))
{
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);
+ 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'",
err = NULL;
#ifdef G_OS_UNIX
if (!g_spawn_command_line_sync ("/bin/sh -c 'echo hello'",
run_all_tests()
{
test_g_mutex ();
run_all_tests()
{
test_g_mutex ();
test_g_static_rec_mutex ();
test_g_static_rec_mutex ();
test_g_static_private ();
test_g_static_private ();
test_g_static_rw_lock ();
test_g_static_rw_lock ();
g_thread_use_default_impl = FALSE;
run_all_tests ();
g_thread_use_default_impl = FALSE;
run_all_tests ();
g_print ("Error message: %s\n", error->message);
any_failed = TRUE;
}
g_print ("Error message: %s\n", error->message);
any_failed = TRUE;
}
-
- /* Give some output */
- g_print (".");
-
- /* Give some output */
- g_print (".");
i, to_uri_tests[i].hostname, hostname);
any_failed = TRUE;
}
i, to_uri_tests[i].hostname, hostname);
any_failed = TRUE;
}
-
- /* Give some output */
- g_print (".");