# HG changeset patch # User renatofilho # Date 1178890871 -3600 # Node ID b937c837e9297b9a5a09822c6cc36b96acbffa7e # Parent 653976fae5dd0464daf91ea6d07d2c6431b62ed6 [svn r650] created test program diff -r 653976fae5dd -r b937c837e929 libgnomevfs2-mythtv/Makefile.am --- a/libgnomevfs2-mythtv/Makefile.am Thu May 10 22:09:33 2007 +0100 +++ b/libgnomevfs2-mythtv/Makefile.am Fri May 11 14:41:11 2007 +0100 @@ -1,5 +1,5 @@ -SUBDIRS = modules -DIST_SUBDIRS = modules +SUBDIRS = modules tests +DIST_SUBDIRS = modules EXTRA_DIST = \ autogen.sh diff -r 653976fae5dd -r b937c837e929 libgnomevfs2-mythtv/configure.ac --- a/libgnomevfs2-mythtv/configure.ac Thu May 10 22:09:33 2007 +0100 +++ b/libgnomevfs2-mythtv/configure.ac Fri May 11 14:41:11 2007 +0100 @@ -115,6 +115,7 @@ AC_OUTPUT( \ Makefile \ - modules/Makefile + modules/Makefile \ + tests/Makefile ) diff -r 653976fae5dd -r b937c837e929 libgnomevfs2-mythtv/tests/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgnomevfs2-mythtv/tests/Makefile.am Fri May 11 14:41:11 2007 +0100 @@ -0,0 +1,15 @@ +bin_PROGRAMS = \ + test + +test_SOURCES = \ + main.c + +INCLUDES = \ + $(GLIB_CFLAGS) \ + $(GOBJECT_CFLAGS) \ + $(GNOME_VFS_CFLAGS) + +LDADD = \ + $(GLIB_LIBS) \ + $(GOBJECT_LIBS) \ + $(GNOME_VFS_LIBS) diff -r 653976fae5dd -r b937c837e929 libgnomevfs2-mythtv/tests/main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgnomevfs2-mythtv/tests/main.c Fri May 11 14:41:11 2007 +0100 @@ -0,0 +1,49 @@ + +#include +#include +#include + +static void +assert_message (gboolean valid, const gchar* message) +{ + if (!valid) { + g_warning (message); + exit (1); + } +} + + + +int main (int argc, char** argv) +{ + GnomeVFSResult result; + GnomeVFSFileSize read; + gchar buff[512]; + GnomeVFSHandle *handle; + + + g_assert (argc == 2); + + gnome_vfs_init (); + + g_debug ("Oppening: %s", argv[1]); + + result = gnome_vfs_open (&handle, argv[1], GNOME_VFS_OPEN_READ); + assert_message (result == GNOME_VFS_OK, + gnome_vfs_result_to_string (result)); + + while (result == GNOME_VFS_OK) { + memset (buff, '\0', sizeof (buff)); + result = gnome_vfs_read (handle, buff, sizeof (buff), &read); + } + + assert_message (result == GNOME_VFS_ERROR_EOF, + gnome_vfs_result_to_string (result)); + + result = gnome_vfs_close (handle); + assert_message (result == GNOME_VFS_OK, + gnome_vfs_result_to_string (result)); + + g_debug ("OK"); + return 0; +}