1 /* This FileX test concentrates on the basic directory naming operations.  */
2 
3 #ifndef FX_STANDALONE_ENABLE
4 #include   "tx_api.h"
5 #endif
6 #include   "fx_api.h"
7 #include   "fx_directory.h"
8 #include   "fx_utility.h"
9 #include   <stdio.h>
10 #include   "fx_ram_driver_test.h"
11 
12 #define     DEMO_STACK_SIZE         4096
13 #define     CACHE_SIZE              16*128
14 
15 
16 /* Define the ThreadX and FileX object control blocks...  */
17 
18 #ifndef FX_STANDALONE_ENABLE
19 static TX_THREAD                ftest_0;
20 #endif
21 static FX_MEDIA                 ram_disk;
22 static CHAR                     max_name[FX_MAX_LONG_NAME_LEN+2];
23 static CHAR                     return_name[FX_MAX_LONG_NAME_LEN+1];
24 
25 
26 /* Define the counters used in the test application...  */
27 
28 #ifndef FX_STANDALONE_ENABLE
29 static UCHAR                  *ram_disk_memory;
30 static UCHAR                  *cache_buffer;
31 #else
32 static UCHAR                  cache_buffer[CACHE_SIZE];
33 #endif
34 
35 
36 /* Define thread prototypes.  */
37 
38 void    filex_directory_naming_application_define(void *first_unused_memory);
39 static void    ftest_0_entry(ULONG thread_input);
40 
41 VOID  _fx_ram_driver(FX_MEDIA *media_ptr);
42 void  test_control_return(UINT status);
43 
44 
45 
46 /* Define what the initial system looks like.  */
47 
48 #ifdef CTEST
test_application_define(void * first_unused_memory)49 void test_application_define(void *first_unused_memory)
50 #else
51 void    filex_directory_naming_application_define(void *first_unused_memory)
52 #endif
53 {
54 
55 #ifndef FX_STANDALONE_ENABLE
56 UCHAR    *pointer;
57 
58 
59     /* Setup the working pointer.  */
60     pointer =  (UCHAR *) first_unused_memory;
61 
62     /* Create the main thread.  */
63     tx_thread_create(&ftest_0, "thread 0", ftest_0_entry, 0,
64             pointer, DEMO_STACK_SIZE,
65             4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
66 
67     pointer =  pointer + DEMO_STACK_SIZE;
68 
69     /* Setup memory for the RAM disk and the sector cache.  */
70     cache_buffer =  pointer;
71     pointer =  pointer + CACHE_SIZE;
72     ram_disk_memory =  pointer;
73 
74 #endif
75 
76     /* Initialize the FileX system.  */
77     fx_system_initialize();
78 #ifdef FX_STANDALONE_ENABLE
79     ftest_0_entry(0);
80 #endif
81 }
82 
83 
84 
85 /* Define the test threads.  */
86 
ftest_0_entry(ULONG thread_input)87 static void    ftest_0_entry(ULONG thread_input)
88 {
89 
90 UINT        status;
91 CHAR        *path_ptr;
92 CHAR        special_name[10];
93 UINT        i;
94 
95     FX_PARAMETER_NOT_USED(thread_input);
96 
97     /* Print out some test information banners.  */
98     printf("FileX Test:   Directory naming test..................................");
99 
100     /* Format the media.  This needs to be done before opening it!  */
101     status =  fx_media_format(&ram_disk,
102                             _fx_ram_driver,         // Driver entry
103                             ram_disk_memory,        // RAM disk memory pointer
104                             cache_buffer,           // Media buffer pointer
105                             CACHE_SIZE,             // Media buffer size
106                             "MY_RAM_DISK",          // Volume Name
107                             1,                      // Number of FATs
108                             32,                     // Directory Entries
109                             0,                      // Hidden sectors
110                             512,                    // Total sectors
111                             128,                    // Sector size
112                             1,                      // Sectors per cluster
113                             1,                      // Heads
114                             1);                     // Sectors per track
115 
116     /* Determine if the format had an error.  */
117     if (status)
118     {
119 
120         printf("ERROR!\n");
121         test_control_return(1);
122     }
123 
124     /* Try to rename a directory before the media is opened to generate an error */
125     status = fx_directory_rename(&ram_disk, "/A0", "/A1");
126     if (status != FX_MEDIA_NOT_OPEN)
127     {
128         printf("ERROR!\n");
129         test_control_return(2);
130     }
131 
132     /* Open the ram_disk.  */
133     status =  fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, CACHE_SIZE);
134 
135     /* Check the status.  */
136     if (status != FX_SUCCESS)
137     {
138 
139         /* Error, return error code.  */
140         printf("ERROR!\n");
141         test_control_return(3);
142     }
143 
144     /* Get the current path. This should be / or NULL.   */
145     status =  fx_directory_default_get(&ram_disk, &path_ptr);
146 
147     /* Check the status.  */
148     if ((status != FX_SUCCESS) || (path_ptr[0]))
149     {
150 
151         /* Error getting the path.  Return to caller.  */
152         printf("ERROR!\n");
153         test_control_return(4);
154     }
155 
156     /* Test a directory name that does not exist to generate an error */
157 /*    status = fx_directory_name_test(&ram_disk, "/A0");
158     if (status == FX_SUCCESS)
159     {
160         printf("ERROR!\n");
161         test_control_return(5);
162     }
163 */
164 
165     /* test some directory names to test the directory search function */
166 /*    status  = fx_directory_create(&ram_disk, "\\TEST");
167     status += fx_directory_name_test(&ram_disk, "\\TEST");
168     status += fx_directory_delete(&ram_disk, "\\TEST");
169     if (status != FX_SUCCESS)
170     {
171         printf("ERROR!\n");
172         test_control_return(6);
173     }
174 */
175 
176 
177     /* Create a series of directories...  */
178     status =   fx_directory_create(&ram_disk, "/A0");
179     status +=  fx_directory_create(&ram_disk, "/b0");
180     status +=  fx_directory_create(&ram_disk, "/C0");
181     status +=  fx_directory_create(&ram_disk, "/d0");
182 
183     /* Check for errors...  */
184     if (status != FX_SUCCESS)
185     {
186 
187         /* Error creating directories.  Return to caller.  */
188         printf("ERROR!\n");
189         test_control_return(7);
190     }
191 
192     /* Attempt to create the same directory again.  */
193     status =   fx_directory_create(&ram_disk, "/a0");
194 
195     /* Check for errors...  */
196     if (status != FX_ALREADY_CREATED)
197     {
198 
199         /* Error creating same directory twice.  Return to caller.  */
200         printf("ERROR!\n");
201         test_control_return(8);
202     }
203 
204     /* Create sub-directories with the E5 character.   */
205     special_name[0] =  (CHAR)0xE5;
206     special_name[1] =  0x2E;
207     special_name[2] =  0x54;
208     special_name[3] =  0x58;
209     special_name[4] =  0x54;
210     special_name[5] =  0;
211     status =  fx_directory_create(&ram_disk, special_name);
212     status += fx_media_flush(&ram_disk);
213     status += fx_directory_delete(&ram_disk, special_name);
214 
215     /* Check for errors.  */
216     if (status != FX_SUCCESS)
217     {
218 
219         /* Error creating special name.  Return to caller.  */
220         printf("ERROR!\n");
221         test_control_return(9);
222     }
223 
224     /* Create another special file name.  */
225     special_name[0] =  (CHAR)0xE5;
226     special_name[1] =  0x31;
227     special_name[2] =  0x2E;
228     special_name[3] =  0x54;
229     special_name[4] =  0x58;
230     special_name[5] =  0x54;
231     special_name[6] =  0;
232     status =  fx_directory_create(&ram_disk, special_name);
233     status += fx_media_flush(&ram_disk);
234     status += fx_directory_delete(&ram_disk, special_name);
235 
236     /* Check for errors.  */
237     if (status != FX_SUCCESS)
238     {
239 
240         /* Error creating special name.  Return to caller.  */
241         printf("ERROR!\n");
242         test_control_return(10);
243     }
244 
245     /* Create the next level of sub-directories.... with the interesting names...  */
246     status =   fx_directory_default_set(&ram_disk, "/A0");
247 
248     status =   fx_directory_create(&ram_disk, "a");
249     status +=  fx_directory_create(&ram_disk, "this...ismytestdir");
250     status +=  fx_directory_create(&ram_disk, "this ... is my test dir");
251     status +=  fx_directory_create(&ram_disk, "ThisIsTheFirstVeryLongDirNameForThisTestABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZfirstfile111111111111111100000000000000000000000000000000000000000000000000000000");
252     status +=  fx_directory_create(&ram_disk, "       c");
253     status +=  fx_directory_create(&ram_disk, "       c/    e");
254     status +=  fx_directory_create(&ram_disk, "       c/    e/    f");
255 
256     /* Check for errors.  */
257     if (status != FX_SUCCESS)
258     {
259 
260         /* Error creating interesting directory names.  Return to caller.  */
261         printf("ERROR!\n");
262         test_control_return(11);
263     }
264 
265     /* Now attempt to create a file in each of these sub-directories.  */
266     status =   fx_file_create(&ram_disk, "/A0/a/test.txt");
267     status +=  fx_file_create(&ram_disk, "/A0/this...ismytestdir/test.txt");
268     status +=  fx_file_create(&ram_disk, "/A0/this ... is my test dir/test.txt");
269     status +=  fx_file_create(&ram_disk, "/A0/ThisIsTheFirstVeryLongDirNameForThisTestABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZfirstfile111111111111111100000000000000000000000000000000000000000000000000000000/test.txt");
270     fx_media_flush(&ram_disk);
271     status +=  fx_file_create(&ram_disk, "/A0    /    c/    e/    f/test.txt");
272     fx_media_flush(&ram_disk);
273 
274     /* Check for errors.  */
275     if (status != FX_SUCCESS)
276     {
277 
278         /* Error creating test files in the interesting sub-directories.  Return to caller.  */
279         printf("ERROR!\n");
280         test_control_return(12);
281     }
282 
283     /* Now attempt to delete the file in each of these sub-directories.  */
284     status =   fx_file_delete(&ram_disk, "/A0/a/test.txt");
285     status +=  fx_file_delete(&ram_disk, "/A0/this...ismytestdir/test.txt");
286     status +=  fx_file_delete(&ram_disk, "/A0/this ... is my test dir/test.txt");
287     status +=  fx_file_delete(&ram_disk, "/A0/ThisIsTheFirstVeryLongDirNameForThisTestABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZfirstfile111111111111111100000000000000000000000000000000000000000000000000000000/test.txt");
288     status +=  fx_file_delete(&ram_disk, "/A0    /    c/    e/    f/test.txt");
289 
290     /* Check for errors.  */
291     if (status != FX_SUCCESS)
292     {
293 
294         /* Error deleting test files in the interesting sub-directories.  Return to caller.  */
295         printf("ERROR!\n");
296         test_control_return(13);
297     }
298 
299     /* Now attempt to delete the interesting sub-directories.  */
300     status =   fx_directory_delete(&ram_disk, "/A0/a");
301     status +=  fx_directory_delete(&ram_disk, "/A0/this...ismytestdir");
302     status +=  fx_directory_delete(&ram_disk, "/A0/this ... is my test dir");
303     status +=  fx_directory_delete(&ram_disk, "/A0/ThisIsTheFirstVeryLongDirNameForThisTestABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZfirstfile111111111111111100000000000000000000000000000000000000000000000000000000");
304     status +=  fx_directory_delete(&ram_disk, "/A0/c/e/f");
305     status +=  fx_directory_delete(&ram_disk, "/A0/c/e");
306     status +=  fx_directory_delete(&ram_disk, "/A0/c");
307 
308     /* Check for errors.  */
309     if (status != FX_SUCCESS)
310     {
311 
312         /* Error deleting the interesting sub-directories.  Return to caller.  */
313         printf("ERROR!\n");
314         test_control_return(14);
315     }
316 
317     /* Delete a series of directories...  Use short name for b0 and d0!  */
318     status =   fx_directory_delete(&ram_disk, "/A0");
319     status +=  fx_directory_delete(&ram_disk, "/B0");
320     status +=  fx_directory_delete(&ram_disk, "/C0");
321     status +=  fx_directory_delete(&ram_disk, "/D0");
322 
323     /* Check for errors...  */
324     if (status != FX_SUCCESS)
325     {
326 
327         /* Error deleting directories.  Return to caller.  */
328         printf("ERROR!\n");
329         test_control_return(15);
330     }
331 
332     /* Set default to root directory.  */
333     status =   fx_directory_default_set(&ram_disk, "/");
334 
335     /* Flush the media... should be empty at this point.  */
336     status += fx_media_flush(&ram_disk);
337 
338     /* Now fill the media's root directory until we get an error...  We will use 8.3 names
339        to attempt to create 32 names.    */
340     status +=  fx_directory_create(&ram_disk, "A01");
341     status +=  fx_directory_create(&ram_disk, "A02");
342     status +=  fx_directory_create(&ram_disk, "A03");
343     status +=  fx_directory_create(&ram_disk, "A04");
344     status +=  fx_directory_create(&ram_disk, "A05");
345     status +=  fx_directory_create(&ram_disk, "A06");
346     status +=  fx_directory_create(&ram_disk, "A07");
347     status +=  fx_directory_create(&ram_disk, "A08");
348     status +=  fx_directory_create(&ram_disk, "A09");
349     status +=  fx_directory_create(&ram_disk, "A10");
350     status +=  fx_directory_create(&ram_disk, "A11");
351     status +=  fx_directory_create(&ram_disk, "A12");
352     status +=  fx_directory_create(&ram_disk, "A13");
353     status +=  fx_directory_create(&ram_disk, "A14");
354     status +=  fx_directory_create(&ram_disk, "A15");
355     status +=  fx_directory_create(&ram_disk, "A16");
356     status +=  fx_directory_create(&ram_disk, "A17");
357     status +=  fx_directory_create(&ram_disk, "A18");
358     status +=  fx_directory_create(&ram_disk, "A19");
359     status +=  fx_directory_create(&ram_disk, "A20");
360     status +=  fx_directory_create(&ram_disk, "A21");
361     status +=  fx_directory_create(&ram_disk, "A22");
362     status +=  fx_directory_create(&ram_disk, "A23");
363     status +=  fx_directory_create(&ram_disk, "A24");
364     status +=  fx_directory_create(&ram_disk, "A25");
365     status +=  fx_directory_create(&ram_disk, "A26");
366     status +=  fx_directory_create(&ram_disk, "A27");
367     status +=  fx_directory_create(&ram_disk, "A28");
368     status +=  fx_directory_create(&ram_disk, "A29");
369     status +=  fx_directory_create(&ram_disk, "A30");
370     status +=  fx_directory_create(&ram_disk, "A31");
371     status +=  fx_directory_create(&ram_disk, "A32");
372 
373 fx_media_flush(&ram_disk);
374 
375     /* Check for errors...  */
376     if (status != FX_SUCCESS)
377     {
378 
379         /* Error creating directories.  Return to caller.  */
380         printf("ERROR!\n");
381         test_control_return(16);
382     }
383 
384     /* Attempt to create 33rd name... this should fail.  */
385     status =  fx_directory_create(&ram_disk, "A33");
386 
387     /* Check for errors...  */
388     if (status != FX_NO_MORE_SPACE)
389     {
390 
391         /* Error creating directories.  Return to caller.  */
392         printf("ERROR!\n");
393         test_control_return(17);
394     }
395 
396     /* Flush the media.  */
397     status =  fx_media_flush(&ram_disk);
398 
399     /* Now delete all the names.  */
400     status +=  fx_directory_delete(&ram_disk, "A01");
401     status +=  fx_directory_delete(&ram_disk, "A02");
402     status +=  fx_directory_delete(&ram_disk, "A03");
403     status +=  fx_directory_delete(&ram_disk, "A04");
404     status +=  fx_directory_delete(&ram_disk, "A05");
405     status +=  fx_directory_delete(&ram_disk, "A06");
406     status +=  fx_directory_delete(&ram_disk, "A07");
407     status +=  fx_directory_delete(&ram_disk, "A08");
408     status +=  fx_directory_delete(&ram_disk, "A09");
409     status +=  fx_directory_delete(&ram_disk, "A10");
410     status +=  fx_directory_delete(&ram_disk, "A11");
411     status +=  fx_directory_delete(&ram_disk, "A12");
412     status +=  fx_directory_delete(&ram_disk, "A13");
413     status +=  fx_directory_delete(&ram_disk, "A14");
414     status +=  fx_directory_delete(&ram_disk, "A15");
415     status +=  fx_directory_delete(&ram_disk, "A16");
416     status +=  fx_directory_delete(&ram_disk, "A17");
417     status +=  fx_directory_delete(&ram_disk, "A18");
418     status +=  fx_directory_delete(&ram_disk, "A19");
419     status +=  fx_directory_delete(&ram_disk, "A20");
420     status +=  fx_directory_delete(&ram_disk, "A21");
421     status +=  fx_directory_delete(&ram_disk, "A22");
422     status +=  fx_directory_delete(&ram_disk, "A23");
423     status +=  fx_directory_delete(&ram_disk, "A24");
424     status +=  fx_directory_delete(&ram_disk, "A25");
425     status +=  fx_directory_delete(&ram_disk, "A26");
426     status +=  fx_directory_delete(&ram_disk, "A27");
427     status +=  fx_directory_delete(&ram_disk, "A28");
428     status +=  fx_directory_delete(&ram_disk, "A29");
429     status +=  fx_directory_delete(&ram_disk, "A30");
430     status +=  fx_directory_delete(&ram_disk, "A31");
431     status +=  fx_directory_delete(&ram_disk, "A32");
432 
433     /* Check for errors...  */
434     if (status != FX_SUCCESS)
435     {
436 
437         /* Error deleting directories.  Return to caller.  */
438         printf("ERROR!\n");
439         test_control_return(18);
440     }
441 
442     /* Flush the media.  */
443     status =  fx_media_flush(&ram_disk);
444 
445     /* Now do the same thing, except with 2 entry long names.  */
446     status +=  fx_directory_create(&ram_disk, "b01");
447     status +=  fx_directory_create(&ram_disk, "b02");
448     status +=  fx_directory_create(&ram_disk, "b03");
449     status +=  fx_directory_create(&ram_disk, "b04");
450     status +=  fx_directory_create(&ram_disk, "b05");
451     status +=  fx_directory_create(&ram_disk, "b06");
452     status +=  fx_directory_create(&ram_disk, "b07");
453     status +=  fx_directory_create(&ram_disk, "b08");
454     status +=  fx_directory_create(&ram_disk, "b09");
455     status +=  fx_directory_create(&ram_disk, "b10");
456     status +=  fx_directory_create(&ram_disk, "b11");
457     status +=  fx_directory_create(&ram_disk, "b12");
458     status +=  fx_directory_create(&ram_disk, "b13");
459     status +=  fx_directory_create(&ram_disk, "b14");
460     status +=  fx_directory_create(&ram_disk, "b15");
461     status +=  fx_directory_create(&ram_disk, "b16");
462 
463     /* Check for errors...  */
464     if (status != FX_SUCCESS)
465     {
466 
467         /* Error creating directories.  Return to caller.  */
468         printf("ERROR!\n");
469         test_control_return(19);
470     }
471 
472     /* Attempt to create 17th long name... this should fail.  */
473     status =  fx_directory_create(&ram_disk, "b17");
474 
475     /* Check for errors...  */
476     if (status != FX_NO_MORE_SPACE)
477     {
478 
479         /* Error creating directories.  Return to caller.  */
480         printf("ERROR!\n");
481         test_control_return(20);
482     }
483 
484     /* Flush the media.  */
485     status =  fx_media_flush(&ram_disk);
486 
487     /* Now delete all the names.  */
488     status +=  fx_directory_delete(&ram_disk, "b01");
489     status +=  fx_directory_delete(&ram_disk, "b02");
490     status +=  fx_directory_delete(&ram_disk, "b03");
491     status +=  fx_directory_delete(&ram_disk, "b04");
492     status +=  fx_directory_delete(&ram_disk, "b05");
493     status +=  fx_directory_delete(&ram_disk, "b06");
494     status +=  fx_directory_delete(&ram_disk, "b07");
495     status +=  fx_directory_delete(&ram_disk, "b08");
496     status +=  fx_directory_delete(&ram_disk, "b09");
497     status +=  fx_directory_delete(&ram_disk, "b10");
498     status +=  fx_directory_delete(&ram_disk, "b11");
499     status +=  fx_directory_delete(&ram_disk, "b12");
500     status +=  fx_directory_delete(&ram_disk, "b13");
501     status +=  fx_directory_delete(&ram_disk, "b14");
502     status +=  fx_directory_delete(&ram_disk, "b15");
503     status +=  fx_directory_delete(&ram_disk, "b16");
504 
505     /* Check for errors...  */
506     if (status != FX_SUCCESS)
507     {
508 
509         /* Error deleting directories.  Return to caller.  */
510         printf("ERROR!\n");
511         test_control_return(21);
512     }
513 
514 #if 0
515     /* test the directory free search function for proper error handing with invalid names */
516     FX_DIR_ENTRY dir_entry;
517     dir_entry.fx_dir_entry_name = (char*) malloc(0x100 * sizeof(char));
518     dir_entry.fx_dir_entry_name[0] = '.';
519     dir_entry.fx_dir_entry_name[1] = '.';
520     dir_entry.fx_dir_entry_name[2] = (char)0;
521     status = _fx_directory_free_search(&ram_disk, &dir_entry, &dir_entry);
522     if (status != FX_INVALID_NAME)
523     {
524         printf("ERROR!\n");
525         test_control_return(22);
526     }
527 
528     /* test the directory free search function for proper error handling of special characters */
529 /* This code is executing differently on local vs server. Disabled until cause is explored */
530     dir_entry.fx_dir_entry_name[0] = (char)128;
531     dir_entry.fx_dir_entry_name[1] = (char)128;
532     dir_entry.fx_dir_entry_name[2] = (char)0;
533     status = _fx_directory_free_search(&ram_disk, &dir_entry, &dir_entry);
534     if (status == FX_SUCCESS)
535     {
536         printf("ERROR!\n");
537         test_control_return(23);
538     }
539 
540     /* test the directory free search function for proper error handling of special characters */
541     dir_entry.fx_dir_entry_name[0] = '%';
542     dir_entry.fx_dir_entry_name[1] = '%';
543     dir_entry.fx_dir_entry_name[2] = (char)0;
544     status = _fx_directory_free_search(&ram_disk, &dir_entry, &dir_entry);
545     if (status == FX_SUCCESS)
546     {
547         printf("ERROR!\n");
548         test_control_return(24);
549     }
550 
551     /* test the directory free search function for proper error handling of special characters */
552     dir_entry.fx_dir_entry_name[0] = ']';
553     dir_entry.fx_dir_entry_name[1] = ']';
554     dir_entry.fx_dir_entry_name[2] = (char)0;
555     status = _fx_directory_free_search(&ram_disk, &dir_entry, &dir_entry);
556     if (status == FX_SUCCESS)
557     {
558         printf("ERROR!\n");
559         test_control_return(25);
560     }
561 #endif
562 
563     /* Create a directory.  */
564     status =  fx_directory_create(&ram_disk, "b16");
565 
566     status += fx_media_flush(&ram_disk);
567     _fx_utility_FAT_flush(&ram_disk);
568     _fx_utility_logical_sector_flush(&ram_disk, 1, 60000, FX_TRUE);
569     for (i = 0; i < FX_MAX_FAT_CACHE; i++)
570     {
571         ram_disk.fx_media_fat_cache[i].fx_fat_cache_entry_cluster =  0;
572         ram_disk.fx_media_fat_cache[i].fx_fat_cache_entry_value =  0;
573     }
574 
575     /* Create an I/O error for the directory search inside of fx_directory_name_test.   */
576     _fx_utility_logical_sector_read_error_request =  1;
577     status =  fx_directory_name_test(&ram_disk, "b16");
578     _fx_utility_logical_sector_read_error_request =  0;
579 
580     /* Check for the I/O error.  */
581     if (status != FX_IO_ERROR)
582     {
583 
584         printf("ERROR!\n");
585         test_control_return(26);
586     }
587 
588     /* Test the directory name.  */
589     _fx_directory_name_extract("\\", return_name);
590 
591     /* Check for a good return name.  */
592     if (return_name[0] != 0)
593     {
594 
595         printf("ERROR!\n");
596         test_control_return(27);
597     }
598 
599     /* Now test the maximum length of a name.  */
600     for (i = 0; i < FX_MAX_LONG_NAME_LEN+1; i++)
601     {
602         max_name[i] = 'a';
603     }
604 
605     /* Test for maximum size... and removal of blank spaces.  */
606     _fx_directory_name_extract(max_name, return_name);
607 
608     /* Was the name truncated?  */
609     if (return_name[FX_MAX_LONG_NAME_LEN - 1] != 0)
610     {
611 
612         printf("ERROR!\n");
613         test_control_return(28);
614     }
615 
616     /* Close the media.  */
617     status =  fx_media_close(&ram_disk);
618 
619     /* Determine if the test was successful.  */
620     if (status != FX_SUCCESS)
621     {
622 
623         printf("ERROR!\n");
624         test_control_return(29);
625     }
626     else
627     {
628 
629         printf("SUCCESS!\n");
630         test_control_return(0);
631     }
632 }
633 
634