1 /* In this test point: */
2 /* Send null pointer to generate an error in fxe_fault_tolerant_enable */
3 /* Register an invalid cluster number for fault_tolerant log file and enable the Fault-tolerant feature.  */
4 /* Register an invalid cluster number for fault_tolerant log file and enable the Fault-tolerant feature, but 0xffffffff this time.  */
5 /* Enable fault tolerant and make an IO ERROR while reading the FAT entry log file. */
6 /* Enable fault tolerant and make an IO ERROR while reading log file. */
7 /* Insert an ucorrect FAT information in cache before enable fault tolerant feature. */
8 /* Modify header checksum in log file before enable fault tolerant. */
9 /* Modify fat chain checksum in log file before enable fault tolerant. */
10 /* Make an IO ERROR in fx_fault_tolerant_create_log_file while reading FAT entries. */
11 /* Make an IO ERROR in fx_fault_tolerant_create_log_file while writiing FAT entries in the method of FX_UTILITY_FAT_ENTRY_WRITE_EXTENSION. */
12 /* Make an IO ERROR in fx_fault_tolerant_create_log_file while writing start cluster of log file into boot sector. */
13 /* Set fx_media_cluster_search_start to enforce filesystem to search wrapping the disk for a free cluster for log file. */
14 /* Access all the fat chain to get the last free cluster for log file and filesystem set fx_media_cluster_search_start as FX_FAT_ENTRY_START. */
15 
16 #ifndef FX_STANDALONE_ENABLE
17 #include   "tx_api.h"
18 #include   "tx_thread.h"
19 #include   "tx_timer.h"
20 #endif
21 #include   "fx_api.h"
22 #include   "fx_utility.h"
23 #include   "fx_fault_tolerant.h"
24 #include   <stdio.h>
25 #include   <string.h>
26 #include   "fx_ram_driver_test.h"
27 extern void    test_control_return(UINT status);
28 void    filex_fault_tolerant_enable_1_test_application_define(void *first_unused_memory);
29 
30 #if defined (FX_ENABLE_FAULT_TOLERANT) && defined (FX_FAULT_TOLERANT)
31 
32 #define DEMO_STACK_SIZE         4096
33 #define CACHE_SIZE              2048
34 #define FAULT_TOLERANT_SIZE     FX_FAULT_TOLERANT_MINIMAL_BUFFER_SIZE
35 
36 
37 /* Define the ThreadX and FileX object control blocks...  */
38 
39 #ifndef FX_STANDALONE_ENABLE
40 static TX_THREAD                ftest_0;
41 #endif
42 static FX_MEDIA                 ram_disk;
43 static UCHAR                    *pointer;
44 
45 /* Define the counters used in the test application...  */
46 
47 #ifndef FX_STANDALONE_ENABLE
48 static UCHAR                    *cache_buffer;
49 static UCHAR                    *fault_tolerant_buffer;
50 #else
51 static UCHAR                    cache_buffer[CACHE_SIZE];
52 static UCHAR                    fault_tolerant_buffer[FAULT_TOLERANT_SIZE];
53 #endif
54 
55 #define TEST_COUNT              3
56 
57 /* Define thread prototypes.  */
58 
59 static void    ftest_0_entry(ULONG thread_input);
60 extern void    _fx_ram_driver(FX_MEDIA *media_ptr);
61 extern void    test_control_return(UINT status);
62 
63 
64 /* Define what the initial system looks like.  */
65 
66 #ifdef CTEST
test_application_define(void * first_unused_memory)67 void test_application_define(void *first_unused_memory)
68 #else
69 void    filex_fault_tolerant_enable_1_test_application_define(void *first_unused_memory)
70 #endif
71 {
72 
73 
74 
75 #ifndef FX_STANDALONE_ENABLE
76     /* Setup the working pointer.  */
77     pointer =  (UCHAR *) first_unused_memory;
78 
79     /* Create the main thread.  */
80 
81     tx_thread_create(&ftest_0, "thread 0", ftest_0_entry, 0,
82             pointer, DEMO_STACK_SIZE,
83             4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
84 
85     pointer =  pointer + DEMO_STACK_SIZE;
86 
87     /* Setup memory for the RAM disk and the sector cache.  */
88     cache_buffer =  pointer;
89     pointer += CACHE_SIZE;
90     fault_tolerant_buffer = pointer;
91     pointer += FAULT_TOLERANT_SIZE + 1024;
92 #endif
93 
94     /* Initialize the FileX system.  */
95     fx_system_initialize();
96 #ifdef FX_STANDALONE_ENABLE
97     ftest_0_entry(0);
98 #endif
99 }
100 
101 
102 /* Define the test threads.  */
103 
ftest_0_entry(ULONG thread_input)104 static void    ftest_0_entry(ULONG thread_input)
105 {
106 
107 UINT        status;
108 UCHAR       buffer[2048];
109 ULONG       clusters;
110 ULONG       bytes_per_cluster;
111 FX_FILE     my_file;
112 FX_LOCAL_PATH local_path;
113 
114     FX_PARAMETER_NOT_USED(thread_input);
115 
116     /* Print out some test information banners.  */
117     printf("FileX Test:   Fault Tolerant Enable 1 Test...........................");
118 
119     /* Format the media with FAT16.  This needs to be done before opening it!  */
120     status =  fx_media_format(&ram_disk,
121                              _fx_ram_driver,         // Driver entry
122                              ram_disk_memory_large,  // RAM disk memory pointer
123                              cache_buffer,           // Media buffer pointer
124                              CACHE_SIZE,             // Media buffer size
125                              "MY_RAM_DISK",          // Volume Name
126                              1,                      // Number of FATs
127                              32,                     // Directory Entries
128                              0,                      // Hidden sectors
129                              4200 * 8,               // Total sectors
130                              256,                    // Sector size
131                              8,                      // Sectors per cluster
132                              1,                      // Heads
133                              1);                     // Sectors per track
134     status +=  fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
135     return_if_fail( status == FX_SUCCESS);
136 
137 /* Only run this if error checking is enabled */
138 #ifndef FX_DISABLE_ERROR_CHECKING
139 
140     /* send null pointer to generate an error */
141     status = fx_fault_tolerant_enable( FX_NULL, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
142     return_if_fail( status == FX_PTR_ERROR);
143 
144     /* send null pointer to generate an error */
145     status = fx_fault_tolerant_enable( &ram_disk, FX_NULL, FAULT_TOLERANT_SIZE);
146     return_if_fail( status == FX_PTR_ERROR);
147 
148 #endif /* FX_DISABLE_ERROR_CHECKING */
149 
150     /* Register an invalid cluster number for fault_tolerant log file and enable the Fault-tolerant feature.  */
151     _fx_utility_32_unsigned_write((UCHAR *)ram_disk.fx_media_driver_info + FX_FAULT_TOLERANT_BOOT_INDEX, (ULONG)1);
152     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
153     return_if_fail( status == FX_SUCCESS);
154 
155     status = fx_media_close( &ram_disk);
156     return_if_fail( status == FX_SUCCESS);
157 
158     /* Format the media with FAT16.  This needs to be done before opening it!  */
159     status =  fx_media_format(&ram_disk,
160                              _fx_ram_driver,         // Driver entry
161                              ram_disk_memory_large,  // RAM disk memory pointer
162                              cache_buffer,           // Media buffer pointer
163                              CACHE_SIZE,             // Media buffer size
164                              "MY_RAM_DISK",          // Volume Name
165                              1,                      // Number of FATs
166                              32,                     // Directory Entries
167                              0,                      // Hidden sectors
168                              4200 * 8,               // Total sectors
169                              256,                    // Sector size
170                              8,                      // Sectors per cluster
171                              1,                      // Heads
172                              1);                     // Sectors per track
173     status +=  fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
174     return_if_fail( status == FX_SUCCESS);
175 
176     /* Register an invalid cluster number for fault_tolerant log file and enable the Fault-tolerant feature, but 0xffffffff this time.  */
177     _fx_utility_32_unsigned_write((UCHAR *)ram_disk.fx_media_driver_info + FX_FAULT_TOLERANT_BOOT_INDEX, (ULONG)0xffffffff);
178     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
179     return_if_fail( status == FX_SUCCESS);
180 
181     status = fx_media_close( &ram_disk);
182     return_if_fail( status == FX_SUCCESS);
183 
184     /* Format the media with FAT16.  This needs to be done before opening it!  */
185     status =  fx_media_format(&ram_disk,
186                              _fx_ram_driver,         // Driver entry
187                              ram_disk_memory_large,  // RAM disk memory pointer
188                              cache_buffer,           // Media buffer pointer
189                              CACHE_SIZE,             // Media buffer size
190                              "MY_RAM_DISK",          // Volume Name
191                              1,                      // Number of FATs
192                              32,                     // Directory Entries
193                              0,                      // Hidden sectors
194                              4200 * 8,               // Total sectors
195                              256,                    // Sector size
196                              12,                     // Sectors per cluster
197                              1,                      // Heads
198                              1);                     // Sectors per track
199     status +=  fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
200     return_if_fail( status == FX_SUCCESS);
201 
202     /* Register an invalid cluster number for fault_tolerant log file and enable the Fault-tolerant feature, but the last FAT entry does not link to fat last.  */
203     _fx_utility_32_unsigned_write((UCHAR *)ram_disk.fx_media_driver_info + FX_FAULT_TOLERANT_BOOT_INDEX, (ULONG)2);
204     _fx_utility_FAT_entry_write( &ram_disk, 2, 3);
205     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
206     return_if_fail( status == FX_SUCCESS);
207 
208     status = fx_media_close( &ram_disk);
209     return_if_fail( status == FX_SUCCESS);
210 
211     /* Format the media with FAT16 and enable fault tolerant. */
212     status =  fx_media_format(&ram_disk,
213                              _fx_ram_driver,         // Driver entry
214                              ram_disk_memory_large,  // RAM disk memory pointer
215                              cache_buffer,           // Media buffer pointer
216                              CACHE_SIZE,             // Media buffer size
217                              "MY_RAM_DISK",          // Volume Name
218                              1,                      // Number of FATs
219                              32,                     // Directory Entries
220                              0,                      // Hidden sectors
221                              4200 * 8,               // Total sectors
222                              256,                    // Sector size
223                              8,                      // Sectors per cluster
224                              1,                      // Heads
225                              1);                     // Sectors per track
226     status += fx_media_open( &ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
227     status += fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
228     status += fx_media_close( &ram_disk);
229     status += fx_media_open( &ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
230     return_if_fail( status == FX_SUCCESS);
231 
232     /* Enable fault tolerant and make an IO ERROR while reading the FAT entry log file. */
233     _fx_ram_driver_io_error_request = 2;
234     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
235     return_if_fail( status == FX_IO_ERROR);
236 
237     /* Enable fault tolerant and make an IO ERROR while reading log file. */
238     _fx_ram_driver_io_error_request = 3;
239     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
240     return_if_fail( status == FX_IO_ERROR);
241 
242     /* Insert an ucorrect FAT information in cache. */
243     ram_disk.fx_media_fat_cache[8].fx_fat_cache_entry_cluster = 2;
244     ram_disk.fx_media_fat_cache[8].fx_fat_cache_entry_value = 5;
245 
246     /* Enable fault tolerant still successfully but original log file is lost. */
247     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
248     return_if_fail( status == FX_SUCCESS);
249 
250     status = fx_media_close( &ram_disk);
251     return_if_fail( status == FX_SUCCESS);
252 
253     /* Format the media with FAT16 and enable fault tolerant. */
254     status =  fx_media_format(&ram_disk,
255                              _fx_ram_driver,         // Driver entry
256                              ram_disk_memory_large,  // RAM disk memory pointer
257                              cache_buffer,           // Media buffer pointer
258                              CACHE_SIZE,             // Media buffer size
259                              "MY_RAM_DISK",          // Volume Name
260                              1,                      // Number of FATs
261                              32,                     // Directory Entries
262                              0,                      // Hidden sectors
263                              4200 * 8,               // Total sectors
264                              256,                    // Sector size
265                              8,                      // Sectors per cluster
266                              1,                      // Heads
267                              1);                     // Sectors per track
268     status += fx_media_open( &ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
269     status += fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
270     status += fx_media_close( &ram_disk);
271     status += fx_media_open( &ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
272     return_if_fail( status == FX_SUCCESS);
273 
274     /* By default, log file locate at the first sector of user area. So we change the data in the log file to make checksum a non zero number. */
275     _fx_utility_logical_sector_read( &ram_disk, 1 + ram_disk.fx_media_sectors_per_FAT + ram_disk.fx_media_root_sectors, buffer, (ULONG64)1, FX_DATA_SECTOR);
276 
277     /* Modify header checksum. */
278     buffer[5]++;
279 
280     /* Write out our modification. */
281     _fx_utility_logical_sector_write( &ram_disk, 1 + ram_disk.fx_media_sectors_per_FAT + ram_disk.fx_media_root_sectors, buffer, (ULONG64)1, FX_DATA_SECTOR);
282 
283     /* Access our log file now. */
284     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
285     return_if_fail( status == FX_SUCCESS);
286 
287     status = fx_media_close( &ram_disk);
288     return_if_fail( status == FX_SUCCESS);
289 
290     status = fx_media_open( &ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
291     return_if_fail( status == FX_SUCCESS);
292 
293     /* Modify log file again, but fat chain this time. */
294     _fx_utility_logical_sector_read( &ram_disk, 1 + ram_disk.fx_media_sectors_per_FAT + ram_disk.fx_media_root_sectors, buffer, (ULONG64)1, FX_DATA_SECTOR);
295 
296     /* Modify FAT chain checksum. */
297     buffer[FX_FAULT_TOLERANT_LOG_HEADER_SIZE]++;
298     _fx_utility_logical_sector_write( &ram_disk, 1 + ram_disk.fx_media_sectors_per_FAT + ram_disk.fx_media_root_sectors, buffer, (ULONG64)1, FX_DATA_SECTOR);
299     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
300     return_if_fail( status == FX_SUCCESS);
301 
302     status = fx_media_close( &ram_disk);
303     return_if_fail( status == FX_SUCCESS);
304 
305     /* Format the media with FAT16 and enable fault tolerant. */
306     status = fx_media_format(&ram_disk,
307                              _fx_ram_driver,         // Driver entry
308                              ram_disk_memory_large,  // RAM disk memory pointer
309                              cache_buffer,           // Media buffer pointer
310                              CACHE_SIZE,             // Media buffer size
311                              "MY_RAM_DISK",          // Volume Name
312                              1,                      // Number of FATs
313                              32,                     // Directory Entries
314                              0,                      // Hidden sectors
315                              4200 * 8,               // Total sectors
316                              256,                    // Sector size
317                              8,                      // Sectors per cluster
318                              1,                      // Heads
319                              1);                     // Sectors per track
320     status += fx_media_open( &ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
321     return_if_fail( status == FX_SUCCESS);
322 
323     /* Make an IO ERROR in fx_fault_tolerant_create_log_file while reading FAT entries. */
324     _fx_ram_driver_io_error_request = 2;
325     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
326     return_if_fail( status == FX_IO_ERROR);
327 
328     /* Make an IO ERROR in fx_fault_tolerant_create_log_file while writiing FAT entries in the method of FX_UTILITY_FAT_ENTRY_WRITE_EXTENSION. */
329     /* Honestly, _fx_utility_FAT_entry_write will not call driver at this particular position. */
330     _fx_utility_fat_entry_write_error_request = 1;
331     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
332     return_if_fail( status == FX_IO_ERROR);
333 
334     /* Make an IO ERROR in fx_fault_tolerant_create_log_file while writing start cluster of log file into boot sector. */
335     _fx_ram_driver_io_error_request = 3;
336     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
337     return_if_fail( status == FX_BOOT_ERROR);
338 
339     /* Make an IO ERROR in fx_fault_tolerant_create_log_file while writiing FAT entries in the method of FX_UTILITY_FAT_ENTRY_WRITE_EXTENSION. */
340     /* Honestly, _fx_utility_FAT_entry_write will not call driver at this particular position. */
341     _fx_utility_fat_entry_write_error_request = 2;
342     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
343     return_if_fail( status == FX_IO_ERROR);
344 
345     status = fx_media_close( &ram_disk);
346     return_if_fail( status == FX_SUCCESS);
347 
348     /* Format the media with FAT16 and enable fault tolerant. */
349     status = fx_media_format(&ram_disk,
350                              _fx_ram_driver,         // Driver entry
351                              ram_disk_memory_large,  // RAM disk memory pointer
352                              cache_buffer,           // Media buffer pointer
353                              CACHE_SIZE,             // Media buffer size
354                              "MY_RAM_DISK",          // Volume Name
355                              1,                      // Number of FATs
356                              32,                     // Directory Entries
357                              0,                      // Hidden sectors
358                              4200 * 8,               // Total sectors
359                              256,                    // Sector size
360                              8,                      // Sectors per cluster
361                              1,                      // Heads
362                              1);                     // Sectors per track
363     status += fx_media_open( &ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
364     return_if_fail( status == FX_SUCCESS);
365 
366     /* Create files in a subdir to fill user data area. */
367     status = fx_directory_create( &ram_disk, "root");
368 #ifndef FX_STANDALONE_ENABLE
369     status += fx_directory_local_path_set( &ram_disk, &local_path, "root");
370 #else
371     status +=  fx_directory_default_set(&ram_disk, "/root");
372 #endif
373     /* Fill all space so that there is no space left for fault tolerant log file. */
374     status += fx_file_create( &ram_disk, "dev");
375     status += fx_file_open( &ram_disk, &my_file, "dev", FX_OPEN_FOR_WRITE);
376     status += fx_file_allocate( &my_file, 256 * 8 * 4000);
377     status += fx_file_close( &my_file);
378     status += fx_file_create( &ram_disk, "src");
379     status += fx_file_open( &ram_disk, &my_file, "src", FX_OPEN_FOR_WRITE);
380     status += fx_file_allocate( &my_file, 256 * 8 * 194);
381     return_if_fail( status == FX_SUCCESS);
382 
383     /* No space is left! */
384     status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
385     return_if_fail( status == FX_NO_MORE_SPACE);
386 
387     /* Delete a file to enable fault tolerant. */
388     status = fx_file_delete( &ram_disk, "dev");
389     return_if_fail( status == FX_SUCCESS);
390 
391     /* Set cluster_search_start as a cluster which is occupied by "src" to enforce filesystem to search wrapping the disk for a free cluster. */
392     ram_disk.fx_media_cluster_search_start = 4100;
393     status += fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
394     return_if_fail( status == FX_SUCCESS);
395 
396     status = fx_media_close( &ram_disk);
397     return_if_fail( status == FX_SUCCESS);
398 
399     /* Format the media with FAT16 and enable fault tolerant. */
400     status = fx_media_format(&ram_disk,
401                              _fx_ram_driver,         // Driver entry
402                              ram_disk_memory_large,  // RAM disk memory pointer
403                              cache_buffer,           // Media buffer pointer
404                              CACHE_SIZE,             // Media buffer size
405                              "MY_RAM_DISK",          // Volume Name
406                              1,                      // Number of FATs
407                              32,                     // Directory Entries
408                              0,                      // Hidden sectors
409                              4200 * 8,               // Total sectors
410                              256,                    // Sector size
411                              8,                      // Sectors per cluster
412                              1,                      // Heads
413                              1);                     // Sectors per track
414     status += fx_media_open( &ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
415     return_if_fail( status == FX_SUCCESS);
416 
417     /* Create files in a subdir to fill user data area. */
418     status = fx_directory_create( &ram_disk, "root");
419 #ifndef FX_STANDALONE_ENABLE
420     status += fx_directory_local_path_set( &ram_disk, &local_path, "/root");
421 #else
422     status +=  fx_directory_default_set(&ram_disk, "/root");
423 #endif
424     return_if_fail( status == FX_SUCCESS);
425 
426     bytes_per_cluster = ram_disk.fx_media_bytes_per_sector * ram_disk.fx_media_sectors_per_cluster;
427     clusters = (FX_FAULT_TOLERANT_MINIMAL_BUFFER_SIZE + bytes_per_cluster - 1) / bytes_per_cluster;
428 
429     /* Fill user data area. Only the last cluster is left. */
430     status = fx_file_create( &ram_disk, "dev");
431     status += fx_file_open( &ram_disk, &my_file, "dev", FX_OPEN_FOR_WRITE);
432     status += fx_file_allocate( &my_file, 256 * 8 * (4194 - clusters));
433     return_if_fail( status == FX_SUCCESS);
434 
435     /* Access all the fat chain to get the last free cluster for log file and filesystem set fx_media_cluster_search_start as FX_FAT_ENTRY_START. */
436     status = fx_fault_tolerant_enable( &ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
437     return_if_fail( status == FX_SUCCESS);
438 
439     status = fx_media_close( &ram_disk);
440     return_if_fail( status == FX_SUCCESS);
441 
442     /* Enable fault tolerant with buffer size larger than required. */
443     status = fx_media_format(&ram_disk,
444                              _fx_ram_driver,         // Driver entry
445                              ram_disk_memory_large,  // RAM disk memory pointer
446                              cache_buffer,           // Media buffer pointer
447                              CACHE_SIZE,             // Media buffer size
448                              "MY_RAM_DISK",          // Volume Name
449                              1,                      // Number of FATs
450                              32,                     // Directory Entries
451                              0,                      // Hidden sectors
452                              4200 * 8,               // Total sectors
453                              256,                    // Sector size
454                              4,                      // Sectors per cluster
455                              1,                      // Heads
456                              1);                     // Sectors per track
457 
458     /* Create files in a subdir to fill user data area. */
459     status += fx_media_open( &ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory_large, cache_buffer, CACHE_SIZE);
460     return_if_fail( status == FX_SUCCESS);
461 
462     status = fx_fault_tolerant_enable( &ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE + 1024);
463     return_if_fail( status == FX_SUCCESS);
464 
465     return_if_fail(ram_disk.fx_media_fault_tolerant_memory_buffer_size == FAULT_TOLERANT_SIZE);
466 
467     status = fx_media_close( &ram_disk);
468     return_if_fail( status == FX_SUCCESS);
469 
470     /* Output successful.  */
471     printf("SUCCESS!\n");
472     test_control_return(0);
473 }
474 
475 #else
476 
477 #ifdef CTEST
test_application_define(void * first_unused_memory)478 void test_application_define(void *first_unused_memory)
479 #else
480 void    filex_fault_tolerant_enable_1_test_application_define(void *first_unused_memory)
481 #endif
482 {
483 
484     FX_PARAMETER_NOT_USED(first_unused_memory);
485 
486     /* Print out some test information banners.  */
487     printf("FileX Test:   Fault Tolerant Enable 1 Test...........................N/A\n");
488 
489     test_control_return(255);
490 }
491 #endif
492