libgnomevfs2-mythtv/tests/main.c
author renatofilho
Thu Aug 16 14:46:11 2007 +0100 (2007-08-16)
branchtrunk
changeset 807 add4025ca678
parent 753 8ee634511c1e
permissions -rw-r--r--
[svn r813] created a timeout function for invalid channels
     1 #include <stdlib.h>
     2 #include <string.h>
     3 #include <libgnomevfs/gnome-vfs.h>
     4 #include <glib.h>
     5 
     6 static void
     7 assert_message(gboolean valid, const gchar * message)
     8 {
     9     if (!valid) {
    10         g_warning(message);
    11         exit(1);
    12     }
    13 }
    14 
    15 int
    16 main(int argc, char **argv)
    17 {
    18     GnomeVFSResult  result;
    19     GnomeVFSFileSize read;
    20     gchar           buff[512];
    21     GnomeVFSHandle *handle = NULL;
    22 
    23 
    24     g_assert(argc == 2);
    25 
    26     gnome_vfs_init();
    27 
    28     g_debug("Oppening: %s", argv[1]);
    29 
    30     result = gnome_vfs_open(&handle, argv[1], GNOME_VFS_OPEN_READ);
    31     assert_message(result == GNOME_VFS_OK,
    32                    gnome_vfs_result_to_string(result));
    33 
    34     g_debug("handle %p", handle);
    35 
    36     while (result == GNOME_VFS_OK) {
    37         memset(buff, '\0', sizeof(buff));
    38         result = gnome_vfs_read(handle, buff, sizeof(buff), &read);
    39         g_debug("read %" G_GINT64_FORMAT, read);
    40     }
    41 
    42     assert_message(result == GNOME_VFS_ERROR_EOF,
    43                    gnome_vfs_result_to_string(result));
    44 
    45     result = gnome_vfs_close(handle);
    46     assert_message(result == GNOME_VFS_OK,
    47                    gnome_vfs_result_to_string(result));
    48 
    49     g_debug("OK");
    50     return 0;
    51 }