summaryrefslogtreecommitdiff
path: root/lib/efi_selftest
AgeCommit message (Collapse)AuthorFilesLines
2019-02-13efi_loader: Make HII a config optionAlexander Graf1-1/+1
Heinrich ran into issues with HII and iPXE which lead to #SErrors on his Odroid-C2 system. We definitely do not want to regress just yet, so let's not expose the HII protocols by default. Instead, let's make it a config option that people can play with This way, we can stabilize the code in tree without breaking any users. Once someone figures out, why this breaks iPXE (probably a NULL dereference), we can enable it by default. Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de> --- v1 -> v2: - Remove HII selftest as well v2 -> v3: - Make config option
2019-02-13efi_selftest: fix HII testsHeinrich Schuchardt1-11/+0
efi_st_printf() does not support format code %ld. Anyway the format code for size_t would be %zu which isn't supported either. We do not want any divisions to avoid invalid references to integer arithmetic routines, cf. https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html. As a simple remedy remove the noisy messages from the output. They are not relevant for automated testing. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: add HII database protocols testAKASHI Takahiro3-0/+1500
This efi_selftest tests HII database protocol and HII string protocol. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: do not use symbolic linksHeinrich Schuchardt1-1/+0
Symbolic links are not supported on all file systems, e.g. not on FAT. So it is not wise to use them in our source tree. Use a qualified path to refer to lib/efi_loader/efi_freestanding.c in scripts/Makefile.lib instead. Reported-by: Alexander Graf <agraf@suse.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: Fix build with O=] Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: use freestanding library for efi appsHeinrich Schuchardt1-0/+1
GCC requires that freestanding programs provide memcpy(), memmove(), memset(), and memcmp(). Add the library functions when building a *.efi files. The EFI selftests might use other compilation flags. So use a symbolic link to provide lib/efi_selftest/efi_freestanding.c and compile it separately. Reported-by: Alexander Graf <agraf@suse.de> Fixes: 5be444d14b38 ("efi_loader: consistent build flags for EFI applications") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: fix variables test for GetNextVariableName()AKASHI Takahiro1-5/+8
There is a bug in efi variables test. Fix it with some cosmetic improvements. Please note that efi variables test still fails at QueryVariableInfo() and GetVariable(), but this is not due to a change in this patch. ==8<== Testing EFI API implementation Selected test: 'variables' Setting up 'variables' Setting up 'variables' succeeded Executing 'variables' .../u-boot/lib/efi_selftest/efi_selftest_variables.c(60): TODO: QueryVariableInfo failed .../u-boot/lib/efi_selftest/efi_selftest_variables.c(131): TODO: GetVariable returned wrong length 7 .../u-boot/lib/efi_selftest/efi_selftest_variables.c(133): TODO: GetVariable returned wrong value Executing 'variables' succeeded Boot services terminated Summary: 0 failures ==>8== Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: consistent build flags for EFI applicationsHeinrich Schuchardt1-2/+2
At the same time adding and removing the -Os flag does not make any sense. Actually it leads to -Os not being used. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: use u16* for file nameHeinrich Schuchardt1-3/+3
UTF-16 strings in our code should all be u16 *. Fix an inconsistency for file names which may lead to a warning for printf("%ls", ). Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: tpl unit test, check return valuesHeinrich Schuchardt1-2/+2
For some API calls checks for the return values are missing. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: events unit test, check return valuesHeinrich Schuchardt1-3/+3
For some API calls checks for the return values are missing. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: SNP unit test on sandboxHeinrich Schuchardt1-0/+8
Running the simple network protocol test on the sandbox requires setting the environment variable ethact to a network interface connected to a DHCP server and ethrotate to 'no'. So let's make it an on-request test on the sandbox (selectable by setting environment variable efi_selftest). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: use const efi_guid_t * for variable servicesHeinrich Schuchardt1-2/+2
The runtime variable services never change GUIDs. So we should declare the GUID parameters as constant. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: allow building on ARMv7-MHeinrich Schuchardt1-3/+3
ARMv7-M only supports the Thumb instruction set. Our current crt0 code does not support it. With the patch we can build all unit tests of the EFI subsystem that do not require crt0. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-23efi_selftest: block device: avoid read after freeHeinrich Schuchardt1-5/+5
Reading the position in a file after closing the same results in a read after free. Correct the sequence in the test. Reported-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_selftest: rename setup_okHeinrich Schuchardt1-4/+4
The variable name setup_ok might suggest a boolean with true indicating OK. Let's avoid the misleading name. %s/setup_ok/setup_status/g Suggested-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_selftest: fix simple network protocol testHeinrich Schuchardt1-8/+8
To use the simple network protocol we have to call the start service first and the initialize service second. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_selftest: check fdt is marked as runtime dataHeinrich Schuchardt1-0/+24
Check that the memory area containing the device tree is marked as runtime data. Update the Python test to pass ${fdtcontroladdr} to bootefi. Update the description of the Python test. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_selftest: building sandbox with EFI_SELFTESTHeinrich Schuchardt1-1/+1
Enable building the sandbox with CONFIG_EFI_SELFTEST. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_selftest: add test for memory allocationHeinrich Schuchardt2-0/+164
This unit test checks the following runtime services: AllocatePages, FreePages, GetMemoryMap Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_selftest: incorrect use of bitwise orHeinrich Schuchardt1-1/+1
We should use a logical or when combining logical values. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_loader: do not use unsupported printf codeHeinrich Schuchardt1-3/+3
Using %zu for efi_intn_t (ssize_t) creates a build warning. Anyway %zu is not supported by efi_st_error(). So let's convert to int. Our implementation of StriColl() only returns -1, 0, or 1. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_selftest: do not write to linker generated arrayHeinrich Schuchardt1-9/+22
Linker generated arrays may be stored in code sections of memory that are not writable. So let's allocate setup_ok as an array at runtime. This avoids an illegal memory access observed in the sandbox. Reported-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_loader: UninstallMultipleProtocolInterfaces error codeHeinrich Schuchardt1-3/+15
If UninstallMultipleProtocolInterfaces fails, we sometimes return the wrong status code. The UEFI spec mandates to always return EFI_INVALID_PARAMETER. Update unit test. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_loader: typedef struct efi_object *efi_handle_tHeinrich Schuchardt1-1/+1
All our handles point to a struct efi_object. So let's define the efi_handle_t accordingly. This helps us to discover coding errors much more easily. This becomes evident by the corrections to the usage of handles in this patch. Rename variable image_handle to image_obj where applicable. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_selftest: fix typosHeinrich Schuchardt11-22/+20
fix typos correct the header comment of efi_selftest_variables.c Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_selftest: test handling of exceptionsHeinrich Schuchardt2-0/+51
Test the handling of execptions by trying to execute an undefined instruction. For 32bit ARM we expect \selftest to be listed as loaded image. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_selftest: simplify lib/efi_selftest/MakefileHeinrich Schuchardt1-8/+2
We should not make anything in lib/efi_selftest if CONFIG_CMD_BOOTEFI_SELFTEST is not defined. We can make that test in lib/Makefile Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-10-16efi_selftest: creating new handle in controller testHeinrich Schuchardt1-0/+2
When the last protocol interface is uninstalled the handle is deleted but this does not set the value of the handle to NULL. To create a new handle with OpenProtocolInterface the value of the handle must be NULL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-10-16efi_loader: correct signature of GetPosition, SetPositionHeinrich Schuchardt1-2/+28
The UEFI spec requires that file positions are passed as u64 in GetPosition() and SetPosition(). Check if the file handle points to a directory in GetPosition(). Provide a unit test for GetPosition() and SetPosition(). Fix Coverity warning CID 184079 (CONSTANT_EXPRESSION_RESULT). Add comments. Fixes: b6dd57773719 ("efi_loader: use correct types in EFI_FILE_PROTOCOL") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_loader: Disable efi selftest on sandbox for nowAlexander Graf1-1/+1
The EFI selftest does not succeed on Sandbox yet. The network support seems to need some love to actually make our current tests succeed. So let's disable running the selftest on sandbox for now until "make tests" just works. Then we can have more amazing CI than ever. Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_selftest: missing braces in efi_selftest_textinputex.cHeinrich Schuchardt1-1/+1
gcc 4.8.4 wants to see all levels of braces when initializing a structure to zeros. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_selftest: test key notification functionsHeinrich Schuchardt1-7/+66
Use a key notification function to leave the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL test. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_selftest: test EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOLHeinrich Schuchardt2-0/+140
Provide a unit test for the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_selftest: use WaitForKey to test text inputHeinrich Schuchardt1-3/+24
We should test the WaitForKey event. Testing for EFI_NOT_READY can be done after resetting the console. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_selftest: refactor text input testHeinrich Schuchardt2-107/+95
Move reusable utility functions to efi_selftest_util.c. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_loader: struct efi_simple_text_input_protocolHeinrich Schuchardt1-1/+1
%s/efi_simple_input_interface/efi_simple_text_input_protocol/ We should be consistent in the naming of the EFI protocol interface structures. The protocol is called EFI_SIMPLE_TEXT_INPUT_PROTOCOL. %s/ExtendedVerification/extended_verification/ Use consistent naming of function parameters. Do not use CamelCase. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_selftest: EFI_UNICODE_COLLATION_PROTOCOLHeinrich Schuchardt2-0/+261
Provide a unit test for the EFI_UNICODE_COLLATION_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_selftest: test for loaded image protocolHeinrich Schuchardt2-0/+109
Verify that the loaded image protocol is installed on the image handle. Verify that the loaded image protocol points to the system table. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_selftest: memory leak testing manage protocolsHeinrich Schuchardt1-2/+19
Remove memory leak in efi_selftest_manageprotocols.c. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-20efi_selftest: correct block device unit testHeinrich Schuchardt1-1/+1
The UEFI specification mandates that the create flag is only used in conjunction with both the read and the write flag. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: unit test for GetTime()Heinrich Schuchardt2-0/+68
Provide a unit test for the GetTime() runtime service. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: support printing leading zeroesHeinrich Schuchardt1-11/+22
Allow specifying the precision when printing integers, e.g. efi_st_printf("%.4u-%.2u-%.2u\n", year, month, day); Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: unit test for CalculateCrc32()Heinrich Schuchardt2-0/+142
This unit test checks the CalculateCrc32 bootservice and checks the headers of the system table, the boot services tablle, and the runtime services table before and after ExitBootServices(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: check crc32 for InstallConfigurationTableHeinrich Schuchardt1-0/+43
InstallConfigurationTable() may change the number of installed configuration tables. Check the crc32 of the system table. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: test InstallConfigurationTable()Heinrich Schuchardt2-0/+224
Provide a unit test for InstallConfigurationTable(). A table is installed, updated, removed. The table entry and the triggering of events is checked. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: test writing to fileHeinrich Schuchardt1-0/+70
Provide a unit test for writing to a FAT file system. Add some additional comments in block device unit test. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: Clean up a few comments and messagesSimon Glass1-8/+6
Fix the 'amp' typo, expand on what 'steps' is and fix a few other minor things. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: Disable miniapps on sandboxAlexander Graf1-1/+1
In the sandbox environment we can not easily build efi stub binaries right now, so let's disable the respective test cases for the efi selftest suite. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: update .gitignoreHeinrich Schuchardt1-1/+3
The following generated files should be ignored by git: efi_miniapp_file_image_exit.h efi_miniapp_file_image_return.h *.so files are normally deleted during the build but should be ignored too. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-06-03SPDX: Fixup tags from latest EFI PRTom Rini1-2/+1
Signed-off-by: Tom Rini <trini@konsulko.com>