summaryrefslogtreecommitdiff
path: root/test.c
AgeCommit message (Collapse)Author
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>
2021-09-07tests: add some slightly better EFIAPI error mocksPeter Jones
This adds more mock functions that just return various EFI error codes in the EFIAPI ABI. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-07tests: link all tests against libefivarPeter Jones
When writing new tests, if we get to the point where we have to use libefivar for something, it's very common that I accidentally link it in twice. When that happens, I typically spend an unfortunate amount of time staring at FLTO's mangled names before I figure out what I've done wrong. This patch makes all the tests link against libefivar, thereby avoiding the issue. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-07-20test: Add a basic traceback printerPeter Jones
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>
2021-07-20test.c: add some simple mock functions for BS->{Allocate,Free}*Peter Jones
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>
2021-07-20Make test cases link against libefi.aPeter Jones
This allows us to use library functions from libefi.a in our test programs. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-07-20test.c: Conditionally do not declare stuff that's in other placesPeter Jones
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>
2021-03-22Make 'make test' work on gcc 4.8.5Peter Jones
2021-03-10Restructure our includes.Peter Jones
This re-structures our includes so we can be sure everything is always including all the system headers in a uniform, predictable way. Temporarily it also adds a bunch of junk at all the places we use variadic functions to specifically pick either the MS (cdecl) or ELF ABIs. I'm not 100% sure that's all correct (see later patch) but it's enough to allow this to build. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-25make 'make test' able to run unit test harnessesPeter Jones
This adds a couple of make targets to do unit tests that are linked to libc: test-FOO : builds and runs test-FOO for any test-FOO.c test : builds and runs all test-FOO tests Note that building and running this test does not quite work yet /on this branch/. In order to do that, we need some cleanups and reorganizing that I don't want to push just yet, which can be found on https://github.com/rhboot/shim/tree/test-reorg Signed-off-by: Peter Jones <pjones@redhat.com>