Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for our load options parsing. #390

Merged
merged 11 commits into from
Jul 20, 2021

Conversation

vathpela
Copy link
Contributor

This patchset moves set_second_stage() and its helpers out of shim.c, and adds test-load-options.c, which attempts to comprehensively test the output from the function, including its intended side effects.

This patchset requires that #379 is merged first.

@vathpela vathpela force-pushed the test-load-options branch 10 times, most recently from 64ae119 to 8d0c063 Compare July 15, 2021 18:38
@vathpela vathpela marked this pull request as draft July 15, 2021 22:00
@vathpela vathpela requested a review from chrisccoulson July 15, 2021 22:00
@vathpela vathpela force-pushed the test-load-options branch from 8d0c063 to 2048005 Compare July 15, 2021 22:05
@vathpela vathpela marked this pull request as ready for review July 15, 2021 22:44
vathpela added 11 commits July 20, 2021 09:31
Signed-off-by: Peter Jones <pjones@redhat.com>
pause() is a posix function, and having it named the same as this makes
it hard to include the asm.h header in some test cases.

Signed-off-by: Peter Jones <pjones@redhat.com>
…pes.

Signed-off-by: Peter Jones <pjones@redhat.com>
In some test cases, it's useful to be able to call some of the very
common stuff in gnu-efi's efilib.h (i.e. CompareGuid()), but including
that header itself is too big for me to tackle right now.

This patch adds a few more decls to test.h.

Signed-off-by: Peter Jones <pjones@redhat.com>
test.c duplicates a couple of objects (StrnCmp, StrCmp) that are
in libefi.a, as well as SHIM_LOCK_GUID from lib/guid.o.  While it's nice
to have these at some places, we need to disable them if we're actually
linking a test case against either of those.

This patch adds HAVE_foo guards around those objects.

Signed-off-by: Peter Jones <pjones@redhat.com>
This allows us to use library functions from libefi.a in our test
programs.

Signed-off-by: Peter Jones <pjones@redhat.com>
In some test cases, it may be useful to call libefi.a functions, such as
the device path parsing functions, which allocate pages via
BS->AllocatePool() or BS->AllocatePages.

This patch ads a simple mock implementation of those functions, as well
as the EFI_SYSTEM_TABLE, EFI_BOOT_SERVICES, and EFI_RUNTIME_SERVICES
variables *ST, *BS, and *RT (respectively), and initializes them before
the test cases run.

Signed-off-by: Peter Jones <pjones@redhat.com>
This test helper was conspicuously missing, so this patch just adds it
at the obvious place.

Signed-off-by: Peter Jones <pjones@redhat.com>
Some tests have some complex flows, and it's useful to be able to see
the call path when there's a failure.

This patch adds a very simple traceback printer, along with changing the
test build arguments to include more debug information.

The result you get from this traceback printer just gives you a function
name and the index into its .txt content, so to use it for more than
"which function calls which", you'll need to use eu-addr2line with the
output.

Signed-off-by: Peter Jones <pjones@redhat.com>
This moves set_second_stage() and some of the helper functions it uses
out of shim.c, so that it's easier to write test cases for.

Signed-off-by: Peter Jones <pjones@redhat.com>
This adds tests for all the cases we've documented in the
set_second_stage() comments.  Each test checks that all of second_stage,
loader_str, and loader_str_size are set correctly.

Note that this adds a dependency on libefivar to build device paths to
test against.

Signed-off-by: Peter Jones <pjones@redhat.com>
@vathpela vathpela force-pushed the test-load-options branch from 2048005 to d70c12b Compare July 20, 2021 13:31
@vathpela vathpela merged commit 3ea1f37 into rhboot:main Jul 20, 2021
@vathpela vathpela deleted the test-load-options branch July 20, 2021 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant