7 #include "filesys-stub.h"
11 filesys_init (bool reformat)
14 printk ("filesystem stubs don't support formatting\n");
19 filesys_create (const char *name)
24 filesys_stub_put_string ("create");
25 filesys_stub_put_string (name);
26 filesys_stub_match_string ("create");
27 success = filesys_stub_get_bool ();
28 filesys_stub_unlock ();
34 filesys_open (const char *name)
39 filesys_stub_put_string ("open");
40 filesys_stub_put_string (name);
41 filesys_stub_match_string ("open");
42 file = filesys_stub_get_file ();
43 filesys_stub_unlock ();
49 filesys_remove (const char *name)
54 filesys_stub_put_string ("remove");
55 filesys_stub_put_string (name);
56 filesys_stub_match_string ("remove");
57 success = filesys_stub_get_bool ();
58 filesys_stub_unlock ();
62 #endif /* FILESYS_STUB */
69 filesys_self_test (void)
71 static const char s[] = "This is a test string.";
75 ASSERT (filesys_create ("foo"));
76 ASSERT ((file = filesys_open ("foo")) != NULL);
77 ASSERT (file_write (file, s, sizeof s) == sizeof s);
78 ASSERT (file_tell (file) == sizeof s);
79 ASSERT (file_length (file) == sizeof s);
82 ASSERT ((file = filesys_open ("foo")) != NULL);
83 ASSERT (file_read (file, s2, sizeof s2) == sizeof s2);
84 ASSERT (memcmp (s, s2, sizeof s) == 0);
85 ASSERT (file_tell (file) == sizeof s2);
86 ASSERT (file_length (file) == sizeof s2);
89 ASSERT (filesys_remove ("foo"));