| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821 |
- /* This FileX test concentrates on the utility APIs. */
- #include "fx_api.h"
- #include "fx_ram_driver_test.h"
- #include "fx_utility.h"
- #include <stdio.h>
- void filex_utility_application_define(void *first_unused_memory);
- void test_control_return(UINT status);
- #define DEMO_STACK_SIZE 8192
- #define CACHE_SIZE 16*128
- /* Define the ThreadX and FileX object control blocks... */
- #ifndef FX_STANDALONE_ENABLE
- static TX_THREAD ftest_0;
- #endif
- static FX_MEDIA ram_disk;
- /* Define the counters used in the test application... */
- #ifndef FX_STANDALONE_ENABLE
- static UCHAR *ram_disk_memory;
- static UCHAR *cache_buffer;
- #else
- static UCHAR cache_buffer[CACHE_SIZE];
- #endif
- extern UCHAR _fx_media_format_oem_name[8];
- extern UCHAR _fx_media_format_media_type;
- extern ULONG _fx_media_format_volume_id;
- static UCHAR partition_sector[] = {
- 0xfa, 0xb8, 0x00, 0x00, 0x8e, 0xd0, 0xbc, 0x00, 0x7c, 0x8b, 0xf4, 0x50, 0x07, 0x50, 0x1f, 0xfb,
- 0xfc, 0xbf, 0x00, 0x06, 0xb9, 0x00, 0x01, 0xf3, 0xa5, 0xea, 0x1e, 0x06, 0x00, 0x00, 0xbe, 0xbe,
- 0x07, 0x80, 0x3c, 0x80, 0x74, 0x02, 0xcd, 0x18, 0x56, 0x53, 0x06, 0xbb, 0x00, 0x7c, 0xb9, 0x01,
- 0x00, 0xba, 0x00, 0x00, 0xb8, 0x01, 0x02, 0xcd, 0x13, 0x07, 0x5b, 0x5e, 0xb2, 0x80, 0x72, 0x0b,
- 0xbf, 0xbc, 0x7d, 0x81, 0x3d, 0x55, 0x53, 0x75, 0x02, 0xb2, 0x00, 0xbf, 0xeb, 0x06, 0x88, 0x15,
- 0x8a, 0x74, 0x01, 0x8b, 0x4c, 0x02, 0x8b, 0xee, 0xeb, 0x15, 0xbe, 0x9b, 0x06, 0xac, 0x3c, 0x00,
- 0x74, 0x0b, 0x56, 0xbb, 0x07, 0x00, 0xb4, 0x0e, 0xcd, 0x10, 0x5e, 0xeb, 0xf0, 0xeb, 0xfe, 0xbb,
- 0x00, 0x7c, 0xb8, 0x01, 0x02, 0xcd, 0x13, 0x73, 0x05, 0xbe, 0xb3, 0x06, 0xeb, 0xdf, 0xbe, 0xd2,
- 0x06, 0xbf, 0xfe, 0x7d, 0x81, 0x3d, 0x55, 0xaa, 0x75, 0xd3, 0xbf, 0x24, 0x7c, 0xbe, 0xeb, 0x06,
- 0x8a, 0x04, 0x88, 0x05, 0x8b, 0xf5, 0xea, 0x00, 0x7c, 0x00, 0x00, 0x49, 0x6e, 0x76, 0x61, 0x6c,
- 0x69, 0x64, 0x20, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x61, 0x62,
- 0x6c, 0x65, 0x00, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67,
- 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65,
- 0x6d, 0x00, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74,
- 0x69, 0x6e, 0x67, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x1a, 0xb8, 0x5e, 0x00, 0x00, 0x00, 0x14,
- 0x35, 0x00, 0x0c, 0xfe, 0xff, 0xe9, 0x20, 0x05, 0x00, 0x00, 0xe0, 0xa2, 0xf5, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
- };
- #define TEST_COUNT 5
- /* Define thread prototypes. */
- static void ftest_0_entry(ULONG thread_input);
- VOID _fx_ram_driver(FX_MEDIA *media_ptr);
- UINT fx_media_format_oem_name_set(UCHAR new_oem_name[8]);
- UINT fx_media_format_type_set(UCHAR new_media_type);
- UINT fx_media_format_volume_id_set(ULONG new_volume_id);
- UINT _fx_partition_offset_calculate(void *partition_sector, UINT partition,
- ULONG *partition_start, ULONG *partition_size);
- /* Define what the initial system looks like. */
- #ifdef CTEST
- void test_application_define(void *first_unused_memory)
- #else
- void filex_utility_application_define(void *first_unused_memory)
- #endif
- {
- #ifndef FX_STANDALONE_ENABLE
- UCHAR *pointer;
-
- /* Setup the working pointer. */
- pointer = (UCHAR *) first_unused_memory;
- /* Create the main thread. */
- tx_thread_create(&ftest_0, "thread 0", ftest_0_entry, 0,
- pointer, DEMO_STACK_SIZE,
- 4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
- pointer = pointer + DEMO_STACK_SIZE;
- /* Setup memory for the RAM disk and the sector cache. */
- cache_buffer = pointer;
- pointer = pointer + CACHE_SIZE;
- ram_disk_memory = pointer;
- #endif
- /* Initialize the FileX system. */
- fx_system_initialize();
- #ifdef FX_STANDALONE_ENABLE
- ftest_0_entry(0);
- #endif
- }
- static void no_partition_test()
- {
- UINT i;
- UINT status;
- ULONG total_sectors;
- ULONG partition_start;
- ULONG partition_size;
-
- /* Loop to test FAT 12, 16, 32. */
- for (i = 0; i < TEST_COUNT; i ++)
- {
- if (i == 0)
- {
- /* Format the media with FAT12. This needs to be done before opening it! */
- total_sectors = 256;
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory_large, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 32, // Directory Entries
- 0, // Hidden sectors
- total_sectors, // Total sectors
- 512, // Sector size
- 8, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- }
- else if (i == 1)
- {
- /* Format the media with FAT16. This needs to be done before opening it! */
- total_sectors = 4200 * 8;
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory_large, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 32, // Directory Entries
- 0, // Hidden sectors
- total_sectors, // Total sectors
- 512, // Sector size
- 8, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- }
- else if (i == 2)
- {
- /* Format the media with FAT32. This needs to be done before opening it! */
- total_sectors = 70000 * 8;
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory_large, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 32, // Directory Entries
- 0, // Hidden sectors
- total_sectors, // Total sectors
- 512, // Sector size
- 8, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- }
- else if (i == 3)
- {
- /* Format the media with FAT12. This needs to be done before opening it! */
- total_sectors = 256;
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory_large, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 32, // Directory Entries
- 0, // Hidden sectors
- total_sectors, // Total sectors
- 128, // Sector size
- 8, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- }
- else if (i == 4)
- {
- /* Format the media with FAT12. This needs to be done before opening it! */
- total_sectors = 256;
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory_large, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 32, // Directory Entries
- 0, // Hidden sectors
- total_sectors, // Total sectors
- 1024, // Sector size
- 8, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- }
- return_if_fail( status == FX_SUCCESS);
- /* Get partition offset and size. */
- _fx_partition_offset_calculate(ram_disk_memory_large, 0, &partition_start, &partition_size);
- /* Check partition offset and size. */
- return_value_if_fail(partition_start == 0, 6);
- return_value_if_fail(partition_size == total_sectors, 7);
- }
- }
- /* Define the test threads. */
- static void ftest_0_entry(ULONG thread_input)
- {
- UCHAR oem_name[8] = {'O', 'E', 'M', ' ', 'N', 'A', 'M', 'E'};
- ULONG partition_start;
- ULONG partition_size;
- ULONG FAT_sector;
- ULONG64 value;
- CHAR buffer[16];
- UINT size;
- UINT status;
- UINT partition_sector_value;
- FX_MEDIA tmp_media;
- ULONG temp;
- ULONG temp1;
- ULONG temp2;
- ULONG temp3;
- ULONG temp4;
- ULONG temp5;
- ULONG temp6;
- FX_PARAMETER_NOT_USED(thread_input);
- /* Print out some test information banners. */
- printf("FileX Test: Utility test...........................................");
- /* Modify OEM_NAME. */
- fx_media_format_oem_name_set(oem_name);
- /* Check OEM_NAME. */
- return_value_if_fail(memcmp(oem_name, _fx_media_format_oem_name, sizeof(oem_name)) == 0, 1);
- /* Modify media_type. */
- fx_media_format_type_set(0xF0);
- /* Check media_type. */
- return_value_if_fail(_fx_media_format_media_type == 0xF0, 2);
- /* Modify volume_id. */
- fx_media_format_volume_id_set(0xFF);
- /* Check media_type. */
- return_value_if_fail(_fx_media_format_volume_id == 0xFF, 3);
- /* Get partition offset and size. */
- _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check partition offset and size. */
- return_value_if_fail(partition_start == 0x0520, 4);
- return_value_if_fail(partition_size == 0xF5A2E0, 5);
- /* Check for error in _fx_partition_offset_calculate when buffer is invalid. */
- /* Induce error in buffer */
- partition_sector[510] = 0xFF;
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_NOT_FOUND)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate!\n");
- test_control_return(1);
- }
- /* Restore buffer */
- partition_sector[510] = 0x55;
- /* BRANCH COVERAGE TESTS START */
- /* Induce error in buffer */
- partition_sector[511] = 0xFF;
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_NOT_FOUND)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate!\n");
- test_control_return(2);
- }
- /* Restore buffer */
- partition_sector[511] = 0xAA;
- partition_sector_value = partition_sector[0];
- /* Induce error in buffer */
- partition_sector[0] = 0xFF;
- status = _fx_partition_offset_calculate(partition_sector, 100, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_NOT_FOUND)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(3);
- }
- /* Restore buffer */
- partition_sector[0] = partition_sector_value;
- partition_sector_value = partition_sector[2];
- /* Induce error in buffer */
- partition_sector[2] = 0xFF;
- status = _fx_partition_offset_calculate(partition_sector, 100, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_NOT_FOUND)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(4);
- }
- /* Restore buffer */
- partition_sector[2] = partition_sector_value;
- partition_sector_value = partition_sector[0];
- /* Induce error in buffer */
- partition_sector[0] = 0xe9;
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(5);
- }
- /* Restore buffer */
- partition_sector[0] = partition_sector_value;
- partition_sector_value = partition_sector[0];
- /* Induce error in buffer */
- partition_sector[0] = 0xeb;
- status = _fx_partition_offset_calculate(partition_sector, 100, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_NOT_FOUND)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(5);
- }
- /* Restore buffer */
- partition_sector[0] = partition_sector_value;
-
- partition_sector_value = partition_sector[0];
- temp = partition_sector[2];
- /* Induce error in buffer */
- partition_sector[0] = 0xeb;
- partition_sector[2] = 0x90;
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(6);
- }
- /* Restore buffer */
- partition_sector[0] = partition_sector_value;
- partition_sector[2] = temp;
- partition_sector_value = partition_sector[0];
- temp = partition_sector[2];
- /* Induce error in buffer */
- partition_sector[0] = 0xe9;
- partition_sector[2] = 0x90;
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(6);
- }
- /* Restore buffer */
- partition_sector[0] = partition_sector_value;
- partition_sector[2] = temp;
- /* Test to check the partition_sector values, if there are good values for sectors per FAT.
- We want the test code to return FX_NOT_FOUND after _fx_utility_partition_get() is called */
- /* Set real boot sector check to true */
- temp6 = partition_sector[0];
- partition_sector[0] = 0xe9;
- temp = partition_sector[0x16];
- temp1 = partition_sector[0x17];
- temp2 = partition_sector[0x24];
- temp3 = partition_sector[0x25];
- temp4 = partition_sector[0x26];
- temp5 = partition_sector[0x27];
- /* Induce error in buffer */
- partition_sector[0x16] = 0;
- partition_sector[0x17] = 0;
- partition_sector[0x24] = 0;
- partition_sector[0x25] = 0;
- partition_sector[0x26] = 0;
- partition_sector[0x27] = 0;
-
- status = _fx_partition_offset_calculate(partition_sector, 100, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_NOT_FOUND)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(7);
- }
- /* Restore buffer */
- partition_sector[0x16] = temp;
- partition_sector[0x17] = temp1;
- partition_sector[0x24] = temp2;
- partition_sector[0x25] = temp3;
- partition_sector[0x26] = temp4;
- partition_sector[0x27] = temp5;
- /* Induce error in buffer */
- partition_sector[0x17] = 0;
- partition_sector[0x24] = 0;
- partition_sector[0x25] = 0;
- partition_sector[0x26] = 0;
- partition_sector[0x27] = 0;
-
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(8);
- }
- /* Restore buffer */
- partition_sector[0x17] = temp1;
- partition_sector[0x24] = temp2;
- partition_sector[0x25] = temp3;
- partition_sector[0x26] = temp4;
- partition_sector[0x27] = temp5;
- /* Induce error in buffer */
- partition_sector[0x16] = 0;
- partition_sector[0x24] = 0;
- partition_sector[0x25] = 0;
- partition_sector[0x26] = 0;
- partition_sector[0x27] = 0;
-
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(9);
- }
- /* Restore buffer */
- partition_sector[0x16] = temp;
- partition_sector[0x24] = temp2;
- partition_sector[0x25] = temp3;
- partition_sector[0x26] = temp4;
- partition_sector[0x27] = temp5;
- /* Induce error in buffer */
- partition_sector[0x16] = 0;
- partition_sector[0x17] = 0;
- partition_sector[0x25] = 0;
- partition_sector[0x26] = 0;
- partition_sector[0x27] = 0;
-
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(10);
- }
- /* Restore buffer */
- partition_sector[0x16] = temp;
- partition_sector[0x17] = temp1;
- partition_sector[0x25] = temp3;
- partition_sector[0x26] = temp4;
- partition_sector[0x27] = temp5;
- /* Induce error in buffer */
- partition_sector[0x16] = 0;
- partition_sector[0x17] = 0;
- partition_sector[0x24] = 0;
- partition_sector[0x26] = 0;
- partition_sector[0x27] = 0;
-
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(11);
- }
- /* Restore buffer */
- partition_sector[0x16] = temp;
- partition_sector[0x17] = temp1;
- partition_sector[0x24] = temp2;
- partition_sector[0x26] = temp4;
- partition_sector[0x27] = temp5;
- /* Induce error in buffer */
- partition_sector[0x16] = 0;
- partition_sector[0x17] = 0;
- partition_sector[0x24] = 0;
- partition_sector[0x25] = 0;
- partition_sector[0x27] = 0;
-
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(12);
- }
- /* Restore buffer */
- partition_sector[0x16] = temp;
- partition_sector[0x17] = temp1;
- partition_sector[0x24] = temp2;
- partition_sector[0x25] = temp3;
- partition_sector[0x27] = temp5;
- /* Induce error in buffer */
- partition_sector[0x16] = 0;
- partition_sector[0x17] = 0;
- partition_sector[0x24] = 0;
- partition_sector[0x25] = 0;
- partition_sector[0x26] = 0;
-
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(13);
- }
- /* Restore buffer */
- partition_sector[0x16] = temp;
- partition_sector[0x17] = temp1;
- partition_sector[0x24] = temp2;
- partition_sector[0x25] = temp3;
- partition_sector[0x26] = temp4;
- temp = partition_sector[0x20];
- temp1 = partition_sector[0x21];
- temp2 = partition_sector[0x22];
- temp3 = partition_sector[0x23];
- /* Set calculatation of the total sectors based of FAT32 */
- temp4 = partition_sector[0x13];
- temp5 = partition_sector[0x14];
- partition_sector[0x13] = 0;
- partition_sector[0x14] = 0;
- /* Induce error in buffer */
- partition_sector[0x20] = 0;
- partition_sector[0x21] = 0;
- partition_sector[0x22] = 0;
- partition_sector[0x23] = 0;
- status = _fx_partition_offset_calculate(partition_sector, 100, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_NOT_FOUND)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(14);
- }
- /* Restore buffer */
- partition_sector[0x20] = temp;
- partition_sector[0x21] = temp1;
- partition_sector[0x22] = temp2;
- partition_sector[0x23] = temp3;
- /* Induce error in buffer */
- partition_sector[0x21] = 0;
- partition_sector[0x22] = 0;
- partition_sector[0x23] = 0;
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(15);
- }
- /* Restore buffer */
- partition_sector[0x21] = temp1;
- partition_sector[0x22] = temp2;
- partition_sector[0x23] = temp3;
- /* Induce error in buffer */
- partition_sector[0x20] = 0;
- partition_sector[0x22] = 0;
- partition_sector[0x23] = 0;
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(16);
- }
- /* Restore buffer */
- partition_sector[0x20] = temp;
- partition_sector[0x22] = temp2;
- partition_sector[0x23] = temp3;
-
- /* Induce error in buffer */
- partition_sector[0x20] = 0;
- partition_sector[0x21] = 0;
- partition_sector[0x23] = 0;
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(17);
- }
- /* Restore buffer */
- partition_sector[0x20] = temp;
- partition_sector[0x21] = temp1;
- partition_sector[0x23] = temp3;
-
- /* Induce error in buffer */
- partition_sector[0x20] = 0;
- partition_sector[0x21] = 0;
- partition_sector[0x22] = 0;
- status = _fx_partition_offset_calculate(partition_sector, 0, &partition_start, &partition_size);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(18);
- }
-
- /* Check for partition_start and partition_size to be NULL */
- status = _fx_partition_offset_calculate(partition_sector, 0, FX_NULL, FX_NULL);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(19);
- }
-
- /* Restore buffer */
- partition_sector[0x20] = temp;
- partition_sector[0x21] = temp1;
- partition_sector[0x22] = temp2;
- /* Restore real boot sector and the total sector check to default */
- partition_sector[0] = temp6;
- partition_sector[0x13] = temp4;
- partition_sector[0x14] = temp5;
- /* Check for partition_start and partition_size to be NULL to cover line 236 and 242 */
- status = _fx_partition_offset_calculate(partition_sector, 0, FX_NULL, FX_NULL);
- /* Check for the error. */
- if (status != FX_SUCCESS)
- {
- /* Print error message. */
- printf("Error in checking of _fx_partition_offset_calculate! %d\n",status);
- test_control_return(20);
- }
- /* BRANCH COVERAGE TESTS END */
- /* Invoke _fx_utility_memory_set and _fx_utility_string_length_get. */
- _fx_utility_memory_set((UCHAR*)buffer, 0, 0);
- _fx_utility_memory_set((UCHAR*)buffer, 0, sizeof(buffer));
- size = _fx_utility_string_length_get(buffer, sizeof(buffer));
- return_if_fail(size == 0);
- buffer[0] = 'a';
- size = _fx_utility_string_length_get(buffer, sizeof(buffer));
- return_if_fail(size == 1);
- _fx_utility_memory_set((UCHAR*)buffer, 'a', sizeof(buffer));
- size = _fx_utility_string_length_get(buffer, sizeof(buffer));
- return_if_fail(size == sizeof(buffer));
- _fx_utility_memory_set((UCHAR*)buffer, 'a', sizeof(buffer));
- size = _fx_utility_string_length_get(buffer, 1);
- return_if_fail(size == 1);
- /* Tests for utility_64_unsigned_read, utility_64_unsigned_write and utility_FAT_sector_get. */
- _fx_utility_64_unsigned_write((UCHAR*)buffer, 0x0001);
- value = _fx_utility_64_unsigned_read((UCHAR*)buffer);
- return_if_fail(0x0001 == value);
- /* Tests for utility_FAT_sector_get. */
- tmp_media.fx_media_bytes_per_sector = 512;
- tmp_media.fx_media_reserved_sectors = 0;
- /* 12-bit FAT. */
- tmp_media.fx_media_12_bit_FAT = 1;
- /* The FAT entry of cluster 400 is located at the second sector. */
- FAT_sector = _fx_utility_FAT_sector_get(&tmp_media, 400);
- return_if_fail(1 == FAT_sector);
- /* 16-bit FAT. */
- tmp_media.fx_media_12_bit_FAT = 0;
- tmp_media.fx_media_32_bit_FAT = 0;
- /* The FAT entry of cluster 400 is located at the second sector. */
- FAT_sector = _fx_utility_FAT_sector_get(&tmp_media, 400);
- return_if_fail(1 == FAT_sector);
- /* 32-bit FAT. */
- tmp_media.fx_media_12_bit_FAT = 0;
- tmp_media.fx_media_32_bit_FAT = 1;
- /* The FAT entry of cluster 400 is located at the fourth sector. */
- FAT_sector = _fx_utility_FAT_sector_get(&tmp_media, 400);
- return_if_fail(3 == FAT_sector);
- no_partition_test();
- printf("SUCCESS!\n");
- test_control_return(0);
- }
|