source: trunk/third/gnome-vfs/test/test-async-cancel.c @ 15595

Revision 15595, 20.5 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r15594, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2
3/* test-async-cancel.c - Test program for the GNOME Virtual File System.
4
5   Copyright (C) 1999 Free Software Foundation
6
7   The Gnome Library is free software; you can redistribute it and/or
8   modify it under the terms of the GNU Library General Public License as
9   published by the Free Software Foundation; either version 2 of the
10   License, or (at your option) any later version.
11
12   The Gnome Library is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   Library General Public License for more details.
16
17   You should have received a copy of the GNU Library General Public
18   License along with the Gnome Library; see the file COPYING.LIB.  If not,
19   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20   Boston, MA 02111-1307, USA.
21
22   Author: Darin Adler <darin@eazel.com>
23*/
24
25#include <config.h>
26
27#include <glib.h>
28#include <signal.h>
29#include <stdlib.h>
30#include <stdio.h>
31#include <fcntl.h>
32#include <libgnorba/gnorba.h>
33#include <unistd.h>
34
35#include "gnome-vfs.h"
36#include "gnome-vfs-backend.h"
37
38#define TEST_ASSERT(expression, message) \
39        G_STMT_START { if (!(expression)) test_failed message; } G_STMT_END
40
41static GnomeVFSAsyncHandle *test_handle;
42static gpointer test_callback_data;
43static gboolean test_done;
44
45#define MAX_THREAD_WAIT 100
46
47static void
48stop_after_log (const char *domain, GLogLevelFlags level,
49        const char *message, gpointer data)
50{
51        void (* saved_handler)(int);
52       
53        g_log_default_handler(domain, level, message, data);
54
55        saved_handler = signal (SIGINT, SIG_IGN);
56        raise(SIGINT);
57        signal(SIGINT, saved_handler);
58}
59
60static void
61make_asserts_break (const char *domain)
62{
63        g_log_set_handler (domain,
64                (GLogLevelFlags) (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING),
65                stop_after_log, NULL);
66}
67
68static int
69get_free_file_descriptor_count (void)
70{
71        int count;
72        GList *list, *p;
73        int fd;
74
75        list = NULL;
76        for (count = 0; ; count++) {
77                fd = open ("/dev/null", O_RDONLY);
78                if (fd == -1) {
79                        break;
80                }
81                list = g_list_prepend (list, GINT_TO_POINTER (fd));
82        }
83
84        for (p = list; p != NULL; p = p->next) {
85                close (GPOINTER_TO_INT (p->data));
86        }
87        g_list_free (list);
88
89        return count;
90}
91
92static int free_at_start;
93
94static int
95get_used_file_descriptor_count (void)
96{
97        return free_at_start - get_free_file_descriptor_count ();
98}
99
100static gboolean
101wait_for_boolean (gboolean *wait_for_it)
102{
103        int i;
104
105        if (*wait_for_it) {
106                return TRUE;
107        }
108
109        for (i = 0; i < MAX_THREAD_WAIT; i++) {
110                usleep (1);
111                gtk_main_iteration_do (FALSE);
112                if (*wait_for_it) {
113                        return TRUE;
114                }
115        }
116        return FALSE;
117}
118
119static gboolean
120wait_until_vfs_threads_gone (void)
121{
122        int i;
123
124        if (gnome_vfs_backend_get_job_count () == 0) {
125                return TRUE;
126        }
127
128        for (i = 0; i < MAX_THREAD_WAIT; i++) {
129                usleep (1);
130                gtk_main_iteration_do (FALSE);
131                if (gnome_vfs_backend_get_job_count () == 0) {
132                        return TRUE;
133                }
134        }
135        return FALSE;
136}
137
138static gboolean
139wait_until_vfs_threads_gone_no_main (void)
140{
141        int i;
142
143        if (gnome_vfs_backend_get_job_count () == 0) {
144                return TRUE;
145        }
146
147        for (i = 0; i < MAX_THREAD_WAIT; i++) {
148                usleep (1);
149                if (gnome_vfs_backend_get_job_count () == 0) {
150                        return TRUE;
151                }
152        }
153        return FALSE;
154}
155
156static gboolean
157wait_until_file_descriptors_gone (void)
158{
159        int i;
160
161        if (get_used_file_descriptor_count () == 0) {
162                return TRUE;
163        }
164
165        for (i = 0; i < MAX_THREAD_WAIT; i++) {
166                usleep (1);
167                gtk_main_iteration_do (FALSE);
168                if (get_used_file_descriptor_count () == 0) {
169                        return TRUE;
170                }
171        }
172        return FALSE;
173}
174
175static gboolean at_least_one_test_failed = FALSE;
176
177static void
178test_failed (const char *format, ...)
179{
180        va_list arguments;
181        char *message;
182
183        va_start (arguments, format);
184        message = g_strdup_vprintf (format, arguments);
185        va_end (arguments);
186
187        g_message ("test failed: %s", message);
188        at_least_one_test_failed = TRUE;
189}
190
191static void
192get_file_info_callback (GnomeVFSAsyncHandle *handle,
193                        GList *results,
194                        gpointer callback_data)
195{
196        TEST_ASSERT (handle == test_handle, ("get_file_info, bad handle"));
197        TEST_ASSERT (g_list_length (results) == 1, ("get_file_info, bad list length"));
198        TEST_ASSERT (callback_data == test_callback_data, ("get_file_info, bad handle"));
199
200        test_handle = NULL;
201        g_free (callback_data);
202
203        test_done = TRUE;
204}
205
206static void
207first_get_file_info (void)
208{
209        GList *uri_list;
210
211        /* Start a get_file_info call. */
212        test_done = FALSE;
213        test_callback_data = g_malloc (1);
214        uri_list = g_list_prepend (NULL, gnome_vfs_uri_new ("file:///dev/null"));
215        gnome_vfs_async_get_file_info (&test_handle,
216                                       uri_list,
217                                       GNOME_VFS_FILE_INFO_DEFAULT,
218                                       get_file_info_callback,
219                                       test_callback_data);
220        g_list_free (uri_list);
221
222        /* Wait until it is done. */
223        TEST_ASSERT (wait_for_boolean (&test_done), ("first_get_file_info: callback was not called"));
224        TEST_ASSERT (wait_until_vfs_threads_gone (), ("first_get_file_info: thread never went away"));
225
226        /* For some reason, this consumes file descriptors.
227         * I don't know why.
228         */
229}
230
231static void
232test_get_file_info (void)
233{
234        GList *uri_list;
235
236        /* Start a get_file_info call. */
237        test_done = FALSE;
238        test_callback_data = g_malloc (1);
239        uri_list = g_list_prepend (NULL, gnome_vfs_uri_new ("file:///dev/null"));
240        gnome_vfs_async_get_file_info (&test_handle,
241                                       uri_list,
242                                       GNOME_VFS_FILE_INFO_DEFAULT,
243                                       get_file_info_callback,
244                                       test_callback_data);
245        g_list_free (uri_list);
246
247        /* Wait until it is done. */
248        TEST_ASSERT (wait_for_boolean (&test_done), ("get_file_info 1: callback was not called"));
249        TEST_ASSERT (wait_until_vfs_threads_gone (), ("get_file_info 1: thread never went away"));
250        TEST_ASSERT (get_used_file_descriptor_count () == 0,
251                     ("get_file_info 1: %d file descriptors leaked", get_used_file_descriptor_count ()));
252        free_at_start = get_free_file_descriptor_count ();
253
254        /* Cancel one right after starting it. */
255        test_done = FALSE;
256        test_callback_data = g_malloc (1);
257        uri_list = g_list_prepend (NULL, gnome_vfs_uri_new ("file:///dev/null"));
258        gnome_vfs_async_get_file_info (&test_handle,
259                                       uri_list,
260                                       GNOME_VFS_FILE_INFO_DEFAULT,
261                                       get_file_info_callback,
262                                       test_callback_data);
263        g_list_free (uri_list);
264        gnome_vfs_async_cancel (test_handle);
265        g_free (test_callback_data);
266
267        /* Wait until it is done. */
268        TEST_ASSERT (wait_until_vfs_threads_gone (), ("get_file_info 2: thread never went away"));
269        TEST_ASSERT (get_used_file_descriptor_count () == 0,
270                     ("get_file_info 2: %d file descriptors leaked", get_used_file_descriptor_count ()));
271        TEST_ASSERT (test_done == FALSE, ("get_file_info 2: callback was called"));
272        free_at_start = get_free_file_descriptor_count ();
273}
274
275static gboolean file_open_flag;
276
277static void
278file_open_callback (GnomeVFSAsyncHandle *handle,
279                    GnomeVFSResult result,
280                    gpointer callback_data)
281{
282        TEST_ASSERT (handle == test_handle, ("open callback, bad handle"));
283        TEST_ASSERT (result == GNOME_VFS_OK, ("open callback, bad result"));
284        TEST_ASSERT (callback_data == test_callback_data, ("open callback, bad callback data"));
285
286        file_open_flag = TRUE;
287}
288
289static gboolean file_closed_flag;
290
291static void
292file_close_callback (GnomeVFSAsyncHandle *handle,
293                     GnomeVFSResult result,
294                     gpointer callback_data)
295{
296        TEST_ASSERT (handle == test_handle, ("close callback, bad handle"));
297        TEST_ASSERT (result == GNOME_VFS_OK, ("close callback, bad result"));
298        TEST_ASSERT (callback_data == test_callback_data, ("close callback, bad callback data"));
299
300        file_closed_flag = TRUE;
301}
302
303static gboolean file_read_flag;
304char read_buffer[1];
305
306static void
307file_read_callback (GnomeVFSAsyncHandle *handle,
308                    GnomeVFSResult result,
309                    gpointer buffer,
310                    GnomeVFSFileSize bytes_requested,
311                    GnomeVFSFileSize bytes_read,
312                    gpointer callback_data)
313{
314        TEST_ASSERT (handle == test_handle, ("read callback, bad handle"));
315        TEST_ASSERT (result == GNOME_VFS_OK, ("read callback, bad result"));
316        TEST_ASSERT (buffer == read_buffer, ("read callback, bad buffer"));
317        TEST_ASSERT (bytes_requested == 1, ("read callback, bad bytes_requested"));
318        TEST_ASSERT (bytes_read == 1, ("read callback, bad bytes_read"));
319        TEST_ASSERT (callback_data == test_callback_data, ("read callback, bad callback data"));
320
321        file_read_flag = TRUE;
322}
323
324static gboolean directory_load_flag;
325
326static void
327directory_load_callback (GnomeVFSAsyncHandle *handle,
328                         GnomeVFSResult result,
329                         GnomeVFSDirectoryList *list,
330                         guint entries_read,
331                         gpointer callback_data)
332{
333        GnomeVFSFileInfo *element;
334
335        for (element = gnome_vfs_directory_list_first (list);
336                element != NULL;
337                element = gnome_vfs_directory_list_next (list)) {
338                gnome_vfs_file_info_ref (element);
339        }
340       
341        for (element = gnome_vfs_directory_list_first (list);
342                element != NULL;
343                element = gnome_vfs_directory_list_next (list)) {
344                gnome_vfs_file_info_unref (element);
345        }
346       
347        directory_load_flag = TRUE;
348}
349
350static gboolean directory_load_failed_flag;
351
352static void
353directory_load_failed_callback (GnomeVFSAsyncHandle *handle,
354                                GnomeVFSResult result,
355                                GnomeVFSDirectoryList *list,
356                                guint entries_read,
357                                gpointer callback_data)
358{
359        g_assert (result != GNOME_VFS_OK);
360        directory_load_failed_flag = TRUE;
361}
362
363static void
364test_open_read_close (void)
365{
366        file_open_flag = FALSE;
367        gnome_vfs_async_open (&test_handle,
368                              "file:///etc/passwd",
369                              GNOME_VFS_OPEN_READ,
370                              file_open_callback,
371                              test_callback_data);
372        TEST_ASSERT (wait_for_boolean (&file_open_flag), ("open: callback was not called"));
373
374        file_read_flag = FALSE;
375        gnome_vfs_async_read (test_handle,
376                              read_buffer,
377                              1,
378                              file_read_callback,
379                              test_callback_data);
380
381        TEST_ASSERT (wait_for_boolean (&file_read_flag), ("open read close: read callback was not called"));
382        file_closed_flag = FALSE;
383        gnome_vfs_async_close (test_handle,
384                               file_close_callback,
385                               test_callback_data);
386
387        TEST_ASSERT (wait_for_boolean (&file_closed_flag), ("open read close: close callback was not called"));
388
389        TEST_ASSERT (wait_until_vfs_threads_gone (), ("open read cancel close: thread never went away"));
390        TEST_ASSERT (get_used_file_descriptor_count () == 0,
391                     ("open read cancel close: %d file descriptors leaked", get_used_file_descriptor_count ()));
392        free_at_start = get_free_file_descriptor_count ();
393}
394
395static void
396test_open_read_cancel_close (void)
397{
398        file_open_flag = FALSE;
399        gnome_vfs_async_open (&test_handle,
400                              "file:///etc/passwd",
401                              GNOME_VFS_OPEN_READ,
402                              file_open_callback,
403                              test_callback_data);
404        TEST_ASSERT (wait_for_boolean (&file_open_flag), ("open: callback was not called"));
405
406        file_read_flag = FALSE;
407        gnome_vfs_async_read (test_handle,
408                              read_buffer,
409                              1,
410                              file_read_callback,
411                              test_callback_data);
412        gnome_vfs_async_cancel (test_handle);
413
414        file_closed_flag = FALSE;
415        gnome_vfs_async_close (test_handle,
416                               file_close_callback,
417                               test_callback_data);
418
419        TEST_ASSERT (wait_for_boolean (&file_closed_flag), ("open read cancel close: callback was not called"));
420        TEST_ASSERT (!file_read_flag, ("open read cancel close: read callback was called"));
421
422        TEST_ASSERT (wait_until_vfs_threads_gone (), ("open read cancel close: thread never went away"));
423        TEST_ASSERT (get_used_file_descriptor_count () == 0,
424                     ("open read cancel close: %d file descriptors leaked", get_used_file_descriptor_count ()));
425        free_at_start = get_free_file_descriptor_count ();
426}
427
428static void
429test_open_close (void)
430{
431        file_open_flag = FALSE;
432        gnome_vfs_async_open (&test_handle,
433                              "file:///etc/passwd",
434                              GNOME_VFS_OPEN_READ,
435                              file_open_callback,
436                              test_callback_data);
437        TEST_ASSERT (wait_for_boolean (&file_open_flag), ("open: open callback was not called"));
438       
439        file_closed_flag = FALSE;
440        gnome_vfs_async_close (test_handle,
441                               file_close_callback,
442                               test_callback_data);
443
444
445        TEST_ASSERT (wait_for_boolean (&file_closed_flag), ("open close: close callback was not called"));
446       
447        TEST_ASSERT (wait_until_vfs_threads_gone (), ("open cancel 1: thread never went away"));
448        TEST_ASSERT (get_used_file_descriptor_count () == 0,
449                     ("open cancel 1: %d file descriptors leaked", get_used_file_descriptor_count ()));
450        free_at_start = get_free_file_descriptor_count ();
451}
452
453static void
454test_open_cancel (void)
455{
456        file_open_flag = FALSE;
457        gnome_vfs_async_open (&test_handle,
458                              "file:///etc/passwd",
459                              GNOME_VFS_OPEN_READ,
460                              file_open_callback,
461                              test_callback_data);
462        gnome_vfs_async_cancel (test_handle);
463
464        TEST_ASSERT (wait_until_vfs_threads_gone (), ("open cancel 1: thread never went away"));
465        TEST_ASSERT (!file_open_flag, ("open cancel 1: open callback was called"));
466        TEST_ASSERT (get_used_file_descriptor_count () == 0,
467                     ("open cancel 1: %d file descriptors leaked", get_used_file_descriptor_count ()));
468        free_at_start = get_free_file_descriptor_count ();
469
470        file_open_flag = FALSE;
471        gnome_vfs_async_open (&test_handle,
472                              "file:///etc/passwd",
473                              GNOME_VFS_OPEN_READ,
474                              file_open_callback,
475                              test_callback_data);
476        wait_until_vfs_threads_gone_no_main ();
477        gnome_vfs_async_cancel (test_handle);
478        TEST_ASSERT (wait_until_file_descriptors_gone (),
479                     ("open cancel 2: %d file descriptors leaked", get_used_file_descriptor_count ()));
480        free_at_start = get_free_file_descriptor_count ();
481        TEST_ASSERT (wait_until_vfs_threads_gone (), ("open cancel 2: later thread never went away"));
482        TEST_ASSERT (!file_open_flag, ("open cancel 2: open callback was called"));
483}
484
485static void
486file_open_fail_callback (GnomeVFSAsyncHandle *handle,
487                         GnomeVFSResult result,
488                         gpointer callback_data)
489{
490        TEST_ASSERT (handle == test_handle, ("open callback, bad handle"));
491        TEST_ASSERT (result == GNOME_VFS_ERROR_NOT_FOUND, ("open callback, bad result"));
492        TEST_ASSERT (callback_data == test_callback_data, ("open callback, bad callback data"));
493
494        file_open_flag = TRUE;
495}
496
497static void
498test_open_fail (void)
499{
500        file_open_flag = FALSE;
501        gnome_vfs_async_open (&test_handle,
502                              "file:///etc/mugwump-xxx",
503                              GNOME_VFS_OPEN_READ,
504                              file_open_fail_callback,
505                              test_callback_data);
506        TEST_ASSERT (wait_for_boolean (&file_open_flag), ("open fail 1: callback was not called"));
507        TEST_ASSERT (wait_until_vfs_threads_gone (), ("open fail 1: thread never went away"));
508        TEST_ASSERT (get_used_file_descriptor_count () == 0,
509                     ("open fail 1: %d file descriptors leaked", get_used_file_descriptor_count ()));
510        free_at_start = get_free_file_descriptor_count ();
511}
512
513static void
514my_yield (int count)
515{
516        for (; count > 0; count--) {
517                usleep (100);
518                gtk_main_iteration_do (FALSE);
519        }
520}
521
522static void
523test_load_directory_cancel (int delay_till_cancel, int chunk_count)
524{
525        GnomeVFSAsyncHandle *handle;
526        guint num_entries;
527       
528       
529        gnome_vfs_async_load_directory (&handle,
530                                        "file:///etc",
531                                        GNOME_VFS_FILE_INFO_GET_MIME_TYPE
532                                         | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE
533                                         | GNOME_VFS_FILE_INFO_FOLLOW_LINKS,
534                                        NULL,
535                                        FALSE,
536                                        GNOME_VFS_DIRECTORY_FILTER_NONE,
537                                        0,
538                                        NULL,
539                                        chunk_count,
540                                        directory_load_callback,
541                                        &num_entries);
542       
543        usleep (delay_till_cancel * 100);
544       
545        directory_load_flag = FALSE;
546        gnome_vfs_async_cancel (handle);
547        TEST_ASSERT (wait_until_vfs_threads_gone (), ("open cancel 1: thread never went away"));
548        TEST_ASSERT (!directory_load_flag, ("load directory cancel 1: load callback was called"));
549
550        gnome_vfs_async_load_directory (&handle,
551                                        "file:///etc",
552                                        GNOME_VFS_FILE_INFO_GET_MIME_TYPE
553                                         | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE
554                                         | GNOME_VFS_FILE_INFO_FOLLOW_LINKS,
555                                        NULL,
556                                        FALSE,
557                                        GNOME_VFS_DIRECTORY_FILTER_NONE,
558                                        0,
559                                        NULL,
560                                        chunk_count,
561                                        directory_load_callback,
562                                        &num_entries);
563       
564        my_yield (delay_till_cancel);
565       
566        directory_load_flag = FALSE;
567        gnome_vfs_async_cancel (handle);
568        TEST_ASSERT (wait_until_vfs_threads_gone (), ("open cancel 2: thread never went away"));
569        TEST_ASSERT (!directory_load_flag, ("load directory cancel 2: load callback was called"));
570}
571
572static void
573test_load_directory_fail (void)
574{
575        GnomeVFSAsyncHandle *handle;
576        guint num_entries;
577       
578        directory_load_failed_flag = FALSE;
579        gnome_vfs_async_load_directory (&handle,
580                                        "file:///strcprstskrzkrk",
581                                        GNOME_VFS_FILE_INFO_GET_MIME_TYPE
582                                         | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE
583                                         | GNOME_VFS_FILE_INFO_FOLLOW_LINKS,
584                                        NULL,
585                                        FALSE,
586                                        GNOME_VFS_DIRECTORY_FILTER_NONE,
587                                        0,
588                                        NULL,
589                                        32,
590                                        directory_load_failed_callback,
591                                        &num_entries);
592               
593        TEST_ASSERT (wait_for_boolean (&directory_load_failed_flag), ("load directory cancel 1: load callback was not called"));
594        TEST_ASSERT (wait_until_vfs_threads_gone (), ("open cancel 1: thread never went away"));
595}
596
597static gboolean find_directory_flag;
598
599static void
600test_find_directory_callback (GnomeVFSAsyncHandle *handle,
601                              GList *results,
602                              gpointer callback_data)
603{
604        GList *element;
605
606        find_directory_flag = TRUE;
607
608        for (element = results; element != NULL; element = element->next) {
609                GnomeVFSFindDirectoryResult *result_item = (GnomeVFSFindDirectoryResult *)element->data;
610               
611                if (result_item->result == GNOME_VFS_OK) {
612                        gnome_vfs_uri_ref (result_item->uri);
613                        gnome_vfs_uri_unref (result_item->uri);
614                }
615        }
616       
617        g_assert (callback_data == &find_directory_flag);
618}
619
620static void
621test_find_directory (int delay_till_cancel)
622{
623        GnomeVFSAsyncHandle *handle;
624        GList *vfs_uri_as_list;
625
626
627        vfs_uri_as_list = g_list_append (NULL, gnome_vfs_uri_new ("file://~"));
628        vfs_uri_as_list = g_list_append (vfs_uri_as_list, gnome_vfs_uri_new ("file:///ace_of_spades"));
629       
630        find_directory_flag = FALSE;
631       
632        gnome_vfs_async_find_directory (&handle, vfs_uri_as_list,
633                GNOME_VFS_DIRECTORY_KIND_TRASH, FALSE, TRUE, 0777,
634                test_find_directory_callback, &find_directory_flag);
635               
636        TEST_ASSERT (wait_for_boolean (&find_directory_flag), ("find directory cancel 1: callback was not called"));
637       
638        find_directory_flag = FALSE;
639       
640        gnome_vfs_async_find_directory (&handle, vfs_uri_as_list,
641                GNOME_VFS_DIRECTORY_KIND_TRASH, FALSE, TRUE, 0777,
642                test_find_directory_callback, &find_directory_flag);
643       
644        usleep (delay_till_cancel * 100);
645       
646        gnome_vfs_async_cancel (handle);
647        TEST_ASSERT (wait_until_vfs_threads_gone (), ("open cancel 2: thread never went away"));
648        TEST_ASSERT (!find_directory_flag, ("find directory cancel 2: callback was called"));
649
650       
651        gnome_vfs_async_find_directory (&handle, vfs_uri_as_list,
652                GNOME_VFS_DIRECTORY_KIND_TRASH, FALSE, TRUE, 0777,
653                test_find_directory_callback, &find_directory_flag);
654       
655        my_yield (delay_till_cancel);
656       
657        find_directory_flag = FALSE;
658        gnome_vfs_async_cancel (handle);
659        TEST_ASSERT (wait_until_vfs_threads_gone (), ("open cancel 3: thread never went away"));
660        TEST_ASSERT (!find_directory_flag, ("find directory cancel 3: callback was called"));
661
662        gnome_vfs_uri_list_free (vfs_uri_as_list);
663}
664
665int
666main (int argc, char **argv)
667{
668        CORBA_Environment ev;
669
670        make_asserts_break("GnomeVFS");
671        /* Initialize the libraries we use. */
672        g_thread_init (NULL);
673        CORBA_exception_init (&ev);
674        gnome_CORBA_init ("test-async-cancel", "0.0", &argc, argv, 0, &ev);
675        gnome_vfs_init ();
676
677       
678        /* Initialize our own stuff. */
679        free_at_start = get_free_file_descriptor_count ();
680
681        /* Do the basic tests of our own tools. */
682        TEST_ASSERT (get_used_file_descriptor_count () == 0, ("file descriptor count"));
683        TEST_ASSERT (gnome_vfs_backend_get_job_count () == 0, ("VFS thread count"));
684
685        /* Spend those first few file descriptors. */
686        first_get_file_info ();
687        free_at_start = get_free_file_descriptor_count ();
688
689        /* Test to see that a simple async. call works without leaking or anything. */
690        test_get_file_info ();
691        test_get_file_info ();
692        test_open_close ();
693        test_open_close ();
694        test_open_read_close ();
695        test_open_read_close ();
696        test_open_cancel ();
697        test_open_cancel ();
698
699        test_open_fail ();
700        test_open_fail ();
701        test_open_read_cancel_close ();
702        test_open_read_cancel_close ();
703
704        test_load_directory_fail ();
705        test_load_directory_cancel (0, 1);
706        test_load_directory_cancel (1, 1);
707        test_load_directory_cancel (10, 1);
708        test_load_directory_cancel (100, 1);
709        test_load_directory_cancel (0, 1);
710        test_load_directory_cancel (1, 1);
711        test_load_directory_cancel (10, 1);
712        test_load_directory_cancel (100, 1);
713
714        test_load_directory_cancel (0, 32);
715        test_load_directory_cancel (1, 32);
716        test_load_directory_cancel (10, 32);
717        test_load_directory_cancel (100, 32);
718        test_load_directory_cancel (0, 32);
719        test_load_directory_cancel (1, 32);
720        test_load_directory_cancel (10, 32);
721        test_load_directory_cancel (100, 32);
722
723        test_find_directory (0);
724        test_find_directory (0);
725        test_find_directory (1);
726        test_find_directory (1);
727        test_find_directory (10);
728        test_find_directory (10);
729        test_find_directory (100);
730        test_find_directory (100);
731               
732        gnome_vfs_shutdown ();
733        /* Report to "make check" on whether it all worked or not. */
734        return at_least_one_test_failed ? EXIT_FAILURE : EXIT_SUCCESS;
735}
Note: See TracBrowser for help on using the repository browser.