From 397f820b8c091ca5e3023b6dbd2f26fb256a19f0 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Fri, 23 Jul 2021 14:36:23 -0400 Subject: tests: Add a unit test for mok mirroring Test that our mok mirroring doesn't ever try to delete any variable that it has previously created, and that it properly mirrors at least MokList, MokListX, and SbatLevel, at least when variables actually work. These tests will fail (rather a lot) without 7f64fd6da9458b73c4. Currently valgrind shows a memory leak in this code which is not introduced in this patch series. Since all of our memory is freed on Exit() or when kernel does ExitBootServices(), this doesn't have any significant repercussions. Signed-off-by: Peter Jones --- include/mock-variables.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/mock-variables.h') diff --git a/include/mock-variables.h b/include/mock-variables.h index 759fd1f0..3f282a68 100644 --- a/include/mock-variables.h +++ b/include/mock-variables.h @@ -124,6 +124,21 @@ typedef enum { REPLACE, } mock_variable_op_t; +static inline const char * +format_var_op(mock_variable_op_t op) +{ + static const char *var_op_names[] = { + "NONE", + "CREATE", + "DELETE", + "APPEND", + "REPLACE", + NULL + }; + + return var_op_names[op]; +} + typedef EFI_STATUS (mock_set_variable_pre_hook_t)(CHAR16 *name, EFI_GUID *guid, UINT32 attrs, UINTN size, VOID *data); -- cgit v1.2.3