aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_disk.c')
-rw-r--r--src/util/test_disk.c74
1 files changed, 38 insertions, 36 deletions
diff --git a/src/util/test_disk.c b/src/util/test_disk.c
index fb79e7cd8..d8d8021e5 100644
--- a/src/util/test_disk.c
+++ b/src/util/test_disk.c
@@ -46,36 +46,35 @@ testReadWrite ()
46 return 1; 46 return 1;
47 ret = GNUNET_DISK_fn_read (".testfile", tmp, sizeof (tmp) - 1); 47 ret = GNUNET_DISK_fn_read (".testfile", tmp, sizeof (tmp) - 1);
48 if (ret < 0) 48 if (ret < 0)
49 { 49 {
50 fprintf (stderr, 50 fprintf (stderr, "Error reading file `%s' in testReadWrite\n", ".testfile");
51 "Error reading file `%s' in testReadWrite\n", ".testfile"); 51 return 1;
52 return 1; 52 }
53 }
54 tmp[ret] = '\0'; 53 tmp[ret] = '\0';
55 if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1)) 54 if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1))
56 { 55 {
57 fprintf (stderr, 56 fprintf (stderr,
58 "Error in testReadWrite: *%s* != *%s* for file %s\n", 57 "Error in testReadWrite: *%s* != *%s* for file %s\n",
59 tmp, TESTSTRING, ".testfile"); 58 tmp, TESTSTRING, ".testfile");
60 return 1; 59 return 1;
61 } 60 }
62 GNUNET_DISK_file_copy (".testfile", ".testfile2"); 61 GNUNET_DISK_file_copy (".testfile", ".testfile2");
63 memset (tmp, 0, sizeof (tmp)); 62 memset (tmp, 0, sizeof (tmp));
64 ret = GNUNET_DISK_fn_read (".testfile2", tmp, sizeof (tmp) - 1); 63 ret = GNUNET_DISK_fn_read (".testfile2", tmp, sizeof (tmp) - 1);
65 if (ret < 0) 64 if (ret < 0)
66 { 65 {
67 fprintf (stderr, 66 fprintf (stderr,
68 "Error reading file `%s' in testReadWrite\n", ".testfile2"); 67 "Error reading file `%s' in testReadWrite\n", ".testfile2");
69 return 1; 68 return 1;
70 } 69 }
71 tmp[ret] = '\0'; 70 tmp[ret] = '\0';
72 if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1)) 71 if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1))
73 { 72 {
74 fprintf (stderr, 73 fprintf (stderr,
75 "Error in testReadWrite: *%s* != *%s* for file %s\n", 74 "Error in testReadWrite: *%s* != *%s* for file %s\n",
76 tmp, TESTSTRING, ".testfile2"); 75 tmp, TESTSTRING, ".testfile2");
77 return 1; 76 return 1;
78 } 77 }
79 78
80 GNUNET_break (0 == UNLINK (".testfile")); 79 GNUNET_break (0 == UNLINK (".testfile"));
81 GNUNET_break (0 == UNLINK (".testfile2")); 80 GNUNET_break (0 == UNLINK (".testfile2"));
@@ -117,11 +116,11 @@ testOpenClose ()
117 while ((avail == GNUNET_DISK_get_blocks_available (".testfile")) && 116 while ((avail == GNUNET_DISK_get_blocks_available (".testfile")) &&
118 (avail != -1)) 117 (avail != -1))
119 if (16 != GNUNET_DISK_file_write (fh, "HelloWorld123456", 16)) 118 if (16 != GNUNET_DISK_file_write (fh, "HelloWorld123456", 16))
120 { 119 {
121 GNUNET_DISK_file_close (fh); 120 GNUNET_DISK_file_close (fh);
122 GNUNET_break (0 == UNLINK (".testfile")); 121 GNUNET_break (0 == UNLINK (".testfile"));
123 return 1; 122 return 1;
124 } 123 }
125 GNUNET_DISK_file_close (fh); 124 GNUNET_DISK_file_close (fh);
126 GNUNET_break (0 == UNLINK (".testfile")); 125 GNUNET_break (0 == UNLINK (".testfile"));
127 126
@@ -162,6 +161,7 @@ iter_callback (void *cls,
162 const char *filename, const char *dirname) 161 const char *filename, const char *dirname)
163{ 162{
164 int *i = cls; 163 int *i = cls;
164
165 (*i)++; 165 (*i)++;
166 GNUNET_DISK_directory_iterator_next (di, GNUNET_NO); 166 GNUNET_DISK_directory_iterator_next (di, GNUNET_NO);
167} 167}
@@ -210,7 +210,8 @@ testGetHome ()
210 GNUNET_CONFIGURATION_destroy (cfg); 210 GNUNET_CONFIGURATION_destroy (cfg);
211 ret = strcmp ("/tmp/test-gnunet-disk-a/b/c/d/e", fn); 211 ret = strcmp ("/tmp/test-gnunet-disk-a/b/c/d/e", fn);
212 GNUNET_free (fn); 212 GNUNET_free (fn);
213 GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove ("/tmp/test-gnunet-disk-a")); 213 GNUNET_break (GNUNET_OK ==
214 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-disk-a"));
214 return ret; 215 return ret;
215} 216}
216 217
@@ -218,12 +219,13 @@ static int
218testCanonicalize () 219testCanonicalize ()
219{ 220{
220 char *fn = GNUNET_strdup ("ab?><|cd*ef:/g\""); 221 char *fn = GNUNET_strdup ("ab?><|cd*ef:/g\"");
222
221 GNUNET_DISK_filename_canonicalize (fn); 223 GNUNET_DISK_filename_canonicalize (fn);
222 if (0 != strcmp (fn, "ab____cd_ef__g_")) 224 if (0 != strcmp (fn, "ab____cd_ef__g_"))
223 { 225 {
224 GNUNET_free (fn); 226 GNUNET_free (fn);
225 return 1; 227 return 1;
226 } 228 }
227 GNUNET_free (fn); 229 GNUNET_free (fn);
228 return 0; 230 return 0;
229} 231}
@@ -275,9 +277,9 @@ main (int argc, char *argv[])
275 failureCount += testChangeOwner (); 277 failureCount += testChangeOwner ();
276 failureCount += testDirMani (); 278 failureCount += testDirMani ();
277 if (failureCount != 0) 279 if (failureCount != 0)
278 { 280 {
279 fprintf (stderr, "\n%u TESTS FAILED!\n", failureCount); 281 fprintf (stderr, "\n%u TESTS FAILED!\n", failureCount);
280 return -1; 282 return -1;
281 } 283 }
282 return 0; 284 return 0;
283} /* end of main */ 285} /* end of main */