aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_fs_test_lib.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-04-19 10:16:45 +0000
committerChristian Grothoff <christian@grothoff.org>2010-04-19 10:16:45 +0000
commit9315a880c07ab72d9c42f3d292c5b9e2c6e50202 (patch)
tree4a7013cf684d4a9e4aec6e0317039bf7f18d1e71 /src/fs/test_fs_test_lib.c
parent541caf3dec54aaee621fed935e667f9ee423ef31 (diff)
downloadgnunet-9315a880c07ab72d9c42f3d292c5b9e2c6e50202.tar.gz
gnunet-9315a880c07ab72d9c42f3d292c5b9e2c6e50202.zip
nicer error handling
Diffstat (limited to 'src/fs/test_fs_test_lib.c')
-rw-r--r--src/fs/test_fs_test_lib.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c
index a62200100..aad4557f9 100644
--- a/src/fs/test_fs_test_lib.c
+++ b/src/fs/test_fs_test_lib.c
@@ -46,15 +46,23 @@ static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS];
46 46
47static struct GNUNET_SCHEDULER_Handle *sched; 47static struct GNUNET_SCHEDULER_Handle *sched;
48 48
49static int ret;
49 50
50static void 51static void
51do_stop (void *cls, 52do_stop (void *cls,
52 const struct GNUNET_SCHEDULER_TaskContext *tc) 53 const struct GNUNET_SCHEDULER_TaskContext *tc)
53{ 54{
54 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); 55 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
55 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 56 {
56 "Finished download, shutting down\n", 57 GNUNET_break (0);
57 (unsigned long long) FILESIZE); 58 ret = 1;
59 }
60 else
61 {
62 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
63 "Finished download, shutting down\n",
64 (unsigned long long) FILESIZE);
65 }
58 GNUNET_FS_TEST_daemons_stop (sched, 66 GNUNET_FS_TEST_daemons_stop (sched,
59 NUM_DAEMONS, 67 NUM_DAEMONS,
60 daemons); 68 daemons);
@@ -65,7 +73,15 @@ static void
65do_download (void *cls, 73do_download (void *cls,
66 const struct GNUNET_FS_Uri *uri) 74 const struct GNUNET_FS_Uri *uri)
67{ 75{
68 GNUNET_assert (NULL != uri); 76 if ((NULL == uri)
77 {
78 GNUNET_break (0);
79 GNUNET_SCHEDULER_add_now (sched,
80 &do_stop,
81 NULL);
82 ret = 1;
83 return;
84 }
69 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
70 "Downloading %llu bytes\n", 86 "Downloading %llu bytes\n",
71 (unsigned long long) FILESIZE); 87 (unsigned long long) FILESIZE);
@@ -82,7 +98,14 @@ static void
82do_publish (void *cls, 98do_publish (void *cls,
83 const struct GNUNET_SCHEDULER_TaskContext *tc) 99 const struct GNUNET_SCHEDULER_TaskContext *tc)
84{ 100{
85 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); 101 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
102 {
103 GNUNET_break (0);
104 ret = 1;
105 GNUNET_SCHEDULER_add_now (sched,
106 &do_stop,
107 NULL);
108 }
86 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 109 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
87 "Publishing %llu bytes\n", 110 "Publishing %llu bytes\n",
88 (unsigned long long) FILESIZE); 111 (unsigned long long) FILESIZE);
@@ -99,7 +122,15 @@ static void
99do_connect (void *cls, 122do_connect (void *cls,
100 const struct GNUNET_SCHEDULER_TaskContext *tc) 123 const struct GNUNET_SCHEDULER_TaskContext *tc)
101{ 124{
102 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); 125 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
126 {
127 GNUNET_break (0);
128 ret = 1;
129 GNUNET_SCHEDULER_add_now (sched,
130 &do_stop,
131 NULL);
132 return;
133 }
103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
104 "Daemons started, will now try to connect them\n"); 135 "Daemons started, will now try to connect them\n");
105 GNUNET_FS_TEST_daemons_connect (sched, 136 GNUNET_FS_TEST_daemons_connect (sched,
@@ -156,7 +187,7 @@ main (int argc, char *argv[])
156 argvx, "test-fs-test-lib", 187 argvx, "test-fs-test-lib",
157 "nohelp", options, &run, NULL); 188 "nohelp", options, &run, NULL);
158 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); 189 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
159 return 0; 190 return ret;
160} 191}
161 192
162/* end of test_gnunet_service_fs_p2p.c */ 193/* end of test_fs_test_lib.c */