summaryrefslogtreecommitdiff
path: root/test-pe-relocate.c
diff options
context:
space:
mode:
authorSteve McIntyre <steve@einval.com>2024-02-17 17:35:37 +0000
committerSteve McIntyre <steve@einval.com>2024-02-17 17:35:37 +0000
commita075e58606b9affb6dfb176c71caab816737a981 (patch)
treecb517fcf059f8d9d9dd7f6860a2d77d75ddc4142 /test-pe-relocate.c
parent2dd2f7600d41253fe621b8d040ab57f0c202d71b (diff)
downloadefi-boot-shim-upstream.tar.gz
efi-boot-shim-upstream.zip
New upstream version 15.8upstream/15.8upstream
Diffstat (limited to 'test-pe-relocate.c')
-rw-r--r--test-pe-relocate.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/test-pe-relocate.c b/test-pe-relocate.c
new file mode 100644
index 00000000..55577791
--- /dev/null
+++ b/test-pe-relocate.c
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+/*
+ * test-pe-reloc.c - attempt to test relocate_coff()
+ * Copyright Peter Jones <pjones@redhat.com>
+ */
+
+#ifndef SHIM_UNIT_TEST
+#define SHIM_UNIT_TEST
+#endif
+#include "shim.h"
+
+static int
+test_image_address(void)
+{
+ char image[4];
+ void *ret;
+
+ assert_equal_return(ImageAddress(image, sizeof(image), 0), &image[0], -1, "got %p expected %p\n");
+ assert_equal_return(ImageAddress(image, sizeof(image), 4), NULL, -1, "got %p expected %p\n");
+ assert_equal_return(ImageAddress((void *)1, 2, 3), NULL, -1, "got %p expected %p\n");
+ assert_equal_return(ImageAddress((void *)-1ull, UINT64_MAX, UINT64_MAX), NULL, -1, "got %p expected %p\n");
+ assert_equal_return(ImageAddress((void *)0, UINT64_MAX, UINT64_MAX), NULL, -1, "got %p expected %p\n");
+ assert_equal_return(ImageAddress((void *)1, UINT64_MAX, UINT64_MAX), NULL, -1, "got %p expected %p\n");
+ assert_equal_return(ImageAddress((void *)2, UINT64_MAX, UINT64_MAX), NULL, -1, "got %p expected %p\n");
+ assert_equal_return(ImageAddress((void *)3, UINT64_MAX, UINT64_MAX), NULL, -1, "got %p expected %p\n");
+
+ return 0;
+}
+
+int
+main(void)
+{
+ int status = 0;
+ test(test_image_address);
+
+ return status;
+}
+
+// vim:fenc=utf-8:tw=75:noet