3 void led_blink(PinName led) {
11 void notify_completion(bool success) {
13 printf("{success}\n");
15 printf("{failure}\n");
19 led_blink(success ? LED1 : LED4);
22 #define TEST_STRING "Hello World!"
24 FILE* test_open(char* path, const char* mode) {
26 f = fopen(path, mode);
28 printf("Error opening file\n");
29 notify_completion(false);
35 void test_write(FILE* f, const char* str) {
36 int n = fprintf(f, str);
37 if (n != strlen(str)) {
38 printf("Error writing file\n");
39 notify_completion(false);
43 void test_close(FILE* f) {
46 printf("Error closing file\n");
47 notify_completion(false);
52 LocalFileSystem local("local");
55 char* str = TEST_STRING;
56 char* buffer = (char*) malloc(sizeof(unsigned char)*strlen(TEST_STRING));
57 int str_len = strlen(TEST_STRING);
59 printf("Write files\n");
61 for (int i=0; i<10; i++) {
62 sprintf(filename, "/local/test_%d.txt", i);
63 printf("Creating file: %s\n", filename);
64 f = test_open(filename, "w");
69 printf("List files:\n");
70 DIR *d = opendir("/local");
72 while((p = readdir(d)) != NULL) {
73 printf("%s\n", p->d_name);
77 notify_completion(true);