1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited
7 * Test HII database protocols
10 #include <efi_selftest.h>
11 #include "efi_selftest_hii_data.c"
13 #define PRINT_TESTNAME efi_st_printf("%s:\n", __func__)
15 static struct efi_boot_services *boottime;
17 static const efi_guid_t hii_database_protocol_guid =
18 EFI_HII_DATABASE_PROTOCOL_GUID;
19 static const efi_guid_t hii_string_protocol_guid =
20 EFI_HII_STRING_PROTOCOL_GUID;
22 static struct efi_hii_database_protocol *hii_database_protocol;
23 static struct efi_hii_string_protocol *hii_string_protocol;
28 * @handle: handle of the loaded image
29 * @systable: system table
31 * Return: EFI_ST_SUCCESS for success
33 static int setup(const efi_handle_t handle,
34 const struct efi_system_table *systable)
38 boottime = systable->boottime;
40 /* HII database protocol */
41 ret = boottime->locate_protocol(&hii_database_protocol_guid, NULL,
42 (void **)&hii_database_protocol);
43 if (ret != EFI_SUCCESS) {
44 hii_database_protocol = NULL;
45 efi_st_error("HII database protocol is not available.\n");
46 return EFI_ST_FAILURE;
49 /* HII string protocol */
50 ret = boottime->locate_protocol(&hii_string_protocol_guid, NULL,
51 (void **)&hii_string_protocol);
52 if (ret != EFI_SUCCESS) {
53 hii_string_protocol = NULL;
54 efi_st_error("HII string protocol is not available.\n");
55 return EFI_ST_FAILURE;
58 return EFI_ST_SUCCESS;
62 * HII database protocol tests
66 * test_hii_database_new_package_list() - test creation and removal of
69 * This test adds a new package list and then tries to remove it using
70 * the provided handle.
72 * @Return: status code
74 static int test_hii_database_new_package_list(void)
76 efi_hii_handle_t handle;
80 ret = hii_database_protocol->new_package_list(hii_database_protocol,
81 (struct efi_hii_package_list_header *)packagelist1,
83 if (ret != EFI_SUCCESS || !handle) {
84 efi_st_error("new_package_list returned %u\n",
86 return EFI_ST_FAILURE;
89 ret = hii_database_protocol->remove_package_list(hii_database_protocol,
91 if (ret != EFI_SUCCESS) {
92 efi_st_error("remove_package_list returned %u\n",
94 return EFI_ST_FAILURE;
97 return EFI_ST_SUCCESS;
101 * test_hii_database_update_package_list() - test update of package list
103 * This test adds a new package list and then tries to update it using
104 * another package list.
106 * @Return: status code
108 static int test_hii_database_update_package_list(void)
110 efi_hii_handle_t handle = NULL;
112 int result = EFI_ST_FAILURE;
115 ret = hii_database_protocol->new_package_list(hii_database_protocol,
116 (struct efi_hii_package_list_header *)packagelist1,
118 if (ret != EFI_SUCCESS || !handle) {
119 efi_st_error("new_package_list returned %u\n",
121 return EFI_ST_FAILURE;
124 ret = hii_database_protocol->update_package_list(hii_database_protocol,
126 (struct efi_hii_package_list_header *)packagelist2);
127 if (ret != EFI_SUCCESS || !handle) {
128 efi_st_error("new_package_list returned %u\n",
133 result = EFI_ST_SUCCESS;
137 ret = hii_database_protocol->remove_package_list(
138 hii_database_protocol, handle);
139 if (ret != EFI_SUCCESS) {
140 efi_st_error("remove_package_list returned %u\n",
142 return EFI_ST_FAILURE;
150 * test_hii_database_list_package_lists() - test listing of package lists
152 * This test adds two package lists and then tries to enumerate them
153 * against different package types. We will get an array of handles.
155 * @Return: status code
157 static int test_hii_database_list_package_lists(void)
159 efi_hii_handle_t handle1 = NULL, handle2 = NULL, *handles;
160 efi_uintn_t handles_size;
162 int result = EFI_ST_FAILURE;
165 ret = hii_database_protocol->new_package_list(hii_database_protocol,
166 (struct efi_hii_package_list_header *)packagelist1,
168 if (ret != EFI_SUCCESS || !handle1) {
169 efi_st_error("new_package_list returned %u\n",
174 ret = hii_database_protocol->new_package_list(hii_database_protocol,
175 (struct efi_hii_package_list_header *)packagelist2,
177 if (ret != EFI_SUCCESS || !handle2) {
178 efi_st_error("new_package_list returned %u\n",
186 ret = hii_database_protocol->list_package_lists(hii_database_protocol,
187 EFI_HII_PACKAGE_TYPE_ALL, NULL,
188 &handles_size, handles);
189 if (ret != EFI_BUFFER_TOO_SMALL) {
190 efi_st_error("list_package_lists returned %u\n",
194 ret = boottime->allocate_pool(EFI_LOADER_DATA, handles_size,
196 if (ret != EFI_SUCCESS) {
197 efi_st_error("AllocatePool failed\n");
200 ret = hii_database_protocol->list_package_lists(hii_database_protocol,
201 EFI_HII_PACKAGE_TYPE_ALL, NULL,
202 &handles_size, handles);
203 if (ret != EFI_SUCCESS) {
204 efi_st_error("list_package_lists returned %u\n",
208 ret = boottime->free_pool(handles);
209 if (ret != EFI_SUCCESS) {
210 efi_st_error("FreePool failed\n");
217 ret = hii_database_protocol->list_package_lists(hii_database_protocol,
218 EFI_HII_PACKAGE_STRINGS, NULL,
219 &handles_size, handles);
220 if (ret != EFI_BUFFER_TOO_SMALL) {
221 efi_st_error("list_package_lists returned %u\n",
225 ret = boottime->allocate_pool(EFI_LOADER_DATA, handles_size,
227 if (ret != EFI_SUCCESS) {
228 efi_st_error("AllocatePool failed\n");
231 ret = hii_database_protocol->list_package_lists(hii_database_protocol,
232 EFI_HII_PACKAGE_STRINGS, NULL,
233 &handles_size, handles);
234 if (ret != EFI_SUCCESS) {
235 efi_st_error("list_package_lists returned %u\n",
239 ret = boottime->free_pool(handles);
240 if (ret != EFI_SUCCESS) {
241 efi_st_error("FreePool failed\n");
248 ret = hii_database_protocol->list_package_lists(hii_database_protocol,
249 EFI_HII_PACKAGE_TYPE_GUID, &package_guid,
250 &handles_size, handles);
251 if (ret != EFI_BUFFER_TOO_SMALL) {
252 efi_st_error("list_package_lists returned %u\n",
256 ret = boottime->allocate_pool(EFI_LOADER_DATA, handles_size,
258 if (ret != EFI_SUCCESS) {
259 efi_st_error("AllocatePool failed\n");
262 ret = hii_database_protocol->list_package_lists(hii_database_protocol,
263 EFI_HII_PACKAGE_TYPE_GUID, &package_guid,
264 &handles_size, handles);
265 if (ret != EFI_SUCCESS) {
266 efi_st_error("list_package_lists returned %u\n",
270 ret = boottime->free_pool(handles);
271 if (ret != EFI_SUCCESS) {
272 efi_st_error("FreePool failed\n");
276 /* KEYBOARD_LAYOUT */
279 ret = hii_database_protocol->list_package_lists(hii_database_protocol,
280 EFI_HII_PACKAGE_KEYBOARD_LAYOUT, NULL,
281 &handles_size, handles);
282 if (ret != EFI_BUFFER_TOO_SMALL) {
283 efi_st_error("list_package_lists returned %u\n",
287 ret = boottime->allocate_pool(EFI_LOADER_DATA, handles_size,
289 if (ret != EFI_SUCCESS) {
290 efi_st_error("AllocatePool failed\n");
293 ret = hii_database_protocol->list_package_lists(hii_database_protocol,
294 EFI_HII_PACKAGE_KEYBOARD_LAYOUT, NULL,
295 &handles_size, handles);
296 if (ret != EFI_SUCCESS) {
297 efi_st_error("list_package_lists returned %u\n",
301 ret = boottime->free_pool(handles);
302 if (ret != EFI_SUCCESS) {
303 efi_st_error("FreePool failed\n");
307 result = EFI_ST_SUCCESS;
311 ret = hii_database_protocol->remove_package_list(
312 hii_database_protocol, handle1);
313 if (ret != EFI_SUCCESS)
314 efi_st_error("remove_package_list returned %u\n",
318 ret = hii_database_protocol->remove_package_list(
319 hii_database_protocol, handle2);
320 if (ret != EFI_SUCCESS)
321 efi_st_error("remove_package_list returned %u\n",
329 * test_hii_database_export_package_lists() - test export of package lists
331 * @Return: status code
333 static int test_hii_database_export_package_lists(void)
336 /* export_package_lists() not implemented yet */
337 return EFI_ST_SUCCESS;
341 * test_hii_database_register_package_notify() - test registration of
342 * notification function
344 * @Return: status code
346 static int test_hii_database_register_package_notify(void)
349 /* register_package_notify() not implemented yet */
350 return EFI_ST_SUCCESS;
354 * test_hii_database_unregister_package_notify() - test removal of
355 * notification function
357 * @Return: status code
359 static int test_hii_database_unregister_package_notify(void)
362 /* unregsiter_package_notify() not implemented yet */
363 return EFI_ST_SUCCESS;
367 * test_hii_database_find_keyboard_layouts() - test listing of
368 * all the keyboard layouts in the system
370 * This test adds two package lists, each of which has two keyboard layouts
371 * and then tries to enumerate them. We will get an array of handles.
373 * @Return: status code
375 static int test_hii_database_find_keyboard_layouts(void)
377 efi_hii_handle_t handle1 = NULL, handle2 = NULL;
381 int result = EFI_ST_FAILURE;
384 ret = hii_database_protocol->new_package_list(hii_database_protocol,
385 (struct efi_hii_package_list_header *)packagelist1,
387 if (ret != EFI_SUCCESS || !handle1) {
388 efi_st_error("new_package_list returned %u\n",
393 ret = hii_database_protocol->new_package_list(hii_database_protocol,
394 (struct efi_hii_package_list_header *)packagelist2,
396 if (ret != EFI_SUCCESS || !handle2) {
397 efi_st_error("new_package_list returned %u\n",
404 ret = hii_database_protocol->find_keyboard_layouts(
405 hii_database_protocol, &guids_size, guids);
406 if (ret != EFI_BUFFER_TOO_SMALL) {
407 efi_st_error("find_keyboard_layouts returned %u\n",
411 ret = boottime->allocate_pool(EFI_LOADER_DATA, guids_size,
413 if (ret != EFI_SUCCESS) {
414 efi_st_error("AllocatePool failed\n");
417 ret = hii_database_protocol->find_keyboard_layouts(
418 hii_database_protocol, &guids_size, guids);
419 if (ret != EFI_SUCCESS) {
420 efi_st_error("find_keyboard_layouts returned %u\n",
424 ret = boottime->free_pool(guids);
425 if (ret != EFI_SUCCESS) {
426 efi_st_error("FreePool failed\n");
430 result = EFI_ST_SUCCESS;
434 ret = hii_database_protocol->remove_package_list(
435 hii_database_protocol, handle1);
436 if (ret != EFI_SUCCESS)
437 efi_st_error("remove_package_list returned %u\n",
441 ret = hii_database_protocol->remove_package_list(
442 hii_database_protocol, handle2);
443 if (ret != EFI_SUCCESS)
444 efi_st_error("remove_package_list returned %u\n",
452 * test_hii_database_get_keyboard_layout() - test retrieval of keyboard layout
454 * This test adds two package lists, each of which has two keyboard layouts
455 * and then tries to get a handle to keyboard layout with a specific guid
456 * and the current one.
458 * @Return: status code
460 static int test_hii_database_get_keyboard_layout(void)
462 efi_hii_handle_t handle1 = NULL, handle2 = NULL;
463 struct efi_hii_keyboard_layout *kb_layout;
466 int result = EFI_ST_FAILURE;
469 ret = hii_database_protocol->new_package_list(hii_database_protocol,
470 (struct efi_hii_package_list_header *)packagelist1,
472 if (ret != EFI_SUCCESS || !handle1) {
473 efi_st_error("new_package_list returned %u\n",
478 ret = hii_database_protocol->new_package_list(hii_database_protocol,
479 (struct efi_hii_package_list_header *)packagelist2,
481 if (ret != EFI_SUCCESS || !handle2) {
482 efi_st_error("new_package_list returned %u\n",
487 /* specific keyboard_layout(guid11) */
490 ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol,
491 &kb_layout_guid11, &kb_layout_size, kb_layout);
492 if (ret != EFI_BUFFER_TOO_SMALL) {
493 efi_st_error("get_keyboard_layout returned %u\n",
497 ret = boottime->allocate_pool(EFI_LOADER_DATA, kb_layout_size,
498 (void **)&kb_layout);
499 if (ret != EFI_SUCCESS) {
500 efi_st_error("AllocatePool failed\n");
503 ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol,
504 &kb_layout_guid11, &kb_layout_size, kb_layout);
505 if (ret != EFI_SUCCESS) {
506 efi_st_error("get_keyboard_layout returned %u\n",
510 ret = boottime->free_pool(kb_layout);
511 if (ret != EFI_SUCCESS) {
512 efi_st_error("FreePool failed\n");
519 ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol,
520 NULL, &kb_layout_size, kb_layout);
521 if (ret != EFI_INVALID_PARAMETER) {
522 efi_st_error("get_keyboard_layout returned %u\n",
527 result = EFI_ST_SUCCESS;
531 ret = hii_database_protocol->remove_package_list(
532 hii_database_protocol, handle1);
533 if (ret != EFI_SUCCESS)
534 efi_st_error("remove_package_list returned %u\n",
538 ret = hii_database_protocol->remove_package_list(
539 hii_database_protocol, handle2);
540 if (ret != EFI_SUCCESS)
541 efi_st_error("remove_package_list returned %u\n",
549 * test_hii_database_set_keyboard_layout() - test change of
550 * current keyboard layout
552 * @Return: status code
554 static int test_hii_database_set_keyboard_layout(void)
560 /* Invalid key guid. */
561 ret = hii_database_protocol->set_keyboard_layout(
562 hii_database_protocol, NULL);
563 if (ret != EFI_INVALID_PARAMETER) {
564 efi_st_error("set_keyboard_layout returned %u not invalid\n",
566 return EFI_ST_FAILURE;
569 /* set_keyboard_layout() not implemented yet */
570 return EFI_ST_SUCCESS;
574 * test_hii_database_get_package_list_handle() - test retrieval of
575 * driver associated with a package list
577 * This test adds a package list, and then tries to get a handle to driver
578 * which is associated with a package list.
580 * @Return: status code
582 static int test_hii_database_get_package_list_handle(void)
584 efi_hii_handle_t handle = NULL;
585 efi_handle_t driver_handle;
587 int result = EFI_ST_FAILURE;
590 driver_handle = (efi_handle_t)0x12345678; /* dummy */
591 ret = hii_database_protocol->new_package_list(hii_database_protocol,
592 (struct efi_hii_package_list_header *)packagelist1,
593 driver_handle, &handle);
594 if (ret != EFI_SUCCESS || !handle) {
595 efi_st_error("new_package_list returned %u\n",
597 return EFI_ST_FAILURE;
600 driver_handle = NULL;
601 ret = hii_database_protocol->get_package_list_handle(
602 hii_database_protocol, handle, &driver_handle);
603 if (ret != EFI_SUCCESS || driver_handle != (efi_handle_t)0x12345678) {
604 efi_st_error("get_package_list_handle returned %u, driver:%p\n",
605 (unsigned int)ret, driver_handle);
609 result = EFI_ST_SUCCESS;
613 ret = hii_database_protocol->remove_package_list(
614 hii_database_protocol, handle);
615 if (ret != EFI_SUCCESS) {
616 efi_st_error("remove_package_list returned %u\n",
618 return EFI_ST_FAILURE;
625 static int test_hii_database_protocol(void)
629 ret = test_hii_database_new_package_list();
630 if (ret != EFI_ST_SUCCESS)
631 return EFI_ST_FAILURE;
633 ret = test_hii_database_update_package_list();
634 if (ret != EFI_ST_SUCCESS)
635 return EFI_ST_FAILURE;
637 ret = test_hii_database_list_package_lists();
638 if (ret != EFI_ST_SUCCESS)
639 return EFI_ST_FAILURE;
641 ret = test_hii_database_export_package_lists();
642 if (ret != EFI_ST_SUCCESS)
643 return EFI_ST_FAILURE;
645 ret = test_hii_database_register_package_notify();
646 if (ret != EFI_ST_SUCCESS)
647 return EFI_ST_FAILURE;
649 ret = test_hii_database_unregister_package_notify();
650 if (ret != EFI_ST_SUCCESS)
651 return EFI_ST_FAILURE;
653 ret = test_hii_database_find_keyboard_layouts();
654 if (ret != EFI_ST_SUCCESS)
655 return EFI_ST_FAILURE;
657 ret = test_hii_database_get_keyboard_layout();
658 if (ret != EFI_ST_SUCCESS)
659 return EFI_ST_FAILURE;
661 ret = test_hii_database_set_keyboard_layout();
662 if (ret != EFI_ST_SUCCESS)
663 return EFI_ST_FAILURE;
665 ret = test_hii_database_get_package_list_handle();
666 if (ret != EFI_ST_SUCCESS)
667 return EFI_ST_FAILURE;
669 return EFI_ST_SUCCESS;
673 * HII string protocol tests
677 * test_hii_string_new_string() - test creation of a new string entry
679 * This test adds a package list, and then tries to add a new string
680 * entry for a specific language.
682 * @Return: status code
684 static int test_hii_string_new_string(void)
686 efi_hii_handle_t handle = NULL;
689 int result = EFI_ST_FAILURE;
692 ret = hii_database_protocol->new_package_list(hii_database_protocol,
693 (struct efi_hii_package_list_header *)packagelist1,
695 if (ret != EFI_SUCCESS || !handle) {
696 efi_st_error("new_package_list returned %u\n",
698 return EFI_ST_FAILURE;
701 ret = hii_string_protocol->new_string(hii_string_protocol, handle,
703 u"Japanese", u"Japanese", NULL);
704 if (ret != EFI_SUCCESS) {
705 efi_st_error("new_string returned %u\n",
709 efi_st_printf("new string id is %u\n", id);
711 result = EFI_ST_SUCCESS;
715 ret = hii_database_protocol->remove_package_list(
716 hii_database_protocol, handle);
717 if (ret != EFI_SUCCESS) {
718 efi_st_error("remove_package_list returned %u\n",
720 return EFI_ST_FAILURE;
728 * test_hii_string_get_string() - test retrieval of a string entry
730 * This test adds a package list, create a new string entry and then tries
731 * to get it with its string id.
733 * @Return: status code
735 static int test_hii_string_get_string(void)
737 efi_hii_handle_t handle = NULL;
740 efi_uintn_t string_len;
742 int result = EFI_ST_FAILURE;
745 ret = hii_database_protocol->new_package_list(hii_database_protocol,
746 (struct efi_hii_package_list_header *)packagelist1,
748 if (ret != EFI_SUCCESS || !handle) {
749 efi_st_error("new_package_list returned %u\n",
751 return EFI_ST_FAILURE;
754 ret = hii_string_protocol->new_string(hii_string_protocol, handle,
756 u"Japanese", u"Japanese", NULL);
757 if (ret != EFI_SUCCESS) {
758 efi_st_error("new_string returned %u\n",
765 ret = hii_string_protocol->get_string(hii_string_protocol,
766 (u8 *)"en-US", handle, id, string, &string_len, NULL);
767 if (ret != EFI_BUFFER_TOO_SMALL) {
768 efi_st_error("get_string returned %u\n",
772 string_len += sizeof(u16);
773 ret = boottime->allocate_pool(EFI_LOADER_DATA, string_len,
775 if (ret != EFI_SUCCESS) {
776 efi_st_error("AllocatePool failed\n");
779 ret = hii_string_protocol->get_string(hii_string_protocol,
780 (u8 *)"en-US", handle, id, string, &string_len, NULL);
781 if (ret != EFI_SUCCESS) {
782 efi_st_error("get_string returned %u\n",
787 if (efi_st_strcmp_16_8(string, "Japanese")) {
788 efi_st_error("get_string returned incorrect string\n");
792 result = EFI_ST_SUCCESS;
796 ret = hii_database_protocol->remove_package_list(
797 hii_database_protocol, handle);
798 if (ret != EFI_SUCCESS) {
799 efi_st_error("remove_package_list returned %u\n",
801 return EFI_ST_FAILURE;
809 * test_hii_string_set_string() - test change of a string entry
811 * This test adds a package list, create a new string entry and then tries
814 * @Return: status code
816 static int test_hii_string_set_string(void)
818 efi_hii_handle_t handle = NULL;
821 int result = EFI_ST_FAILURE;
824 ret = hii_database_protocol->new_package_list(hii_database_protocol,
825 (struct efi_hii_package_list_header *)packagelist1,
827 if (ret != EFI_SUCCESS || !handle) {
828 efi_st_error("new_package_list returned %u\n",
830 return EFI_ST_FAILURE;
833 ret = hii_string_protocol->new_string(hii_string_protocol, handle,
835 u"Japanese", u"Japanese", NULL);
836 if (ret != EFI_SUCCESS) {
837 efi_st_error("new_string returned %u\n",
842 ret = hii_string_protocol->set_string(hii_string_protocol, handle,
845 if (ret != EFI_SUCCESS) {
846 efi_st_error("set_string returned %u\n",
851 result = EFI_ST_SUCCESS;
855 ret = hii_database_protocol->remove_package_list(
856 hii_database_protocol, handle);
857 if (ret != EFI_SUCCESS) {
858 efi_st_error("remove_package_list returned %u\n",
860 return EFI_ST_FAILURE;
868 * test_hii_string_get_languages() - test listing of languages
870 * This test adds a package list, and then tries to enumerate languages
871 * in it. We will get an string of language names.
873 * @Return: status code
875 static int test_hii_string_get_languages(void)
877 efi_hii_handle_t handle = NULL;
879 efi_uintn_t languages_len;
881 int result = EFI_ST_FAILURE;
884 ret = hii_database_protocol->new_package_list(hii_database_protocol,
885 (struct efi_hii_package_list_header *)packagelist1,
887 if (ret != EFI_SUCCESS || !handle) {
888 efi_st_error("new_package_list returned %u\n",
890 return EFI_ST_FAILURE;
895 ret = hii_string_protocol->get_languages(hii_string_protocol, handle,
896 languages, &languages_len);
897 if (ret != EFI_BUFFER_TOO_SMALL) {
898 efi_st_error("get_languages returned %u\n",
902 ret = boottime->allocate_pool(EFI_LOADER_DATA, languages_len,
903 (void **)&languages);
904 if (ret != EFI_SUCCESS) {
905 efi_st_error("AllocatePool failed\n");
908 ret = hii_string_protocol->get_languages(hii_string_protocol, handle,
909 languages, &languages_len);
910 if (ret != EFI_SUCCESS) {
911 efi_st_error("get_languages returned %u\n",
916 efi_st_printf("Available languages: %s\n", languages);
918 result = EFI_ST_SUCCESS;
922 ret = hii_database_protocol->remove_package_list(
923 hii_database_protocol, handle);
924 if (ret != EFI_SUCCESS) {
925 efi_st_error("remove_package_list returned %u\n",
927 return EFI_ST_FAILURE;
935 * test_hii_string_get_secondary_languages() - test listing of secondary
938 * This test adds a package list, and then tries to enumerate secondary
939 * languages with a specific language. We will get an string of language names.
941 * @Return: status code
943 static int test_hii_string_get_secondary_languages(void)
945 efi_hii_handle_t handle = NULL;
947 efi_uintn_t languages_len;
949 int result = EFI_ST_FAILURE;
952 ret = hii_database_protocol->new_package_list(hii_database_protocol,
953 (struct efi_hii_package_list_header *)packagelist1,
955 if (ret != EFI_SUCCESS || !handle) {
956 efi_st_error("new_package_list returned %u\n",
958 return EFI_ST_FAILURE;
963 ret = hii_string_protocol->get_secondary_languages(hii_string_protocol,
964 handle, (u8 *)"en-US", languages, &languages_len);
965 if (ret == EFI_NOT_FOUND) {
966 efi_st_printf("no secondary languages\n");
967 result = EFI_ST_SUCCESS;
970 if (ret != EFI_BUFFER_TOO_SMALL) {
971 efi_st_error("get_secondary_languages returned %u\n",
975 ret = boottime->allocate_pool(EFI_LOADER_DATA, languages_len,
976 (void **)&languages);
977 if (ret != EFI_SUCCESS) {
978 efi_st_error("AllocatePool failed\n");
981 ret = hii_string_protocol->get_secondary_languages(hii_string_protocol,
982 handle, (u8 *)"en-US", languages, &languages_len);
983 if (ret != EFI_SUCCESS) {
984 efi_st_error("get_secondary_languages returned %u\n",
989 efi_st_printf("got secondary languages are %s\n", languages);
991 result = EFI_ST_SUCCESS;
995 ret = hii_database_protocol->remove_package_list(
996 hii_database_protocol, handle);
997 if (ret != EFI_SUCCESS) {
998 efi_st_error("remove_package_list returned %u\n",
1000 return EFI_ST_FAILURE;
1007 static int test_hii_string_protocol(void)
1011 ret = test_hii_string_new_string();
1012 if (ret != EFI_ST_SUCCESS)
1013 return EFI_ST_FAILURE;
1015 ret = test_hii_string_get_string();
1016 if (ret != EFI_ST_SUCCESS)
1017 return EFI_ST_FAILURE;
1019 ret = test_hii_string_set_string();
1020 if (ret != EFI_ST_SUCCESS)
1021 return EFI_ST_FAILURE;
1023 ret = test_hii_string_get_languages();
1024 if (ret != EFI_ST_SUCCESS)
1025 return EFI_ST_FAILURE;
1027 ret = test_hii_string_get_secondary_languages();
1028 if (ret != EFI_ST_SUCCESS)
1029 return EFI_ST_FAILURE;
1031 return EFI_ST_SUCCESS;
1035 * Execute unit test.
1037 * Return: EFI_ST_SUCCESS for success, EFI_ST_FAILURE for failure
1039 static int execute(void)
1043 /* HII database protocol */
1044 ret = test_hii_database_protocol();
1045 if (ret != EFI_ST_SUCCESS)
1046 return EFI_ST_FAILURE;
1048 /* HII string protocol */
1049 ret = test_hii_string_protocol();
1050 if (ret != EFI_ST_SUCCESS)
1051 return EFI_ST_FAILURE;
1053 return EFI_ST_SUCCESS;
1056 EFI_UNIT_TEST(hii) = {
1057 .name = "HII database protocols",
1058 .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,