[svn r650] created test program trunk
authorrenatofilho
Fri May 11 14:41:11 2007 +0100 (2007-05-11)
branchtrunk
changeset 644b937c837e929
parent 643 653976fae5dd
child 645 17877d6e44e2
[svn r650] created test program
libgnomevfs2-mythtv/Makefile.am
libgnomevfs2-mythtv/configure.ac
libgnomevfs2-mythtv/tests/Makefile.am
libgnomevfs2-mythtv/tests/main.c
     1.1 --- a/libgnomevfs2-mythtv/Makefile.am	Thu May 10 22:09:33 2007 +0100
     1.2 +++ b/libgnomevfs2-mythtv/Makefile.am	Fri May 11 14:41:11 2007 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4 -SUBDIRS = modules
     1.5 -DIST_SUBDIRS = modules
     1.6 +SUBDIRS = modules tests
     1.7 +DIST_SUBDIRS = modules 
     1.8  
     1.9  EXTRA_DIST = \
    1.10  	autogen.sh
     2.1 --- a/libgnomevfs2-mythtv/configure.ac	Thu May 10 22:09:33 2007 +0100
     2.2 +++ b/libgnomevfs2-mythtv/configure.ac	Fri May 11 14:41:11 2007 +0100
     2.3 @@ -115,6 +115,7 @@
     2.4  
     2.5  AC_OUTPUT( \
     2.6      Makefile \
     2.7 -    modules/Makefile
     2.8 +    modules/Makefile \
     2.9 +    tests/Makefile
    2.10  )
    2.11  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/libgnomevfs2-mythtv/tests/Makefile.am	Fri May 11 14:41:11 2007 +0100
     3.3 @@ -0,0 +1,15 @@
     3.4 +bin_PROGRAMS = \
     3.5 +	test
     3.6 +
     3.7 +test_SOURCES = \
     3.8 +	main.c
     3.9 +
    3.10 +INCLUDES = \
    3.11 +	$(GLIB_CFLAGS) \
    3.12 +	$(GOBJECT_CFLAGS) \
    3.13 +	$(GNOME_VFS_CFLAGS)
    3.14 +
    3.15 +LDADD = \
    3.16 +	$(GLIB_LIBS) \
    3.17 +	$(GOBJECT_LIBS) \
    3.18 +	$(GNOME_VFS_LIBS)	
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/libgnomevfs2-mythtv/tests/main.c	Fri May 11 14:41:11 2007 +0100
     4.3 @@ -0,0 +1,49 @@
     4.4 +
     4.5 +#include <libgnomevfs/gnome-vfs-module.h>
     4.6 +#include <libgnomevfs/gnome-vfs-utils.h>
     4.7 +#include <glib.h>
     4.8 +
     4.9 +static void 
    4.10 +assert_message (gboolean valid, const gchar* message)
    4.11 +{
    4.12 +    if (!valid) {
    4.13 +        g_warning (message);            
    4.14 +        exit (1);
    4.15 +    }
    4.16 +}
    4.17 +        
    4.18 +
    4.19 +
    4.20 +int main (int argc, char** argv)
    4.21 +{
    4.22 +        GnomeVFSResult result;
    4.23 +        GnomeVFSFileSize read;
    4.24 +        gchar buff[512];
    4.25 +        GnomeVFSHandle *handle;
    4.26 +        
    4.27 +       
    4.28 +        g_assert (argc == 2);
    4.29 +        
    4.30 +        gnome_vfs_init ();
    4.31 +
    4.32 +        g_debug ("Oppening: %s", argv[1]);
    4.33 +
    4.34 +        result = gnome_vfs_open (&handle, argv[1], GNOME_VFS_OPEN_READ);
    4.35 +        assert_message (result == GNOME_VFS_OK, 
    4.36 +                        gnome_vfs_result_to_string (result));
    4.37 +
    4.38 +        while (result == GNOME_VFS_OK) {
    4.39 +            memset (buff, '\0', sizeof (buff));
    4.40 +            result = gnome_vfs_read (handle, buff, sizeof (buff), &read);
    4.41 +        }
    4.42 +
    4.43 +        assert_message (result == GNOME_VFS_ERROR_EOF, 
    4.44 +                        gnome_vfs_result_to_string (result));
    4.45 +
    4.46 +        result = gnome_vfs_close (handle);
    4.47 +        assert_message (result == GNOME_VFS_OK, 
    4.48 +                        gnome_vfs_result_to_string (result));
    4.49 +
    4.50 +        g_debug ("OK");
    4.51 +        return 0;
    4.52 +}