summaryrefslogtreecommitdiff
path: root/mock-variables.c
AgeCommit message (Collapse)Author
2025-02-24test-mock-variables: improve some debug printsPeter Jones
This changes test-mock-variables and related code to not print all debug messages at SHIM_DEBUG=1, and also adds some prints and comments for context as to what's going on in the tests. Signed-off-by: Peter Jones <pjones@redhat.com>
2025-02-24mock-variables: fix debugging printf format specifier oopsiePeter Jones
This debug printf in our mock variable test code, which isn't normally enabled, has a missing comma at the end of the format specifier. This causes __FILE__ to be part of the format specifier, which then means we've got a missing parameter and also the types don't match up like you'd hope. This causes the most confusing segfaults. Signed-off-by: Peter Jones <pjones@redhat.com>
2025-01-17tests: make it possible to use different limits for variable spacePeter Jones
This splits up the API for setting default usage limits, adding a test API function to set alternate usage limits. Signed-off-by: Peter Jones <pjones@redhat.com>
2025-01-17Make mock_set_variable() correctly account for resource usage.Peter Jones
When SetVariable() is called, currently the test for being out of space is correct, but the accounting is backwards - success adds more space available. This fixes the accounting and (with SHIM_DEBUG) logs the variable size. Signed-off-by: Peter Jones <pjones@redhat.com>
2022-05-04mock-variables.c: fix gcc warningAlexey Kodanev
$ make test ... mock-variables.c: In function 'mock_sv_attrs_match': mock-variables.c:448:23: error: conversion from 'long unsigned int' to 'UINT32' {aka 'unsigned int'} changes value from '18446744073709551551' to '4294967231' [-Werror=overflow] 448 | UINT32 mask = ~EFI_VARIABLE_APPEND_WRITE; | ^ cc1: all warnings being treated as errors Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
2021-09-07tests: Add config table supportPeter Jones
This adds a simple implementation of ST->ConfigurationTable, ST->NumberOfTableEntries, and BS->InstallConfigurationTable to our test harness. Currently it is limited at 1024 entries, but that should be well more than enough for any tests we've currently considered. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-07tests: add pre and post hooks to the mock variable storePeter Jones
For testing of the mok mirroring behavior, we have to be able to account for what variable calls happened and in what order. In order to support that, this patch adds 8 callbacks: mock_set_variable_pre_hook() mock_set_variable_post_hook() mock_get_variable_pre_hook() mock_get_variable_post_hook() mock_get_next_variable_name_pre_hook() mock_get_next_variable_name_post_hook() mock_query_variable_info_pre_hook() mock_query_variable_info_post_hook() The pre hooks each take the same arguments as their mocked namesake, and they fire before any input validation. The post hooks take an additional EFI_STATUS argument. The post hook fires immediately before any return from the mocked namesake function. For SetVariable(), the arguments when the post hook fires are the current contents of the variable if status is EFI_SUCCESS, and whatever arguments were passed in if status is any other value. For everything else, the arguments are the correct results on EFI_SUCCESS, and whatever was passed in if status is any other value. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-07tests: model different behaviors for deleting variablesPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-07tests: add a mock implementation of {Get,Set}Variable and tests for itPeter Jones
Some tests will need variables, and so we need a mock implementation of the various calls relating to them. This patch adds implementations for the EFI Runtime Services calls GetVariable(), SetVariable(), GetNextVariableName(), and QueryVariableInfo(). Additionally, it enforces tunable limits on storage for variables, and (with only a little work) the limits can be different for SetVariable() vs what is returned by QueryVariableInfo(). That is, it can lie to you like real systems do. Signed-off-by: Peter Jones <pjones@redhat.com>