summaryrefslogtreecommitdiff
path: root/mock-variables.c
AgeCommit message (Collapse)Author
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>