From f0958baa7cc0fcce0de09323d89dda7bf23afec3 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 18 Feb 2025 15:19:21 -0500 Subject: test-mock-variables: improve some debug prints 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 --- test-mock-variables.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'test-mock-variables.c') diff --git a/test-mock-variables.c b/test-mock-variables.c index c7e42b05..79e6628f 100644 --- a/test-mock-variables.c +++ b/test-mock-variables.c @@ -212,14 +212,23 @@ test_gnvn_helper(char *testvars) mock_load_variables(testvars, mok_rt_vars, true); +#if defined(SHIM_DEBUG) && SHIM_DEBUG != 0 + dump_mock_variables(__FILE__, __LINE__, __func__); +#endif + + /* + * This tests the sort policy, filtering for only variables in the + * EFI "global" namespace. If ascending the first thing should + * be Boot0000, if descending it should be dbxDefault + */ +#if defined(SHIM_DEBUG) && SHIM_DEBUG >= 1 + printf("Testing mock variable sorting in the global namespace\n"); +#endif size = sizeof(buf); buf[0] = L'\0'; status = RT->GetNextVariableName(&size, buf, &GV_GUID); assert_equal_goto(status, EFI_SUCCESS, err, "0x%lx != 0x%lx\n"); -#if defined(SHIM_DEBUG) && SHIM_DEBUG != 0 - dump_mock_variables(__FILE__, __LINE__, __func__); -#endif switch (mock_variable_sort_policy) { case MOCK_SORT_DESCENDING: dump_mock_variables_if_wrong(__FILE__, __LINE__, __func__, @@ -236,6 +245,14 @@ test_gnvn_helper(char *testvars) break; } + /* + * Do it again but test for only variables in the Secure Boot + * policy guid namespace. Ascending should be "db", descending + * "dbx". + */ +#if defined(SHIM_DEBUG) && SHIM_DEBUG >= 1 + printf("Testing mock variable sorting in the Secure Boot GUID namespace\n"); +#endif size = sizeof(buf); buf[0] = 0; status = RT->GetNextVariableName(&size, buf, &EFI_SECURE_BOOT_DB_GUID); -- cgit v1.2.3