filex_unicode_test.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. /* This FileX test concentrates on the unicode operations. */
  2. #ifndef FX_STANDALONE_ENABLE
  3. #include "tx_api.h"
  4. #endif
  5. #include "fx_api.h"
  6. #include "fx_utility.h"
  7. #include <stdio.h>
  8. #include "fx_ram_driver_test.h"
  9. #define DEMO_STACK_SIZE 8192
  10. #define CACHE_SIZE 16*128
  11. /* Define the ThreadX and FileX object control blocks... */
  12. #ifndef FX_STANDALONE_ENABLE
  13. static TX_THREAD ftest_0;
  14. #endif
  15. static FX_MEDIA ram_disk;
  16. static UCHAR short_unicode_name[] = {1, 0, 0, 0};
  17. static UCHAR directory_name[] = {3, 0, 4, 0, 5, 0, 6, 0, 0, 0};
  18. static UCHAR long_unicode_name[] = {2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 0, 0};
  19. static UCHAR destination_name[100];
  20. static UCHAR does_not_exist[] = {1, 1, 1, 1};
  21. static UCHAR unicode_temp_long_file_name[FX_MAX_LONG_NAME_LEN];
  22. /* Define the counters used in the test application... */
  23. #ifndef FX_STANDALONE_ENABLE
  24. static UCHAR *ram_disk_memory;
  25. static UCHAR *cache_buffer;
  26. #else
  27. static UCHAR cache_buffer[CACHE_SIZE];
  28. #endif
  29. /* Define thread prototypes. */
  30. void filex_unicode_application_define(void *first_unused_memory);
  31. static void ftest_0_entry(ULONG thread_input);
  32. VOID _fx_ram_driver(FX_MEDIA *media_ptr);
  33. void test_control_return(UINT status);
  34. #ifndef FX_ENABLE_FAULT_TOLERANT
  35. /* Calculate the times driver was called to raise error at a particular time. */
  36. static INT driver_called_counter = 0;
  37. /* Create a terrible driver. */
  38. static void _fx_terrible_driver(FX_MEDIA *media_ptr)
  39. {
  40. driver_called_counter++;
  41. /* Make IO error to cover the branch at Line 247 in fx_unicode_file_create.c */
  42. if ( driver_called_counter != 61)
  43. (* _fx_ram_driver)(media_ptr);
  44. else
  45. media_ptr -> fx_media_driver_status = FX_IO_ERROR;
  46. return;
  47. }
  48. #endif /* FX_ENABLE_FAULT_TOLERANT */
  49. /* Define what the initial system looks like. */
  50. #ifdef CTEST
  51. void test_application_define(void *first_unused_memory)
  52. #else
  53. void filex_unicode_application_define(void *first_unused_memory)
  54. #endif
  55. {
  56. #ifndef FX_STANDALONE_ENABLE
  57. UCHAR *pointer;
  58. /* Setup the working pointer. */
  59. pointer = (UCHAR *) first_unused_memory;
  60. /* Create the main thread. */
  61. tx_thread_create(&ftest_0, "thread 0", ftest_0_entry, 0,
  62. pointer, DEMO_STACK_SIZE,
  63. 4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
  64. pointer = pointer + DEMO_STACK_SIZE;
  65. /* Setup memory for the RAM disk and the sector cache. */
  66. cache_buffer = pointer;
  67. pointer = pointer + CACHE_SIZE;
  68. ram_disk_memory = pointer;
  69. #endif
  70. /* Initialize the FileX system. */
  71. fx_system_initialize();
  72. #ifdef FX_STANDALONE_ENABLE
  73. ftest_0_entry(0);
  74. #endif
  75. }
  76. /* Define the test threads. */
  77. static void ftest_0_entry(ULONG thread_input)
  78. {
  79. UINT status;
  80. ULONG length;
  81. ULONG ul_temp;
  82. UCHAR buffer[512];
  83. UINT i;
  84. FX_PARAMETER_NOT_USED(thread_input);
  85. /* Print out some test information banners. */
  86. printf("FileX Test: Unicode test...........................................");
  87. /* Format the media. This needs to be done before opening it! */
  88. status = fx_media_format(&ram_disk,
  89. _fx_ram_driver, // Driver entry
  90. ram_disk_memory, // RAM disk memory pointer
  91. cache_buffer, // Media buffer pointer
  92. CACHE_SIZE, // Media buffer size
  93. "MY_RAM_DISK", // Volume Name
  94. 1, // Number of FATs
  95. 100, // Directory Entries
  96. 0, // Hidden sectors
  97. 512, // Total sectors
  98. 128, // Sector size
  99. 1, // Sectors per cluster
  100. 1, // Heads
  101. 1); // Sectors per track
  102. /* Determine if the format had an error. */
  103. if (status)
  104. {
  105. printf("ERROR!\n");
  106. test_control_return(1);
  107. }
  108. /* try to do all the unicode commands before the media is opened to generate an error */
  109. length = 1;
  110. /* short name get */
  111. status = fx_unicode_short_name_get(&ram_disk, directory_name, length, (CHAR *) destination_name);
  112. if (status != FX_MEDIA_NOT_OPEN)
  113. {
  114. printf("ERROR!\n");
  115. test_control_return(2);
  116. }
  117. /* Call extended version of short name get. */
  118. status = fx_unicode_short_name_get_extended(&ram_disk, directory_name, length, (CHAR*)destination_name, sizeof(destination_name));
  119. if (status != FX_MEDIA_NOT_OPEN)
  120. {
  121. printf("ERROR!\n");
  122. test_control_return(2);
  123. }
  124. /* name get */
  125. status = fx_unicode_name_get(&ram_disk, (CHAR *) destination_name, destination_name, &length);
  126. if (status != FX_MEDIA_NOT_OPEN)
  127. {
  128. printf("ERROR!\n");
  129. test_control_return(3);
  130. }
  131. /* Call extended version of name get. */
  132. status = fx_unicode_name_get_extended(&ram_disk, (CHAR*)destination_name, destination_name, &length, sizeof(destination_name));
  133. if (status != FX_MEDIA_NOT_OPEN)
  134. {
  135. printf("ERROR!\n");
  136. test_control_return(3);
  137. }
  138. /* create */
  139. status = fx_unicode_directory_create(&ram_disk, directory_name, length, (CHAR *) destination_name);
  140. if (status != FX_MEDIA_NOT_OPEN)
  141. {
  142. printf("ERROR!\n");
  143. test_control_return(4);
  144. }
  145. /* file create */
  146. status = fx_unicode_file_create(&ram_disk, short_unicode_name, length, (CHAR *) destination_name);
  147. if (status != FX_MEDIA_NOT_OPEN)
  148. {
  149. printf("ERROR!\n");
  150. test_control_return(5);
  151. }
  152. /* Open the ram_disk. */
  153. status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, CACHE_SIZE);
  154. /* Check the status. */
  155. if (status != FX_SUCCESS)
  156. {
  157. /* Error, return error code. */
  158. printf("ERROR!\n");
  159. test_control_return(6);
  160. }
  161. /* try to create a directory while the media is write protected */
  162. ram_disk.fx_media_driver_write_protect = FX_TRUE;
  163. status = fx_unicode_directory_create(&ram_disk, directory_name, length, (CHAR *) destination_name);
  164. if (status != FX_WRITE_PROTECT)
  165. {
  166. printf("ERROR!\n");
  167. test_control_return(7);
  168. }
  169. /* try to create a file while the media is write protected */
  170. status = fx_unicode_file_create(&ram_disk, short_unicode_name, length, (CHAR *) destination_name);
  171. if (status != FX_WRITE_PROTECT)
  172. {
  173. printf("ERROR!\n");
  174. test_control_return(8);
  175. }
  176. ram_disk.fx_media_driver_write_protect = FX_FALSE;
  177. /* only test this if error checking is enabled */
  178. #ifndef FX_DISABLE_ERROR_CHECKING
  179. /* send a null pointer to generate an error */
  180. /* short name get */
  181. status = fx_unicode_short_name_get(FX_NULL, directory_name, length, (CHAR *) destination_name);
  182. if (status != FX_PTR_ERROR)
  183. {
  184. printf("ERROR!\n");
  185. test_control_return(9);
  186. }
  187. /* name get */
  188. status = fx_unicode_name_get(FX_NULL, (CHAR *) destination_name, destination_name, &length);
  189. if (status != FX_PTR_ERROR)
  190. {
  191. printf("ERROR!\n");
  192. test_control_return(10);
  193. }
  194. /* file create */
  195. status = fx_unicode_file_create(FX_NULL, short_unicode_name, length, (CHAR *) destination_name);
  196. if (status != FX_PTR_ERROR)
  197. {
  198. printf("ERROR!\n");
  199. test_control_return(11);
  200. }
  201. #endif /* FX_DISABLE_ERROR_CHECKING */
  202. /* Create the a short and long unicode file name. */
  203. length = fx_unicode_length_get(short_unicode_name);
  204. status = fx_unicode_file_create(&ram_disk, short_unicode_name, length, (CHAR *) destination_name);
  205. length = fx_unicode_length_get(long_unicode_name);
  206. status += fx_unicode_file_create(&ram_disk, long_unicode_name, length, (CHAR *) destination_name);
  207. status += fx_file_create(&ram_disk, "abcdefghijklmnop");
  208. status += fx_directory_short_name_get(&ram_disk, "abcdefghijklmnop", (CHAR *) destination_name);
  209. status += fx_media_flush(&ram_disk);
  210. /* Check for erros. */
  211. if (status != FX_SUCCESS)
  212. {
  213. /* Error creating unicode file names. Return to caller. */
  214. printf("ERROR!\n");
  215. test_control_return(13);
  216. }
  217. /* Try to create the same name again - this should result in an error! */
  218. length = fx_unicode_length_get(long_unicode_name);
  219. status += fx_unicode_file_create(&ram_disk, long_unicode_name, length, (CHAR *) destination_name);
  220. /* Check for expected error. */
  221. if (status != FX_ALREADY_CREATED)
  222. {
  223. /* Error creating unicode file names. Return to caller. */
  224. printf("ERROR!\n");
  225. test_control_return(14);
  226. }
  227. /* Try creating a unicode name twice... this should result in an error as well. */
  228. length = fx_unicode_length_get(short_unicode_name);
  229. status = fx_unicode_file_create(&ram_disk, short_unicode_name, length, (CHAR *) destination_name);
  230. /* Check for expected error. */
  231. if (status != FX_ALREADY_CREATED)
  232. {
  233. /* Error creating unicode file names. Return to caller. */
  234. printf("ERROR!\n");
  235. test_control_return(15);
  236. }
  237. /* Only run this if error checking is enabled */
  238. #ifndef FX_DISABLE_ERROR_CHECKING
  239. /* send null pointer to generate an error */
  240. status = fx_unicode_directory_create(FX_NULL, directory_name, length, (CHAR *) destination_name);
  241. if (status != FX_PTR_ERROR)
  242. {
  243. printf("ERROR!\n");
  244. test_control_return(16);
  245. }
  246. #endif /* FX_DISABLE_ERROR_CHECKING */
  247. /* Create the unicode directory name to create the same unicode file names in the sub directory. */
  248. length = fx_unicode_length_get(directory_name);
  249. status = fx_unicode_directory_create(&ram_disk, directory_name, length, (CHAR *) destination_name);
  250. status += fx_file_create(&ram_disk, "qrstuvwxyz");
  251. /* Check for erros. */
  252. if (status != FX_SUCCESS)
  253. {
  254. /* Error creating unicode directory. Return to caller. */
  255. printf("ERROR!\n");
  256. test_control_return(17);
  257. }
  258. /* Attempt to create the unicode sub-directory again. */
  259. status = fx_unicode_directory_create(&ram_disk, directory_name, length, (CHAR *) destination_name);
  260. /* Check for expected error. */
  261. if (status != FX_ALREADY_CREATED)
  262. {
  263. /* Error creating unicode directory name. Return to caller. */
  264. printf("ERROR!\n");
  265. test_control_return(18);
  266. }
  267. /* Ask for the name of something that does not exist to generate an error. */
  268. ul_temp = length;
  269. status = fx_unicode_short_name_get(&ram_disk, does_not_exist, length, (CHAR *) destination_name);
  270. if (status == FX_SUCCESS)
  271. {
  272. printf("ERROR!\n");
  273. test_control_return(19);
  274. }
  275. status = fx_unicode_name_get(&ram_disk, (CHAR *) does_not_exist, destination_name, &length);
  276. if (status == FX_SUCCESS)
  277. {
  278. printf("ERROR!\n");
  279. test_control_return(20);
  280. }
  281. length = ul_temp;
  282. /* Now, pickup the short name for the unicode directory so we can set the default path there and
  283. do the same thing from a sub-directory. */
  284. status = fx_unicode_short_name_get(&ram_disk, directory_name, length, (CHAR *) destination_name);
  285. status += fx_directory_default_set(&ram_disk, (CHAR *) destination_name);
  286. length = fx_unicode_length_get(short_unicode_name);
  287. status = fx_unicode_file_create(&ram_disk, short_unicode_name, length, (CHAR *) destination_name);
  288. length = fx_unicode_length_get(long_unicode_name);
  289. status += fx_unicode_file_create(&ram_disk, long_unicode_name, length, (CHAR *) destination_name);
  290. status += fx_file_create(&ram_disk, "abcdefghijklmnop");
  291. length = fx_unicode_length_get(directory_name);
  292. status += fx_unicode_directory_create(&ram_disk, directory_name, length, (CHAR *) destination_name);
  293. status += fx_file_create(&ram_disk, "qrstuvwxyz");
  294. status += fx_media_flush(&ram_disk);
  295. /* Check for erros. */
  296. if (status != FX_SUCCESS)
  297. {
  298. /* Error creating unicode file and directory names in a sub-directory. Return to caller. */
  299. printf("ERROR!\n");
  300. test_control_return(21);
  301. }
  302. /* Test the short/long name get routines with the short unicode name. */
  303. length = fx_unicode_length_get(short_unicode_name);
  304. status += fx_unicode_short_name_get(&ram_disk, short_unicode_name, length, (CHAR *) destination_name);
  305. status += fx_unicode_name_get(&ram_disk, (CHAR *) destination_name, destination_name, &length);
  306. /* Check for errors. */
  307. if ((status) || (length != fx_unicode_length_get(short_unicode_name)))
  308. {
  309. /* Error getting unicode file and short names in a sub-directory. Return to caller. */
  310. printf("ERROR!\n");
  311. test_control_return(22);
  312. }
  313. /* Test the short/long name get routines with the long unicode name. */
  314. length = fx_unicode_length_get(long_unicode_name);
  315. status += fx_unicode_short_name_get(&ram_disk, long_unicode_name, length, (CHAR *) destination_name);
  316. status += fx_unicode_name_get(&ram_disk, (CHAR *) destination_name, destination_name, &length);
  317. /* Check for errors. */
  318. if ((status) || (length != fx_unicode_length_get(long_unicode_name)))
  319. {
  320. /* Error getting unicode file and short names in a sub-directory. Return to caller. */
  321. printf("ERROR!\n");
  322. test_control_return(23);
  323. }
  324. /* Test the short/long name get routines with the directory unicode name. */
  325. length = fx_unicode_length_get(directory_name);
  326. status += fx_unicode_short_name_get(&ram_disk, directory_name, length, (CHAR *) destination_name);
  327. status += fx_unicode_name_get(&ram_disk, (CHAR *) destination_name, destination_name, &length);
  328. /* Check for errors. */
  329. if ((status) || (length != fx_unicode_length_get(directory_name)))
  330. {
  331. /* Error getting unicode file and short names in a sub-directory. Return to caller. */
  332. printf("ERROR!\n");
  333. test_control_return(24);
  334. }
  335. /* Now delete everything in the sub-directory. */
  336. status += fx_unicode_short_name_get(&ram_disk, directory_name, length, (CHAR *) destination_name);
  337. status += fx_directory_delete(&ram_disk, (CHAR *) destination_name);
  338. status += fx_file_delete(&ram_disk, "qrstuvwxyz");
  339. status += fx_file_delete(&ram_disk, "abcdefghijklmnop");
  340. length = fx_unicode_length_get(long_unicode_name);
  341. status += fx_unicode_short_name_get(&ram_disk, long_unicode_name, length, (CHAR *) destination_name);
  342. status += fx_file_delete(&ram_disk, (CHAR *) destination_name);
  343. length = fx_unicode_length_get(short_unicode_name);
  344. status += fx_unicode_short_name_get(&ram_disk, short_unicode_name, length, (CHAR *) destination_name);
  345. status += fx_file_delete(&ram_disk, (CHAR *) destination_name);
  346. /* Check for erros. */
  347. if (status != FX_SUCCESS)
  348. {
  349. /* Error deleting unicode file and directory names in a sub-directory. Return to caller. */
  350. printf("ERROR!\n");
  351. test_control_return(25);
  352. }
  353. /* Move the directory default back to the root. */
  354. status += fx_directory_default_set(&ram_disk, "/");
  355. /* Test the short/long name get routines with the short unicode name. */
  356. length = fx_unicode_length_get(short_unicode_name);
  357. status += fx_unicode_short_name_get(&ram_disk, short_unicode_name, length, (CHAR *) destination_name);
  358. status += fx_unicode_name_get(&ram_disk, (CHAR *) destination_name, destination_name, &length);
  359. /* Check for errors. */
  360. if ((status) || (length != fx_unicode_length_get(short_unicode_name)))
  361. {
  362. /* Error getting unicode file and short names in the root directory. Return to caller. */
  363. printf("ERROR!\n");
  364. test_control_return(26);
  365. }
  366. /* Test the short/long name get routines with the long unicode name. */
  367. length = fx_unicode_length_get(long_unicode_name);
  368. status += fx_unicode_short_name_get(&ram_disk, long_unicode_name, length, (CHAR *) destination_name);
  369. status += fx_unicode_name_get(&ram_disk, (CHAR *) destination_name, destination_name, &length);
  370. /* Check for errors. */
  371. if ((status) || (length != fx_unicode_length_get(long_unicode_name)))
  372. {
  373. /* Error getting unicode file and short names in the root directory. Return to caller. */
  374. printf("ERROR!\n");
  375. test_control_return(27);
  376. }
  377. /* Test the short/long name get routines with the directory unicode name. */
  378. length = fx_unicode_length_get(directory_name);
  379. status += fx_unicode_short_name_get(&ram_disk, directory_name, length, (CHAR *) destination_name);
  380. status += fx_unicode_name_get(&ram_disk, (CHAR *) destination_name, destination_name, &length);
  381. /* Check for errors. */
  382. if ((status) || (length != fx_unicode_length_get(directory_name)))
  383. {
  384. /* Error getting unicode file and short names in the root directory. Return to caller. */
  385. printf("ERROR!\n");
  386. test_control_return(28);
  387. }
  388. /* Delete the root directory contents. */
  389. status += fx_unicode_short_name_get(&ram_disk, directory_name, length, (CHAR *) destination_name);
  390. status += fx_directory_delete(&ram_disk, (CHAR *) destination_name);
  391. status += fx_file_delete(&ram_disk, "qrstuvwxyz");
  392. status += fx_file_delete(&ram_disk, "abcdefghijklmnop");
  393. length = fx_unicode_length_get(long_unicode_name);
  394. status += fx_unicode_short_name_get(&ram_disk, long_unicode_name, length, (CHAR *) destination_name);
  395. status += fx_file_delete(&ram_disk, (CHAR *) destination_name);
  396. length = fx_unicode_length_get(short_unicode_name);
  397. status += fx_unicode_short_name_get(&ram_disk, short_unicode_name, length, (CHAR *) destination_name);
  398. status += fx_file_delete(&ram_disk, (CHAR *) destination_name);
  399. /* Check for errors. */
  400. if (status != FX_SUCCESS)
  401. {
  402. /* Error getting unicode file and short names in the root directory. Return to caller. */
  403. printf("ERROR!\n");
  404. test_control_return(29);
  405. }
  406. length = fx_unicode_length_get(short_unicode_name);
  407. status = fx_unicode_file_create(&ram_disk, short_unicode_name, length, (CHAR*)destination_name);
  408. length = fx_unicode_length_get(long_unicode_name);
  409. status += fx_unicode_file_create(&ram_disk, long_unicode_name, length, (CHAR*)destination_name);
  410. length = fx_unicode_length_get((UCHAR*)"Z\01\02\03\0\0");
  411. status += fx_file_create(&ram_disk, (CHAR*)"test");
  412. /* Check for errors. */
  413. if (status != FX_SUCCESS)
  414. {
  415. /* Error creating unicode files. Return to caller. */
  416. printf("ERROR!\n");
  417. test_control_return(29);
  418. }
  419. length = fx_unicode_length_get(long_unicode_name);
  420. status = fx_unicode_short_name_get_extended(&ram_disk, long_unicode_name, length, (CHAR*)destination_name, 14);
  421. /* Check for error. */
  422. if (status != FX_SUCCESS)
  423. {
  424. /* Error getting short name. Return to caller. */
  425. printf("ERROR!\n");
  426. test_control_return(29);
  427. }
  428. /* Set unicode_temp_long_file_name and length to known state. */
  429. memcpy(unicode_temp_long_file_name, "ORIGINALSTRING", 15);
  430. length = 0;
  431. status = fx_unicode_name_get_extended(&ram_disk, (CHAR*)destination_name, (UCHAR*)unicode_temp_long_file_name, &length, 4);
  432. /* Check for error. */
  433. if ((status != FX_SUCCESS) || (length != 14) || (memcmp(unicode_temp_long_file_name, "\2\0\0\0INALSTRING\0", 15)))
  434. {
  435. /* Error getting short name. Return to caller. */
  436. printf("ERROR!\n");
  437. test_control_return(29);
  438. }
  439. status = fx_unicode_short_name_get_extended(&ram_disk, (UCHAR*)"t\0e\0s\0t\0\0", 4, (CHAR*)destination_name, 14);
  440. /* Check for error. */
  441. if (status != FX_SUCCESS)
  442. {
  443. /* Error getting short name. Return to caller. */
  444. printf("ERROR!\n");
  445. test_control_return(29);
  446. }
  447. /* At the circumstance of the same lenth of unicode name,there are no more than 26 unicode names
  448. with the first character ranging from 'a'to 'z'.If you create one more unicode name, an error will
  449. occur.Now test this case */
  450. length = fx_unicode_length_get(long_unicode_name);
  451. unicode_temp_long_file_name[0] = 'z';
  452. for (i = 1; i < length; i++)
  453. {
  454. /* Build temporary long file name. */
  455. unicode_temp_long_file_name[i] = (UCHAR)('0' + (i % 9));
  456. }
  457. unicode_temp_long_file_name[i] = FX_NULL;
  458. for (i = 1; i < 27; i++)
  459. {
  460. /* creat the same lenth files but Them differ in the first character of file name. */
  461. status = fx_file_create(&ram_disk, (CHAR *)unicode_temp_long_file_name);
  462. if (status)
  463. break;
  464. unicode_temp_long_file_name[0] = (UCHAR)('z' - i);
  465. }
  466. status = fx_unicode_file_create(&ram_disk, long_unicode_name, length, (CHAR *)destination_name);
  467. if (status != FX_ALREADY_CREATED)
  468. {
  469. /* No spare name for unicode file names. Return to caller. */
  470. printf("ERROR!\n");
  471. test_control_return(30);
  472. }
  473. /* Test the unicode length get that exceeds the maximum value. */
  474. for (i = 0; i < 512; i++)
  475. {
  476. buffer[i] = 'A';
  477. }
  478. length = fx_unicode_length_get(buffer);
  479. if (length != 128)
  480. {
  481. printf("ERROR!\n");
  482. test_control_return(31);
  483. }
  484. /* Now test the NULL bytes being in different locations. */
  485. buffer[0] = 0;
  486. buffer[3] = 0;
  487. buffer[8] = 0;
  488. buffer[9] = 0;
  489. length = fx_unicode_length_get(buffer);
  490. if (length != 4)
  491. {
  492. printf("ERROR!\n");
  493. test_control_return(32);
  494. }
  495. /* Close the media. */
  496. status = fx_media_close(&ram_disk);
  497. return_value_if_fail( status == FX_SUCCESS, 33);
  498. /* Open the ram_disk. */
  499. status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, CACHE_SIZE);
  500. return_value_if_fail( status == FX_SUCCESS, 34);
  501. #ifndef FX_ENABLE_FAULT_TOLERANT
  502. /* Register our terrible driver. */
  503. ram_disk.fx_media_driver_entry = _fx_terrible_driver;
  504. short_unicode_name[0]++;
  505. length = fx_unicode_length_get(short_unicode_name);
  506. status = fx_unicode_file_create(&ram_disk, long_unicode_name, length, (CHAR *)destination_name);
  507. ram_disk.fx_media_driver_entry = _fx_ram_driver;
  508. return_value_if_fail( status == FX_IO_ERROR, 35);
  509. #endif /* FX_ENABLE_FAULT_TOLERANT */
  510. /* Close the media. */
  511. status = fx_media_close(&ram_disk);
  512. /* Determine if the test was successful. */
  513. return_value_if_fail( status == FX_SUCCESS, 36);
  514. printf("SUCCESS!\n");
  515. test_control_return(0);
  516. }