1 /* This FileX test concentrates on the basic directory default path get/set 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 name[256];
23
24
25 /* Define the counters used in the test application... */
26
27 #ifndef FX_STANDALONE_ENABLE
28 static UCHAR *ram_disk_memory;
29 static UCHAR *cache_buffer;
30 #else
31 static UCHAR cache_buffer[CACHE_SIZE];
32 #endif
33
34
35 /* Define thread prototypes. */
36
37 void filex_directory_default_get_set_application_define(void *first_unused_memory);
38 static void ftest_0_entry(ULONG thread_input);
39
40 VOID _fx_ram_driver(FX_MEDIA *media_ptr);
41 void test_control_return(UINT status);
42
43
44
45 /* Define what the initial system looks like. */
46
47 #ifdef CTEST
test_application_define(void * first_unused_memory)48 void test_application_define(void *first_unused_memory)
49 #else
50 void filex_directory_default_get_set_application_define(void *first_unused_memory)
51 #endif
52 {
53
54 #ifndef FX_STANDALONE_ENABLE
55 UCHAR *pointer;
56
57
58 /* Setup the working pointer. */
59 pointer = (UCHAR *) first_unused_memory;
60
61 /* Create the main thread. */
62 tx_thread_create(&ftest_0, "thread 0", ftest_0_entry, 0,
63 pointer, DEMO_STACK_SIZE,
64 4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
65
66 pointer = pointer + DEMO_STACK_SIZE;
67
68 /* Setup memory for the RAM disk and the sector cache. */
69 cache_buffer = pointer;
70 pointer = pointer + CACHE_SIZE;
71 ram_disk_memory = pointer;
72
73 #endif
74
75 /* Initialize the FileX system. */
76 fx_system_initialize();
77 #ifdef FX_STANDALONE_ENABLE
78 ftest_0_entry(0);
79 #endif
80 }
81
82
83
84 /* Define the test threads. */
85
ftest_0_entry(ULONG thread_input)86 static void ftest_0_entry(ULONG thread_input)
87 {
88
89 UINT status;
90 CHAR *path_ptr;
91 CHAR path_name_buffer[32];
92 CHAR test_path_name_buffer[1];
93 ULONG temp;
94 FX_LOCAL_PATH local_path;
95 FX_LOCAL_PATH local_path1;
96 UINT i;
97
98 FX_PARAMETER_NOT_USED(thread_input);
99
100 /* Print out some test information banners. */
101 printf("FileX Test: Directory default get/set test.........................");
102
103 /* Format the media. This needs to be done before opening it! */
104 status = fx_media_format(&ram_disk,
105 _fx_ram_driver, // Driver entry
106 ram_disk_memory, // RAM disk memory pointer
107 cache_buffer, // Media buffer pointer
108 CACHE_SIZE, // Media buffer size
109 "MY_RAM_DISK", // Volume Name
110 1, // Number of FATs
111 32, // Directory Entries
112 0, // Hidden sectors
113 512, // Total sectors
114 128, // Sector size
115 1, // Sectors per cluster
116 1, // Heads
117 1); // Sectors per track
118
119 /* Determine if the format had an error. */
120 if (status)
121 {
122
123 printf("ERROR!\n");
124 test_control_return(1);
125 }
126
127 /* Attempt to set the default directory before the media has been opened to generate an error */
128 status = fx_directory_default_set(&ram_disk, "/A0");
129 if (status != FX_MEDIA_NOT_OPEN)
130 {
131 printf("ERROR!\n");
132 test_control_return(2);
133 }
134
135 /* Attempt to get the default directory before the media has been opened to generate an error */
136 status = fx_directory_default_get(&ram_disk, &path_ptr);
137 if (status != FX_MEDIA_NOT_OPEN)
138 {
139 printf("ERROR!\n");
140 test_control_return(3);
141 }
142
143 /* Attempt to get copy of the default directory before the media has been opened to generate an error */
144 status = fx_directory_default_get_copy(&ram_disk, test_path_name_buffer, sizeof(test_path_name_buffer));
145
146 /* Determine if the test was successful. */
147 if (status != FX_MEDIA_NOT_OPEN)
148 {
149
150 printf("ERROR!\n");
151 test_control_return(52);
152 }
153
154 #ifndef FX_NO_LOCAL_PATH
155 /* Attempt to get copy of the directory local path before the media has been opened to generate an error */
156 status = _fx_directory_local_path_get_copy(&ram_disk, test_path_name_buffer, sizeof(test_path_name_buffer));
157
158 /* Determine if the test was successful. */
159 if (status != FX_MEDIA_NOT_OPEN)
160 {
161
162 printf("ERROR!\n");
163 test_control_return(53);
164 }
165 #endif /* FX_NO_LOCAL_PATH */
166
167 /* Open the ram_disk. */
168 status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, CACHE_SIZE);
169
170 /* Check the status. */
171 if (status != FX_SUCCESS)
172 {
173
174 /* Error, return error code. */
175 printf("ERROR!\n");
176 test_control_return(4);
177 }
178
179 /* Get the current path. This should be / or NULL. */
180 status = fx_directory_default_get(&ram_disk, &path_ptr);
181
182 /* Check the status. */
183 if ((status != FX_SUCCESS) || (path_ptr[0]))
184 {
185
186 /* Error getting the path. Return to caller. */
187 printf("ERROR!\n");
188 test_control_return(5);
189 }
190
191 temp = ram_disk.fx_media_id;
192 ram_disk.fx_media_id = 0;
193
194 /* Give a media pointer with bad data to cause an error */
195 status = fx_directory_default_get(&ram_disk, &path_ptr);
196
197 /* Check the status */
198 if (status != FX_MEDIA_NOT_OPEN)
199 {
200
201 /* Error opening the media */
202 printf("ERROR!\n");
203 test_control_return(6);
204 }
205
206 ram_disk.fx_media_id = temp;
207
208 #ifndef FX_DISABLE_ERROR_CHECKING
209 /* Give a bad ram pointer to cause an error */
210 status = fx_directory_default_get(NULL, &path_ptr);
211
212 /* Check the status. */
213 if (status != FX_PTR_ERROR)
214 {
215
216 /* Error getting the path. Return to caller. */
217 printf("ERROR!\n");
218 test_control_return(7);
219 }
220
221 /* Give a bad path pointer to cause an error */
222 status = fx_directory_default_get(&ram_disk, NULL);
223
224 /* Check the status. */
225 if (status != FX_PTR_ERROR)
226 {
227
228 /* Error getting the path. Return to caller. */
229 printf("ERROR!\n");
230 test_control_return(8);
231 }
232 #endif
233
234 /* Create a series of directories... */
235 status = fx_directory_create(&ram_disk, "/A0");
236 status += fx_directory_create(&ram_disk, "/B0");
237 status += fx_directory_create(&ram_disk, "/C0");
238 status += fx_directory_create(&ram_disk, "/D0");
239 status += fx_directory_create(&ram_disk, "/E0");
240 status += fx_directory_create(&ram_disk, "/F0");
241 status += fx_directory_create(&ram_disk, "/G0");
242 status += fx_directory_create(&ram_disk, "/H0");
243 status += fx_directory_create(&ram_disk, "/I0");
244 status += fx_file_create(&ram_disk, "NOT_A_DIR");
245
246 /* Check for errors... */
247 if (status != FX_SUCCESS)
248 {
249
250 /* Error creating directories. Return to caller. */
251 printf("ERROR!\n");
252 test_control_return(9);
253 }
254
255 /* Attempt to set the default directory to something that is not a directory to generate an error */
256 status = fx_directory_default_set(&ram_disk, "NOT_A_DIR");
257 if (status != FX_INVALID_PATH)
258 {
259 printf("ERROR!\n");
260 test_control_return(10);
261 }
262 status = fx_file_delete(&ram_disk, "NOT_A_DIR");
263 if (status != FX_SUCCESS)
264 {
265 printf("ERROR!\n");
266 test_control_return(11);
267 }
268
269 /* Attempt to create the same directory again. */
270 status = fx_directory_create(&ram_disk, "/A0");
271
272 /* Check for errors... */
273 if (status != FX_ALREADY_CREATED)
274 {
275
276 /* Error creating same directory twice. Return to caller. */
277 printf("ERROR!\n");
278 test_control_return(12);
279 }
280
281 /* Only run this if error checking is enabled */
282 #ifndef FX_DISABLE_ERROR_CHECKING
283 /* send null pointer to default directory set to generate an error */
284 status = fx_directory_default_set(FX_NULL, "/A0");
285 if (status != FX_PTR_ERROR)
286 {
287 printf("ERROR!\n");
288 test_control_return(13);
289 }
290 #endif /* FX_DISABLE_ERROR_CHECKING */
291
292 /* Create the next level of sub-directories. */
293 status = fx_directory_default_set(&ram_disk, "/A0");
294 status += fx_directory_create(&ram_disk, "A1");
295 status += fx_directory_create(&ram_disk, "A2");
296 status += fx_directory_create(&ram_disk, "A3");
297 status += fx_directory_create(&ram_disk, "A4");
298 status += fx_directory_create(&ram_disk, "A5");
299 status += fx_directory_default_get(&ram_disk, &path_ptr);
300
301
302 status += fx_directory_default_set(&ram_disk, "/B0");
303 status += fx_directory_create(&ram_disk, "B1");
304 status += fx_directory_create(&ram_disk, "B2");
305 status += fx_directory_create(&ram_disk, "B3");
306 status += fx_directory_create(&ram_disk, "B4");
307 status += fx_directory_create(&ram_disk, "B5");
308 status += fx_directory_default_get(&ram_disk, &path_ptr);
309
310 status += fx_directory_default_set(&ram_disk, "/C0");
311 status += fx_directory_create(&ram_disk, "C1");
312 status += fx_directory_create(&ram_disk, "C2");
313 status += fx_directory_create(&ram_disk, "C3");
314 status += fx_directory_create(&ram_disk, "C4");
315 status += fx_directory_create(&ram_disk, "C5");
316 status += fx_directory_default_get(&ram_disk, &path_ptr);
317
318 status += fx_directory_default_set(&ram_disk, "/D0");
319 status += fx_directory_create(&ram_disk, "D1");
320 status += fx_directory_create(&ram_disk, "D2");
321 status += fx_directory_create(&ram_disk, "D3");
322 status += fx_directory_create(&ram_disk, "D4");
323 status += fx_directory_create(&ram_disk, "D5");
324 status += fx_directory_default_get(&ram_disk, &path_ptr);
325
326 status += fx_directory_default_set(&ram_disk, "/E0");
327 status += fx_directory_create(&ram_disk, "E1");
328 status += fx_directory_create(&ram_disk, "E2");
329 status += fx_directory_create(&ram_disk, "E3");
330 status += fx_directory_create(&ram_disk, "E4");
331 status += fx_directory_create(&ram_disk, "E5");
332 status += fx_directory_default_get(&ram_disk, &path_ptr);
333
334 status += fx_directory_default_set(&ram_disk, "/F0");
335 status += fx_directory_create(&ram_disk, "F1");
336 status += fx_directory_create(&ram_disk, "F2");
337 status += fx_directory_create(&ram_disk, "F3");
338 status += fx_directory_create(&ram_disk, "F4");
339 status += fx_directory_create(&ram_disk, "F5");
340 status += fx_directory_default_get(&ram_disk, &path_ptr);
341
342 status += fx_directory_default_set(&ram_disk, "/G0");
343 status += fx_directory_create(&ram_disk, "G1");
344 status += fx_directory_create(&ram_disk, "G2");
345 status += fx_directory_create(&ram_disk, "G3");
346 status += fx_directory_create(&ram_disk, "G4");
347 status += fx_directory_create(&ram_disk, "G5");
348 status += fx_directory_default_get(&ram_disk, &path_ptr);
349
350 status += fx_directory_default_set(&ram_disk, "/H0");
351 status += fx_directory_create(&ram_disk, "H1");
352 status += fx_directory_create(&ram_disk, "H2");
353 status += fx_directory_create(&ram_disk, "H3");
354 status += fx_directory_create(&ram_disk, "H4");
355 status += fx_directory_create(&ram_disk, "H5");
356 status += fx_directory_default_get(&ram_disk, &path_ptr);
357
358 status += fx_directory_default_set(&ram_disk, "/I0");
359 status += fx_directory_create(&ram_disk, "I1");
360 status += fx_directory_create(&ram_disk, "I2");
361 status += fx_directory_create(&ram_disk, "I3");
362 status += fx_directory_create(&ram_disk, "I4");
363 status += fx_directory_create(&ram_disk, "I5");
364 status += fx_directory_default_get(&ram_disk, &path_ptr);
365 status += fx_directory_default_get_copy(&ram_disk, path_name_buffer, sizeof(path_name_buffer));
366
367 /* Check for errors... */
368 if (status != FX_SUCCESS)
369 {
370
371 /* Error creating sub-directories. Return to caller. */
372 printf("ERROR!\n");
373 test_control_return(14);
374 }
375
376 if (strcmp(path_name_buffer, "/I0"))
377 {
378 printf("ERROR!\n");
379 test_control_return(233);
380 }
381
382 /* Now create the third level of sub-directories... */
383
384 #ifndef FX_NO_LOCAL_PATH
385 /* create these with a local path defined in threadx */
386 status = fx_directory_local_path_set(&ram_disk, &local_path, "/A0");
387 status += fx_directory_default_set(&ram_disk, "/A0");
388 status += fx_directory_create(&ram_disk, "test");
389 status += fx_directory_delete(&ram_disk, "test");
390 status += fx_directory_default_set(&ram_disk, "A1");
391 status += fx_directory_create(&ram_disk, "test");
392 status += fx_directory_delete(&ram_disk, "test");
393 status += fx_directory_local_path_clear(&ram_disk);
394
395 /* Check for errors... */
396 if (status != FX_SUCCESS)
397 {
398
399 /* Error creating sub-sub-directories. Return to caller. */
400 printf("ERROR!\n");
401 test_control_return(15);
402 }
403 #endif
404
405 /* create the rest as normal */
406 status = fx_directory_default_set(&ram_disk, "/A0/A1");
407 status += fx_directory_create(&ram_disk, "A00");
408 status += fx_directory_default_set(&ram_disk, "/B0");
409 status += fx_directory_create(&ram_disk, "B2/B00");
410 status += fx_directory_create(&ram_disk, "/C0/C3/C00");
411 status += fx_directory_default_set(&ram_disk, "/D0/D4");
412 status += fx_directory_create(&ram_disk, "D00");
413 status += fx_directory_default_set(&ram_disk, "/E0");
414 status += fx_directory_create(&ram_disk, "E5/E00");
415 status += fx_directory_create(&ram_disk, "/F0/F1/F00");
416 status += fx_directory_default_set(&ram_disk, "/G0/G1");
417 status += fx_directory_create(&ram_disk, "G00");
418 status += fx_directory_default_set(&ram_disk, "/H0");
419 status += fx_directory_create(&ram_disk, "H2/H00");
420 status += fx_directory_create(&ram_disk, "/I0/I3/I00");
421 status += fx_directory_default_get(&ram_disk, &path_ptr);
422
423 /* Check for errors... */
424 if (status != FX_SUCCESS)
425 {
426
427 /* Error creating sub-sub-directories. Return to caller. */
428 printf("ERROR!\n");
429 test_control_return(16);
430 }
431
432 /* Now delete all the directories. */
433 status = fx_directory_delete(&ram_disk, "/A0/A1/A00");
434 status += fx_directory_delete(&ram_disk, "/B0/B2/B00");
435 status += fx_directory_delete(&ram_disk, "/C0/C3/C00");
436 status += fx_directory_delete(&ram_disk, "/D0/D4/D00");
437 status += fx_directory_delete(&ram_disk, "/E0/E5/E00");
438 status += fx_directory_delete(&ram_disk, "/F0/F1/F00");
439 status += fx_directory_delete(&ram_disk, "/G0/G1/G00");
440 status += fx_directory_delete(&ram_disk, "/H0/H2/H00");
441 status += fx_directory_delete(&ram_disk, "/I0/I3/I00");
442
443 /* Check for errors... */
444 if (status != FX_SUCCESS)
445 {
446
447 /* Error deleting sub-sub-directories. Return to caller. */
448 printf("ERROR!\n");
449 test_control_return(17);
450 }
451
452 /* Delete the next level of sub-directories. */
453 status += fx_directory_delete(&ram_disk, "/A0/A1");
454 status += fx_directory_delete(&ram_disk, "/A0/A2");
455 status += fx_directory_delete(&ram_disk, "/A0/A3");
456 status += fx_directory_delete(&ram_disk, "/A0/A4");
457 status += fx_directory_delete(&ram_disk, "/A0/A5");
458
459 status += fx_directory_delete(&ram_disk, "/B0/B1");
460 status += fx_directory_delete(&ram_disk, "/B0/B2");
461 status += fx_directory_delete(&ram_disk, "/B0/B3");
462 status += fx_directory_delete(&ram_disk, "/B0/B4");
463 status += fx_directory_delete(&ram_disk, "/B0/B5");
464
465 status += fx_directory_delete(&ram_disk, "/C0/C1");
466 status += fx_directory_delete(&ram_disk, "/C0/C2");
467 status += fx_directory_delete(&ram_disk, "/C0/C3");
468 status += fx_directory_delete(&ram_disk, "/C0/C4");
469 status += fx_directory_delete(&ram_disk, "/C0/C5");
470
471 status += fx_directory_delete(&ram_disk, "/D0/D1");
472 status += fx_directory_delete(&ram_disk, "/D0/D2");
473 status += fx_directory_delete(&ram_disk, "/D0/D3");
474 status += fx_directory_delete(&ram_disk, "/D0/D4");
475 status += fx_directory_delete(&ram_disk, "/D0/D5");
476
477 status += fx_directory_delete(&ram_disk, "/E0/E1");
478 status += fx_directory_delete(&ram_disk, "/E0/E2");
479 status += fx_directory_delete(&ram_disk, "/E0/E3");
480 status += fx_directory_delete(&ram_disk, "/E0/E4");
481 status += fx_directory_delete(&ram_disk, "/E0/E5");
482
483 status += fx_directory_delete(&ram_disk, "/F0/F1");
484 status += fx_directory_delete(&ram_disk, "/F0/F2");
485 status += fx_directory_delete(&ram_disk, "/F0/F3");
486 status += fx_directory_delete(&ram_disk, "/F0/F4");
487 status += fx_directory_delete(&ram_disk, "/F0/F5");
488
489 status += fx_directory_delete(&ram_disk, "/G0/G1");
490 status += fx_directory_delete(&ram_disk, "/G0/G2");
491 status += fx_directory_delete(&ram_disk, "/G0/G3");
492 status += fx_directory_delete(&ram_disk, "/G0/G4");
493 status += fx_directory_delete(&ram_disk, "/G0/G5");
494
495 status += fx_directory_delete(&ram_disk, "/H0/H1");
496 status += fx_directory_delete(&ram_disk, "/H0/H2");
497 status += fx_directory_delete(&ram_disk, "/H0/H3");
498 status += fx_directory_delete(&ram_disk, "/H0/H4");
499 status += fx_directory_delete(&ram_disk, "/H0/H5");
500
501 status += fx_directory_delete(&ram_disk, "/I0/I1");
502 status += fx_directory_delete(&ram_disk, "/I0/I2");
503 status += fx_directory_delete(&ram_disk, "/I0/I3");
504 status += fx_directory_delete(&ram_disk, "/I0/I4");
505 status += fx_directory_delete(&ram_disk, "/I0/I5");
506
507 /* Check for errors... */
508 if (status != FX_SUCCESS)
509 {
510
511 /* Error deleting sub-directories. Return to caller. */
512 printf("ERROR!\n");
513 test_control_return(18);
514 }
515
516 /* Delete a series of directories... */
517 status = fx_directory_delete(&ram_disk, "/A0");
518 status += fx_directory_delete(&ram_disk, "/B0");
519 status += fx_directory_delete(&ram_disk, "/C0");
520 status += fx_directory_delete(&ram_disk, "/D0");
521 status += fx_directory_delete(&ram_disk, "/E0");
522 status += fx_directory_delete(&ram_disk, "/F0");
523 status += fx_directory_delete(&ram_disk, "/G0");
524 status += fx_directory_delete(&ram_disk, "/H0");
525 status += fx_directory_delete(&ram_disk, "/I0");
526
527 /* Check for errors... */
528 if (status != FX_SUCCESS)
529 {
530
531 /* Error deleting directories. Return to caller. */
532 printf("ERROR!\n");
533 test_control_return(19);
534 }
535
536 /* Attempt to delete a directory again. */
537 status = fx_directory_delete(&ram_disk, "/A0");
538
539 /* This should be an error. */
540 if (status != FX_NOT_FOUND)
541 {
542
543 /* Error deleting same directory twice. Return to caller. */
544 printf("ERROR!\n");
545 test_control_return(20);
546 }
547
548 /* Close the media. */
549 status = fx_media_close(&ram_disk);
550
551 /* Determine if the test was successful. */
552 if (status != FX_SUCCESS)
553 {
554
555 printf("ERROR!\n");
556 test_control_return(21);
557 }
558
559
560 /* Format the media. This needs to be done before opening it! */
561 status = fx_media_format(&ram_disk,
562 _fx_ram_driver, // Driver entry
563 ram_disk_memory, // RAM disk memory pointer
564 cache_buffer, // Media buffer pointer
565 CACHE_SIZE, // Media buffer size
566 "MY_RAM_DISK", // Volume Name
567 1, // Number of FATs
568 32, // Directory Entries
569 0, // Hidden sectors
570 4096, // Total sectors
571 128, // Sector size
572 1, // Sectors per cluster
573 1, // Heads
574 1); // Sectors per track
575
576 /* Determine if the format had an error. */
577 if (status)
578 {
579
580 printf("ERROR!\n");
581 test_control_return(22);
582 }
583
584 /* Open the ram_disk - with one logical sector cache! */
585 status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
586
587 /* Check the status. */
588 if (status != FX_SUCCESS)
589 {
590
591 /* Error, return error code. */
592 printf("ERROR!\n");
593 test_control_return(23);
594 }
595
596 /* Create a sub-directory. */
597 status = fx_directory_create(&ram_disk, "sub-directory-level_001");
598
599 /* Attempt to set a path with a NULL path name. */
600 status += _fx_directory_default_set(&ram_disk, FX_NULL);
601
602 /* Check the status. */
603 if (status != FX_SUCCESS)
604 {
605
606 /* Error, return error code. */
607 printf("ERROR!\n");
608 test_control_return(24);
609 }
610
611 /* Flush and invalidate the caches. */
612 fx_media_flush(&ram_disk);
613 _fx_utility_FAT_flush(&ram_disk);
614 _fx_utility_logical_sector_flush(&ram_disk, 1, 60000, FX_TRUE);
615 for (i = 0; i < FX_MAX_FAT_CACHE; i++)
616 {
617 ram_disk.fx_media_fat_cache[i].fx_fat_cache_entry_cluster = 0;
618 ram_disk.fx_media_fat_cache[i].fx_fat_cache_entry_value = 0;
619 }
620
621 /* Try to set the current path but with an I/O error coming from the directory search. */
622 _fx_utility_logical_sector_read_error_request = 1;
623 status = fx_directory_default_set(&ram_disk, "sub-directory-level_001");
624 _fx_utility_logical_sector_read_error_request = 0;
625
626 /* Check the status - should be an I/O error! */
627 if (status != FX_INVALID_PATH)
628 {
629
630 /* Error, return error code. */
631 printf("ERROR!\n");
632 test_control_return(25);
633 }
634
635 /* Try to set the current path to the first sub-directory. */
636 status = fx_directory_default_set(&ram_disk, "sub-directory-level_001");
637
638 /* Check the status. */
639 if (status != FX_SUCCESS)
640 {
641
642 /* Error, return error code. */
643 printf("ERROR!\n");
644 test_control_return(26);
645 }
646
647 /* Try to set the current path to the same relative sub-directory. */
648 status = fx_directory_default_set(&ram_disk, ".");
649
650 /* Check the status. */
651 if (status != FX_SUCCESS)
652 {
653
654 /* Error, return error code. */
655 printf("ERROR!\n");
656 test_control_return(27);
657 }
658
659 /* Try to set the current path back to root directory relative to the current directory. */
660 status = fx_directory_default_set(&ram_disk, "..");
661
662 /* Check the status. */
663 if (status != FX_SUCCESS)
664 {
665
666 /* Error, return error code. */
667 printf("ERROR!\n");
668 test_control_return(28);
669 }
670
671 /* Create a set of sub-directories that exceeds the maximum path size. */
672 status = fx_directory_default_set(&ram_disk, "sub-directory-level_001");
673 status += fx_directory_create(&ram_disk, "sub-directory-level_002");
674 status += fx_directory_default_set(&ram_disk, "sub-directory-level_002");
675 status += fx_directory_create(&ram_disk, "sub-directory-level_003");
676 status += fx_directory_default_set(&ram_disk, "sub-directory-level_003");
677 status += fx_directory_create(&ram_disk, "sub-directory-level_004");
678 status += fx_directory_default_set(&ram_disk, "sub-directory-level_004");
679 status += fx_directory_create(&ram_disk, "sub-directory-level_005");
680 status += fx_directory_default_set(&ram_disk, "sub-directory-level_005");
681 status += fx_directory_create(&ram_disk, "sub-directory-level_006");
682 status += fx_directory_default_set(&ram_disk, "sub-directory-level_006");
683 status += fx_directory_create(&ram_disk, "sub-directory-level_007");
684 status += fx_directory_default_set(&ram_disk, "sub-directory-level_007");
685 status += fx_directory_create(&ram_disk, "sub-directory-level_008");
686 status += fx_directory_default_set(&ram_disk, "sub-directory-level_008");
687 status += fx_directory_create(&ram_disk, "sub-directory-level_009");
688 status += fx_directory_default_set(&ram_disk, "sub-directory-level_009");
689 status += fx_directory_create(&ram_disk, "sub-directory-level_010");
690 status += fx_directory_default_set(&ram_disk, "sub-directory-level_010");
691 status += fx_directory_create(&ram_disk, "sub-directory-level_011");
692 status += fx_directory_default_set(&ram_disk, "sub-directory-level_011");
693 status += fx_directory_create(&ram_disk, "sub-directory-level_012");
694 status += fx_directory_default_set(&ram_disk, "sub-directory-level_012");
695 status += fx_directory_create(&ram_disk, "sub-directory-level_013");
696 status += fx_directory_default_set(&ram_disk, "sub-directory-level_013");
697 status += fx_directory_create(&ram_disk, "sub-directory-level_014");
698 status += fx_directory_default_set(&ram_disk, "sub-directory-level_014");
699 status += fx_directory_create(&ram_disk, "sub-directory-level_015");
700 status += fx_directory_default_set(&ram_disk, "sub-directory-level_015");
701
702 /* Now backup to the root directory. */
703 status += fx_directory_default_set(&ram_disk, "../../../../../../../../../../../../../../..");
704 status += fx_directory_first_entry_find(&ram_disk, name);
705
706 /* Check the status. */
707 if (status != FX_SUCCESS)
708 {
709
710 /* Error, return error code. */
711 printf("ERROR!\n");
712 test_control_return(29);
713 }
714
715 /* Move back to a maximum path situation. */
716 status = fx_directory_default_set(&ram_disk, "sub-directory-level_001");
717 status += fx_directory_default_set(&ram_disk, "sub-directory-level_002");
718 status += fx_directory_default_set(&ram_disk, "sub-directory-level_003");
719 status += fx_directory_default_set(&ram_disk, "sub-directory-level_004");
720 status += fx_directory_default_set(&ram_disk, "sub-directory-level_005");
721 status += fx_directory_default_set(&ram_disk, "sub-directory-level_006");
722 status += fx_directory_default_set(&ram_disk, "sub-directory-level_007");
723 status += fx_directory_default_set(&ram_disk, "sub-directory-level_008");
724 status += fx_directory_default_set(&ram_disk, "sub-directory-level_009");
725 status += fx_directory_default_set(&ram_disk, "sub-directory-level_010");
726 status += fx_directory_default_set(&ram_disk, "sub-directory-level_011");
727 status += fx_directory_default_set(&ram_disk, "sub-directory-level_012");
728 status += fx_directory_default_set(&ram_disk, "sub-directory-level_013");
729 status += fx_directory_default_set(&ram_disk, "sub-directory-level_014");
730 status += fx_directory_default_set(&ram_disk, "sub-directory-level_015");
731
732 /* Now backup to the root directory - one sub-directory at a time. */
733 status += fx_directory_default_set(&ram_disk, "..");
734 status += fx_directory_default_set(&ram_disk, "..");
735 status += fx_directory_default_set(&ram_disk, "..");
736 status += fx_directory_default_set(&ram_disk, "..");
737 status += fx_directory_default_set(&ram_disk, "..");
738 status += fx_directory_default_set(&ram_disk, "..");
739 status += fx_directory_default_set(&ram_disk, "..");
740 status += fx_directory_default_set(&ram_disk, "..");
741 status += fx_directory_default_set(&ram_disk, "..");
742 status += fx_directory_default_set(&ram_disk, "..");
743 status += fx_directory_default_set(&ram_disk, "..");
744 status += fx_directory_default_set(&ram_disk, "..");
745 status += fx_directory_default_set(&ram_disk, "..");
746 status += fx_directory_default_set(&ram_disk, "..");
747 status += fx_directory_default_set(&ram_disk, "..");
748
749 /* Check the status. */
750 if (status != FX_SUCCESS)
751 {
752
753 /* Error, return error code. */
754 printf("ERROR!\n");
755 test_control_return(30);
756 }
757
758 /* Move back to a maximum path situation. */
759 status = fx_directory_default_set(&ram_disk, "sub-directory-level_001");
760 status += fx_directory_default_set(&ram_disk, "sub-directory-level_002");
761 status += fx_directory_default_set(&ram_disk, "sub-directory-level_003");
762 status += fx_directory_default_set(&ram_disk, "sub-directory-level_004");
763 status += fx_directory_default_set(&ram_disk, "sub-directory-level_005");
764 status += fx_directory_default_set(&ram_disk, "sub-directory-level_006");
765 status += fx_directory_default_set(&ram_disk, "sub-directory-level_007");
766 status += fx_directory_default_set(&ram_disk, "sub-directory-level_008");
767 status += fx_directory_default_set(&ram_disk, "sub-directory-level_009");
768 status += fx_directory_default_set(&ram_disk, "sub-directory-level_010");
769 status += fx_directory_default_set(&ram_disk, "sub-directory-level_011");
770 status += fx_directory_default_set(&ram_disk, "sub-directory-level_012");
771 status += fx_directory_default_set(&ram_disk, "sub-directory-level_013");
772 status += fx_directory_default_set(&ram_disk, "sub-directory-level_014");
773 status += fx_directory_default_set(&ram_disk, "sub-directory-level_015");
774
775 /* Now backup to the root directory - one sub-directory at a time. */
776 status += fx_directory_default_set(&ram_disk, "..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..");
777
778 /* Check the status. */
779 if (status != FX_SUCCESS)
780 {
781
782 /* Error, return error code. */
783 printf("ERROR!\n");
784 test_control_return(31);
785 }
786
787 /* Move to an exact fit of the 256 path size situation. */
788 status = fx_directory_default_set(&ram_disk, "sub-directory-level_001");
789 status += fx_directory_default_set(&ram_disk, "sub-directory-level_002");
790 status += fx_directory_default_set(&ram_disk, "sub-directory-level_003");
791 status += fx_directory_default_set(&ram_disk, "sub-directory-level_004");
792 status += fx_directory_default_set(&ram_disk, "sub-directory-level_005");
793 status += fx_directory_default_set(&ram_disk, "sub-directory-level_006");
794 status += fx_directory_default_set(&ram_disk, "sub-directory-level_007");
795 status += fx_directory_default_set(&ram_disk, "sub-directory-level_008");
796 status += fx_directory_default_set(&ram_disk, "sub-directory-level_009");
797 status += fx_directory_default_set(&ram_disk, "sub-directory-level_010");
798 status += fx_directory_create(&ram_disk, "perfect_fit_dr");
799 status += fx_directory_default_set(&ram_disk, "perfect_fit_dr");
800 status += fx_directory_create(&ram_disk, "perfect_fit_subdir");
801 status += fx_directory_default_set(&ram_disk, "perfect_fit_subdir");
802
803 /* Now backup to the root directory - one sub-directory at a time. */
804 status += fx_directory_default_set(&ram_disk, "..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..");
805 status += fx_directory_first_entry_find(&ram_disk, name);
806 status += fx_directory_first_entry_find(&ram_disk, name);
807 status += fx_directory_first_entry_find(&ram_disk, name);
808
809 /* Check the status. */
810 if (status != FX_SUCCESS)
811 {
812
813 /* Error, return error code. */
814 printf("ERROR!\n");
815 test_control_return(32);
816 }
817
818 /* Now try to have a new path relative back to the root directory, and then back to itself. */
819 status = fx_directory_default_set(&ram_disk, "sub-directory-level_001");
820
821 /* Update the directory symbol at the root of the path string. */
822 ram_disk.fx_media_default_path.fx_path_string[0] = '/';
823 status += fx_directory_default_set(&ram_disk, "../sub-directory-level_001");
824
825 /* Update the directory symbol at the root of the path string to cause a maximum path condition. */
826 ram_disk.fx_media_default_path.fx_path_string[0] = ' ';
827 status += fx_directory_default_set(&ram_disk, "../sub-directory-level_001");
828
829 status += fx_directory_default_set(&ram_disk, "..");
830 status += fx_directory_first_entry_find(&ram_disk, name);
831
832 /* Check the status. */
833 if (status != FX_SUCCESS)
834 {
835
836 /* Error, return error code. */
837 printf("ERROR!\n");
838 test_control_return(33);
839 }
840
841 /* Test to return FX_BUFFER_ERROR from _fx_directory_default_get_copy() */
842 status = fx_directory_default_get_copy(&ram_disk, test_path_name_buffer, sizeof(test_path_name_buffer));
843
844 /* Determine if the test was successful. */
845 if (status != FX_BUFFER_ERROR)
846 {
847
848 printf("ERROR!\n");
849 test_control_return(52);
850 }
851
852 /* Close the media. */
853 status = fx_media_close(&ram_disk);
854
855 /* Determine if the test was successful. */
856 if (status != FX_SUCCESS)
857 {
858
859 printf("ERROR!\n");
860 test_control_return(34);
861 }
862
863 /* Now perform the same corner case testing with the local path set. */
864
865 /* Format the media. This needs to be done before opening it! */
866 status = fx_media_format(&ram_disk,
867 _fx_ram_driver, // Driver entry
868 ram_disk_memory, // RAM disk memory pointer
869 cache_buffer, // Media buffer pointer
870 CACHE_SIZE, // Media buffer size
871 "MY_RAM_DISK", // Volume Name
872 1, // Number of FATs
873 32, // Directory Entries
874 0, // Hidden sectors
875 4096, // Total sectors
876 128, // Sector size
877 1, // Sectors per cluster
878 1, // Heads
879 1); // Sectors per track
880
881 /* Determine if the format had an error. */
882 if (status)
883 {
884
885 printf("ERROR!\n");
886 test_control_return(22);
887 }
888
889 /* Open the ram_disk - with one logical sector cache! */
890 status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
891
892 /* Check the status. */
893 if (status != FX_SUCCESS)
894 {
895
896 /* Error, return error code. */
897 printf("ERROR!\n");
898 test_control_return(35);
899 }
900
901 /* Create a sub-directory. */
902 status = fx_directory_create(&ram_disk, "sub-directory-level_001");
903
904 /* Skip local_path test */
905 #ifndef FX_NO_LOCAL_PATH
906 /* Attempt to set a path with a NULL path name. */
907 status += _fx_directory_local_path_set(&ram_disk, &local_path, FX_NULL);
908
909 /* Check the status. */
910 if (status != FX_SUCCESS)
911 {
912
913 /* Error, return error code. */
914 printf("ERROR!\n");
915 test_control_return(36);
916 }
917
918 /* Flush and invalidate the caches. */
919 fx_media_flush(&ram_disk);
920 _fx_utility_FAT_flush(&ram_disk);
921 _fx_utility_logical_sector_flush(&ram_disk, 1, 60000, FX_TRUE);
922 for (i = 0; i < FX_MAX_FAT_CACHE; i++)
923 {
924 ram_disk.fx_media_fat_cache[i].fx_fat_cache_entry_cluster = 0;
925 ram_disk.fx_media_fat_cache[i].fx_fat_cache_entry_value = 0;
926 }
927
928 /* Try to set the current path but with an I/O error coming from the directory search. */
929 _fx_utility_logical_sector_read_error_request = 1;
930 status = fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_001");
931 _fx_utility_logical_sector_read_error_request = 0;
932
933 /* Check the status - should be an I/O error! */
934 if (status != FX_INVALID_PATH)
935 {
936
937 /* Error, return error code. */
938 printf("ERROR!\n");
939 test_control_return(37);
940 }
941
942 /* Try to set the current path to the first sub-directory. */
943 status = fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_001");
944
945 /* Check the status. */
946 if (status != FX_SUCCESS)
947 {
948
949 /* Error, return error code. */
950 printf("ERROR!\n");
951 test_control_return(38);
952 }
953
954 /* Try to set the current path to the same relative sub-directory. */
955 status = fx_directory_local_path_set(&ram_disk, &local_path, ".");
956
957 /* Check the status. */
958 if (status != FX_SUCCESS)
959 {
960
961 /* Error, return error code. */
962 printf("ERROR!\n");
963 test_control_return(39);
964 }
965
966 /* Try to set the current path back to root directory relative to the current directory. */
967 status = fx_directory_local_path_set(&ram_disk, &local_path, "..");
968
969 /* Check the status. */
970 if (status != FX_SUCCESS)
971 {
972
973 /* Error, return error code. */
974 printf("ERROR!\n");
975 test_control_return(40);
976 }
977
978 /* Create a set of sub-directories that exceeds the maximum path size. */
979 status = fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_001");
980 status += fx_directory_create(&ram_disk, "sub-directory-level_002");
981 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_002");
982 status += fx_directory_create(&ram_disk, "sub-directory-level_003");
983 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_003");
984 status += fx_directory_create(&ram_disk, "sub-directory-level_004");
985 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_004");
986 status += fx_directory_create(&ram_disk, "sub-directory-level_005");
987 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_005");
988 status += fx_directory_create(&ram_disk, "sub-directory-level_006");
989 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_006");
990 status += fx_directory_create(&ram_disk, "sub-directory-level_007");
991 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_007");
992 status += fx_directory_create(&ram_disk, "sub-directory-level_008");
993 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_008");
994 status += fx_directory_create(&ram_disk, "sub-directory-level_009");
995 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_009");
996 status += fx_directory_create(&ram_disk, "sub-directory-level_010");
997 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_010");
998 status += fx_directory_create(&ram_disk, "sub-directory-level_011");
999 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_011");
1000 status += fx_directory_create(&ram_disk, "sub-directory-level_012");
1001 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_012");
1002 status += fx_directory_create(&ram_disk, "sub-directory-level_013");
1003 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_013");
1004 status += fx_directory_create(&ram_disk, "sub-directory-level_014");
1005 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_014");
1006 status += fx_directory_create(&ram_disk, "sub-directory-level_015");
1007 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_015");
1008
1009 /* Now backup to the root directory. */
1010 status += fx_directory_local_path_set(&ram_disk, &local_path, "../../../../../../../../../../../../../../..");
1011 status += fx_directory_first_entry_find(&ram_disk, name);
1012
1013 /* Check the status. */
1014 if (status != FX_SUCCESS)
1015 {
1016
1017 /* Error, return error code. */
1018 printf("ERROR!\n");
1019 test_control_return(41);
1020 }
1021
1022 /* Move back to a maximum path situation. */
1023 status = fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_001");
1024 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_002");
1025 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_003");
1026 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_004");
1027 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_005");
1028 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_006");
1029 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_007");
1030 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_008");
1031 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_009");
1032 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_010");
1033 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_011");
1034 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_012");
1035 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_013");
1036 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_014");
1037 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_015");
1038
1039 /* Now backup to the root directory - one sub-directory at a time. */
1040 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1041 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1042 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1043 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1044 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1045 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1046 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1047 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1048 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1049 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1050 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1051 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1052 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1053 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1054 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1055
1056 /* Check the status. */
1057 if (status != FX_SUCCESS)
1058 {
1059
1060 /* Error, return error code. */
1061 printf("ERROR!\n");
1062 test_control_return(42);
1063 }
1064
1065 /* Move back to a maximum path situation. */
1066 status = fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_001");
1067 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_002");
1068 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_003");
1069 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_004");
1070 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_005");
1071 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_006");
1072 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_007");
1073 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_008");
1074 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_009");
1075 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_010");
1076 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_011");
1077 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_012");
1078 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_013");
1079 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_014");
1080 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_015");
1081
1082 /* Now backup to the root directory - one sub-directory at a time. */
1083 status += fx_directory_local_path_set(&ram_disk, &local_path, "..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..");
1084
1085 /* Check the status. */
1086 if (status != FX_SUCCESS)
1087 {
1088
1089 /* Error, return error code. */
1090 printf("ERROR!\n");
1091 test_control_return(43);
1092 }
1093
1094 /* Move to an exact fit of the 256 path size situation. */
1095 status = fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_001");
1096 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_002");
1097 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_003");
1098 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_004");
1099 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_005");
1100 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_006");
1101 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_007");
1102 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_008");
1103 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_009");
1104 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_010");
1105 status += fx_directory_create(&ram_disk, "perfect_fit_dr");
1106 status += fx_directory_local_path_set(&ram_disk, &local_path, "perfect_fit_dr");
1107 status += fx_directory_create(&ram_disk, "perfect_fit_subdir");
1108 status += fx_directory_local_path_set(&ram_disk, &local_path, "perfect_fit_subdir");
1109
1110 /* Now backup to the root directory - one sub-directory at a time. */
1111 status += fx_directory_local_path_set(&ram_disk, &local_path, "..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..");
1112 status += fx_directory_first_entry_find(&ram_disk, name);
1113 status += fx_directory_first_entry_find(&ram_disk, name);
1114 status += fx_directory_first_entry_find(&ram_disk, name);
1115
1116 /* Check the status. */
1117 if (status != FX_SUCCESS)
1118 {
1119
1120 /* Error, return error code. */
1121 printf("ERROR!\n");
1122 test_control_return(44);
1123 }
1124
1125 /* Now try to have a new path relative back to the root directory, and then back to itself. */
1126 status = fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_001");
1127
1128 /* Update the directory symbol at the root of the path string. */
1129 local_path.fx_path_string[0] = '/';
1130 status += fx_directory_local_path_set(&ram_disk, &local_path, "../sub-directory-level_001");
1131
1132 /* Update the directory symbol at the root of the path string to cause a maximum path condition. */
1133 local_path.fx_path_string[0] = ' ';
1134 status += fx_directory_local_path_set(&ram_disk, &local_path, "../sub-directory-level_001");
1135
1136 status += fx_directory_local_path_set(&ram_disk, &local_path, "..");
1137 status += fx_directory_first_entry_find(&ram_disk, name);
1138
1139 /* Check the status. */
1140 if (status != FX_SUCCESS)
1141 {
1142
1143 /* Error, return error code. */
1144 printf("ERROR!\n");
1145 test_control_return(45);
1146 }
1147
1148 /* Create a file at the root directory. */
1149 status += fx_file_create(&ram_disk, "TEST.TXT");
1150
1151 /* Attempt to set the default to a file name. */
1152 status += fx_directory_local_path_set(&ram_disk, &local_path, "TEST.TXT");
1153
1154 /* Check the status. */
1155 if (status != FX_INVALID_PATH)
1156 {
1157
1158 /* Error, return error code. */
1159 printf("ERROR!\n");
1160 test_control_return(46);
1161 }
1162
1163 /* Build a maximum local path. */
1164 status = fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_001");
1165 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_002");
1166 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_003");
1167 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_004");
1168 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_005");
1169 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_006");
1170 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_007");
1171 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_008");
1172 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_009");
1173 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_010");
1174 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_011");
1175 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_012");
1176 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_013");
1177 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_014");
1178 status += fx_directory_local_path_set(&ram_disk, &local_path, "sub-directory-level_015");
1179
1180 /* Now set a new local path that will inherit this local path. */
1181 status += fx_directory_local_path_set(&ram_disk, &local_path1, "..\\sub-directory-level_015");
1182
1183 /* Now set an absolute path. */
1184 status += fx_directory_local_path_set(&ram_disk, &local_path1, "\\sub-directory-level_001");
1185 status += fx_directory_local_path_set(&ram_disk, &local_path1, "..");
1186
1187 /* Check the status. */
1188 if (status != FX_SUCCESS)
1189 {
1190
1191 /* Error, return error code. */
1192 printf("ERROR!\n");
1193 test_control_return(47);
1194 }
1195
1196 /* Clear the local path. */
1197 status += fx_directory_local_path_clear(&ram_disk);
1198
1199 /* Build a maximum path default (global) path. */
1200 status = fx_directory_default_set(&ram_disk, "\\");
1201 status += fx_directory_default_set(&ram_disk, "sub-directory-level_001");
1202 status += fx_directory_default_set(&ram_disk, "sub-directory-level_002");
1203 status += fx_directory_default_set(&ram_disk, "sub-directory-level_003");
1204 status += fx_directory_default_set(&ram_disk, "sub-directory-level_004");
1205 status += fx_directory_default_set(&ram_disk, "sub-directory-level_005");
1206 status += fx_directory_default_set(&ram_disk, "sub-directory-level_006");
1207 status += fx_directory_default_set(&ram_disk, "sub-directory-level_007");
1208 status += fx_directory_default_set(&ram_disk, "sub-directory-level_008");
1209 status += fx_directory_default_set(&ram_disk, "sub-directory-level_009");
1210 status += fx_directory_default_set(&ram_disk, "sub-directory-level_010");
1211 status += fx_directory_default_set(&ram_disk, "sub-directory-level_011");
1212 status += fx_directory_default_set(&ram_disk, "sub-directory-level_012");
1213 status += fx_directory_default_set(&ram_disk, "sub-directory-level_013");
1214 status += fx_directory_default_set(&ram_disk, "sub-directory-level_014");
1215 status += fx_directory_default_set(&ram_disk, "sub-directory-level_015");
1216
1217 /* Now set the local path again, which will inherit the global path. */
1218 status += fx_directory_local_path_set(&ram_disk, &local_path, "../sub-directory-level_015");
1219
1220 /* Check the status. */
1221 if (status != FX_SUCCESS)
1222 {
1223
1224 /* Error, return error code. */
1225 printf("ERROR!\n");
1226 test_control_return(48);
1227 }
1228
1229 /* Test to return FX_BUFFER_ERROR from _fx_directory_local_path_get_copy() */
1230 status = _fx_directory_local_path_get_copy(&ram_disk, test_path_name_buffer, sizeof(test_path_name_buffer));
1231
1232 /* Determine if the test was successful. */
1233 if (status != FX_BUFFER_ERROR)
1234 {
1235
1236 printf("ERROR!\n");
1237 test_control_return(49);
1238 }
1239
1240 /* Test to each (return_path_name_buffer[0] = '\0') line in _fx_directory_local_path_get_copy() */
1241 fx_directory_local_path_clear(&ram_disk);
1242 path_name_buffer[0] = 'A';
1243 status = _fx_directory_local_path_get_copy(&ram_disk, path_name_buffer, sizeof(path_name_buffer));
1244 status += strcmp(&path_name_buffer[0], "\0");
1245
1246 /* Determine if the test was successful. */
1247 if (status != FX_SUCCESS)
1248 {
1249
1250 printf("ERROR!\n");
1251 test_control_return(50);
1252 }
1253
1254 #endif /* FX_NO_LOCAL_PATH */
1255
1256 /* Close the media. */
1257 status = fx_media_close(&ram_disk);
1258
1259 /* Determine if the test was successful. */
1260 if (status != FX_SUCCESS)
1261 {
1262
1263 printf("ERROR!\n");
1264 test_control_return(51);
1265 }
1266 else
1267 {
1268
1269 printf("SUCCESS!\n");
1270 test_control_return(0);
1271 }
1272 }
1273
1274