Hello Anna Karaś,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/44669
to review the following change.
Change subject: tests: Add lib/imd-test test case ......................................................................
tests: Add lib/imd-test test case
Implement unit tests for src/lib/imd.c module.
Signed-off-by: Anna Karas aka@semihalf.com Signed-off-by: Jan Dabros jsd@semihalf.com Change-Id: I9d3ab45c3da2a21c910f52a84526b60c39ff1fe7 --- M tests/lib/Makefile.inc A tests/lib/imd-test.c 2 files changed, 813 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/44669/1
diff --git a/tests/lib/Makefile.inc b/tests/lib/Makefile.inc index b66d386..3062bca 100644 --- a/tests/lib/Makefile.inc +++ b/tests/lib/Makefile.inc @@ -3,6 +3,7 @@ tests-y += string-test tests-y += b64_decode-test tests-y += hexstrtobin-test +tests-y += imd-test
string-test-srcs += tests/lib/string-test.c string-test-srcs += src/lib/string.c @@ -13,3 +14,7 @@
hexstrtobin-test-srcs += tests/lib/hexstrtobin-test.c hexstrtobin-test-srcs += src/lib/hexstrtobin.c + +imd-test-srcs += tests/lib/imd-test.c +imd-test-srcs += tests/stubs/console.c +imd-test-srcs += src/lib/imd.c \ No newline at end of file diff --git a/tests/lib/imd-test.c b/tests/lib/imd-test.c new file mode 100644 index 0000000..01a9e19 --- /dev/null +++ b/tests/lib/imd-test.c @@ -0,0 +1,808 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <imd.h> +#include <cbmem.h> +#include <stdlib.h> +#include <stdio.h> +#include <types.h> +#include <tests/test.h> +#include <limits.h> +#include <commonlib/bsd/helpers.h> + +void *calloc(size_t nitems, size_t size); +void *memset(void * ptr, int value, size_t num); + +/* In-memory data structures. */ +struct imd_root_pointer { + uint32_t magic; + /* Relative to upper limit/offset. */ + int32_t root_offset; +} __packed; + +struct imd_entry { + uint32_t magic; + /* start is located relative to imd_root */ + int32_t start_offset; + uint32_t size; + uint32_t id; +} __packed; + +struct imd_root { + uint32_t max_entries; + uint32_t num_entries; + uint32_t flags; + uint32_t entry_align; + /* Used for fixing the size of an imd. Relative to the root. */ + int32_t max_offset; + struct imd_entry entries[0]; +} __packed; + +/* Auxiliary functions and definitions. */ + +#define CBMEM_ID_IMD_ROOT 0xff4017ff +#define CBMEM_ID_IMD_SMALL 0x53a11439 + +#define IMD_FLAG_LOCKED 1 + +const uint32_t IMD_ROOT_PTR_MAGIC = 0xc0389481; +const uint32_t IMD_ENTRY_MAGIC = ~0xc0389481; +const uint32_t SMALL_REGION_ID = CBMEM_ID_IMD_SMALL; + +#define LIMIT_SZ (LIMIT_ALIGN + 1) +#define RP_SZ sizeof(struct imd_root_pointer) +#define ROOT_SZ sizeof(struct imd_root) +#define ENTRY_SZ sizeof(struct imd_entry) +#define IMD_SZ sizeof(struct imd) +#define CURSOR_SZ sizeof(struct imd_cursor) + +#define LG_ROOT_SIZE align_up_pow2(sizeof(struct imd_root_pointer) +\ + sizeof(struct imd_root) + 3 * sizeof(struct imd_entry)) +#define LG_ENTRY_ALIGN (2 * sizeof(int32_t)) +#define LG_ENTRY_SIZE (2 * sizeof(int32_t)) +#define LG_ENTRY_ID 0xA001 + +#define SM_ROOT_SIZE LG_ROOT_SIZE +#define SM_ENTRY_ALIGN sizeof(uint32_t) +#define SM_ENTRY_SIZE sizeof(uint32_t) +#define SM_ENTRY_ID 0xB001 + +uint32_t align_up_pow2(uint32_t x) { + return (IS_POWER_OF_2(x) ? x : 1 << (32 - __builtin_clz(x - 1))); +} + +size_t max_entries(size_t root_size) { + return (root_size - RP_SZ - ROOT_SZ) / ENTRY_SZ; +} + +/* + * Mainly, we should check that imd_handle_init() aligns upper_limit properly + * for various inputs. Upper limit is the _exclusive_ address, so we expect + * ALIGN_DOWN. + */ +static void test_imd_handle_init(void **state) +{ + int i; + void *base; + struct imd imd; + uintptr_t test_inputs[] = {0, 0xDEAA, 0xF0F0F0F0, ((1ULL << 32) + 4), + ((1ULL << 60) - 100)}; + + for (i = 0; i < ARRAY_SIZE(test_inputs); i++) { + base = (void *)test_inputs[i]; + + imd_handle_init(&imd, (void *)base); + + assert_int_equal(imd.lg.limit % LIMIT_ALIGN, 0); + assert_int_equal(imd.lg.limit, ALIGN_DOWN(test_inputs[i], LIMIT_ALIGN)); + assert_ptr_equal(imd.lg.r, NULL); + + /* Small allocations not initialized */ + assert_ptr_equal(imd.sm.limit, NULL); + assert_ptr_equal(imd.sm.r, NULL); + } +} + +static void test_imd_handle_init_partial_recovery(void **state) +{ + void *base; + struct imd imd = {0}; + const struct imd_entry *entry; + struct imdr *imdr; + struct imd_root *r; + + imd_handle_init_partial_recovery(&imd); + assert_null(imd.lg.limit); + assert_null(imd.sm.limit); + + base = malloc(LIMIT_SZ); + if (base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)base)); + imd_handle_init_partial_recovery(&imd); + + assert_non_null(imd.lg.r); + assert_null(imd.sm.limit); + + assert_int_equal(0, imd_create_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN)); + entry = imd_entry_add(&imd, SMALL_REGION_ID, LG_ENTRY_SIZE); + assert_non_null(entry); + + imd_handle_init_partial_recovery(&imd); + + assert_non_null(imd.lg.r); + assert_non_null(imd.sm.limit); + + imdr = &imd.lg; + r = (struct imd_root *) (imdr->r); + + assert_ptr_equal(((void *)r + entry->start_offset + LG_ENTRY_SIZE), imd.sm.limit); + assert_non_null(imd.sm.r); + + free(base); +} + +static void test_imd_create_empty(void **state) +{ + struct imd imd = {0}; + void *base; + struct imdr *imdr; + struct imd_root *r; + struct imd_entry *e; + + /* Expect failure, since imd handle is not initialized */ + assert_int_equal(-1, imd_create_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN)); + base = malloc(sizeof(struct imd_root_pointer) + sizeof(struct imd_root)); + if (base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)base)); + + /* Try incorrect sizes */ + assert_int_equal(-1, imd_create_empty(&imd, sizeof(struct imd_root_pointer) + + sizeof(struct imd_root), LG_ENTRY_ALIGN)); + assert_int_equal(-1, imd_create_empty(&imd, LG_ROOT_SIZE, 2 * LG_ROOT_SIZE)); + + /* Working case */ + assert_int_equal(0, imd_create_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN)); + + /* Only large allocation initialized with one entry for the root region */ + imdr = &imd.lg; + r = (struct imd_root *) (imdr->r); + assert_non_null(r); + + e = &r->entries[r->num_entries - 1]; + + assert_int_equal(max_entries(LG_ROOT_SIZE), r->max_entries); + assert_int_equal(1, r->num_entries); + assert_int_equal(0, r->flags); + assert_int_equal(LG_ENTRY_ALIGN, r->entry_align); + assert_int_equal(0, r->max_offset); + assert_ptr_equal(e, &r->entries); + + assert_int_equal(IMD_ENTRY_MAGIC, e->magic); + assert_int_equal(0, e->start_offset); + assert_int_equal(LG_ROOT_SIZE, e->size); + assert_int_equal(CBMEM_ID_IMD_ROOT, e->id); + + free(base); +} + +static void test_imd_create_tiered_empty(void **state) +{ + void *base; + size_t sm_region_size, lg_region_wrong_size; + struct imd imd = {0}; + struct imd_root *r; + struct imd_entry *fst_lg_entry, *snd_lg_entry, *sm_entry; + + /* Uninitialized imd handle */ + assert_int_equal(-1, imd_create_tiered_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN, + LG_ROOT_SIZE, SM_ENTRY_ALIGN)); + + base = malloc(LIMIT_SZ); + if (base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)base)); + + /* Too small root_size for small region */ + assert_int_equal(-1, imd_create_tiered_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN, + sizeof(int32_t), 2 * sizeof(int32_t))); + + /* Fail when large region doesn't have capacity for more than 1 entry */ + lg_region_wrong_size = sizeof(struct imd_root_pointer) + sizeof(struct imd_root) + + sizeof(struct imd_entry); + assert_int_equal(-1, imd_create_tiered_empty(&imd, lg_region_wrong_size, + LG_ENTRY_ALIGN, SM_ROOT_SIZE, + SM_ENTRY_ALIGN)); + + assert_int_equal(0, imd_create_tiered_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN, + SM_ROOT_SIZE, SM_ENTRY_ALIGN)); + + r = imd.lg.r; + + /* One entry for root_region and one for small allocations */ + assert_int_equal(2, r->num_entries); + + fst_lg_entry = &r->entries[0]; + assert_int_equal(IMD_ENTRY_MAGIC, fst_lg_entry->magic); + assert_int_equal(0, fst_lg_entry->start_offset); + assert_int_equal(LG_ROOT_SIZE, fst_lg_entry->size); + assert_int_equal(CBMEM_ID_IMD_ROOT, fst_lg_entry->id); + + sm_region_size = SM_ROOT_SIZE - RP_SZ - ROOT_SZ; + sm_region_size /= ENTRY_SZ; + sm_region_size *= SM_ENTRY_ALIGN; + sm_region_size += SM_ROOT_SIZE; + sm_region_size = ALIGN_UP(sm_region_size, LG_ENTRY_ALIGN); + + snd_lg_entry = &r->entries[1]; + assert_int_equal(IMD_ENTRY_MAGIC, snd_lg_entry->magic); + assert_int_equal(-sm_region_size, snd_lg_entry->start_offset); + assert_int_equal(CBMEM_ID_IMD_SMALL, snd_lg_entry->id); + + assert_int_equal(sm_region_size, snd_lg_entry->size); + + r = imd.sm.r; + assert_int_equal(1, r->num_entries); + + sm_entry = &r->entries[0]; + assert_int_equal(IMD_ENTRY_MAGIC, sm_entry->magic); + assert_int_equal(0, sm_entry->start_offset); + assert_int_equal(SM_ROOT_SIZE, sm_entry->size); + assert_int_equal(CBMEM_ID_IMD_ROOT, sm_entry->id); + + free(base); +} + +/* Tests for imdr_recover. */ +static void test_imd_recover(void **state) +{ + int32_t offset_copy; + uint32_t rp_magic_copy, num_entries_copy, e_magic_copy; + uint32_t size_copy, diff; + void *base; + struct imd imd = {0}; + struct imdr *imdr; + struct imd_root_pointer *rp; + struct imd_root *r; + struct imd_entry *lg_root_entry, *sm_root_entry, *ptr; + const struct imd_entry *lg_entry; + + /* Fail when the limit for lg was not set. */ + imdr = &imd.lg; + imdr->limit = (uintptr_t) NULL; + assert_int_equal(-1, imd_recover(&imd)); + + /* Set the limit for lg. */ + base = malloc(LIMIT_SZ); + if (base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)base)); + + /* Fail when the root pointer is not valid. */ + rp = (void *)imdr->limit - RP_SZ; + assert_non_null(rp); + + rp_magic_copy = rp->magic; + rp->magic = 0; + assert_int_equal(-1, imd_recover(&imd)); + rp->magic = rp_magic_copy; + + /* Set the root pointer. */ + assert_int_equal(0, imd_create_tiered_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN, + SM_ROOT_SIZE, SM_ENTRY_ALIGN)); + r = imd.lg.r; + assert_int_equal(2, r->num_entries); + r = imd.sm.r; + assert_int_equal(1, r->num_entries); + r = imd.lg.r; + + /* Fail if the number of entries exceeds the maximum number of entries. */ + num_entries_copy = r->num_entries; + r->num_entries = r->max_entries + 1; + assert_int_equal(-1, imd_recover(&imd)); + r->num_entries = num_entries_copy; + + /* Fail if entry align is not a power of 2. */ + r->entry_align += 1; + assert_int_equal(-1, imd_recover(&imd)); + r->entry_align--; + + + /* Fail when an entry is not valid. */ + lg_root_entry = &r->entries[0]; + e_magic_copy = lg_root_entry->magic; + lg_root_entry->magic = 0; + assert_int_equal(-1, imd_recover(&imd)); + lg_root_entry->magic = e_magic_copy; + + /* Add new entries: large and small. */ + lg_entry = imd_entry_add(&imd, LG_ENTRY_ID, LG_ENTRY_SIZE); + assert_non_null(lg_entry); + assert_int_equal(3, r->num_entries); + + assert_non_null(imd_entry_add(&imd, SM_ENTRY_ID, SM_ENTRY_SIZE)); + r = imd.sm.r; + assert_int_equal(2, r->num_entries); + r = imd.lg.r; + + /* Fail when start_addr is lower than low_limit. */ + r->max_offset = lg_entry->start_offset + sizeof(int32_t); + assert_int_equal(-1, imd_recover(&imd)); + r->max_offset = 0; + + /* Fail when start_addr is at least imdr->limit. */ + offset_copy = lg_entry->start_offset; + ptr = (struct imd_entry *)lg_entry; + ptr->start_offset = (void *)imdr->limit - (void *)r; + assert_int_equal(-1, imd_recover(&imd)); + ptr->start_offset = offset_copy; + + /* Fail when (start_addr + e->size) is higher than imdr->limit. */ + size_copy = lg_entry->size; + diff = (void *)imdr->limit - ((void *)r + lg_entry->start_offset); + ptr->size = diff + 1; + assert_int_equal(-1, imd_recover(&imd)); + ptr->size = size_copy; + + /* End of tests for imdr_recover(). */ + + /* Succeed if small region is not present. */ + sm_root_entry = &r->entries[1]; + sm_root_entry->id = 0; + assert_int_equal(0, imd_recover(&imd)); + sm_root_entry->id = SMALL_REGION_ID; + + /* Continue if small region is present. */ + assert_int_equal(0, imd_recover(&imd)); + + free(base); +} + +static void test_imd_limit_size(void **state) +{ + void *base; + struct imd imd = {0}; + size_t root_size, max_size; + struct imdr *imdr; + + max_size = align_up_pow2(RP_SZ + ROOT_SZ + 3 * ENTRY_SZ); + + assert_int_equal(-1, imd_limit_size(&imd, max_size)); + + base = malloc(LIMIT_SZ); + if (base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)base)); + + imdr = &imd.lg; + root_size = align_up_pow2(RP_SZ + ROOT_SZ + 2 * ENTRY_SZ); + imdr->r = (void *)imdr->limit - root_size; + + imd_create_empty(&imd, root_size, LG_ENTRY_ALIGN); + assert_int_equal(-1, imd_limit_size(&imd, root_size - 1)); + assert_int_equal(0, imd_limit_size(&imd, max_size)); + + /* Cannot create such a big entry */ + assert_null(imd_entry_add(&imd, LG_ENTRY_ID, max_size - root_size + 1)); + + free(base); +} + +static void test_imd_lockdown(void **state) +{ + struct imd imd = {0}; + struct imdr *imdr; + struct imd_root *r_lg, *r_sm; + + assert_int_equal(-1, imd_lockdown(&imd)); + + imdr = &imd.lg; + imdr->r = malloc(ROOT_SZ); + if (imdr->r == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + + r_lg = (struct imd_root *) (imdr->r); + + assert_int_equal(0, imd_lockdown(&imd)); + assert_true(r_lg->flags & IMD_FLAG_LOCKED); + + imdr = &imd.sm; + imdr->r = malloc(ROOT_SZ); + if (imdr->r == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + r_sm = (struct imd_root *) (imdr->r); + + assert_int_equal(0, imd_lockdown(&imd)); + assert_true(r_sm->flags & IMD_FLAG_LOCKED); + + free(imd.lg.r); + free(imd.sm.r); +} + +static void test_imd_region_used(void **state) +{ + struct imd imd = {0}; + struct imd_entry *first_entry, *new_entry; + struct imdr *imdr; + struct imd_root *r; + size_t size; + void *imd_base; + void *base; + + assert_int_equal(-1, imd_region_used(&imd, &base, &size)); + + imd_base = malloc(LIMIT_SZ); + if (imd_base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)imd_base)); + + assert_int_equal(-1, imd_region_used(&imd, &base, &size)); + assert_int_equal(0, imd_create_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN)); + assert_int_equal(0, imd_region_used(&imd, &base, &size)); + + imdr = &imd.lg; + r = (struct imd_root *) (imdr->r); + first_entry = &r->entries[r->num_entries - 1]; + + assert_int_equal(r + first_entry->start_offset, (uintptr_t)base); + assert_int_equal(first_entry->size, size); + + assert_non_null(imd_entry_add(&imd, LG_ENTRY_ID, LG_ENTRY_SIZE)); + assert_int_equal(2, r->num_entries); + + assert_int_equal(0, imd_region_used(&imd, &base, &size)); + + new_entry = &r->entries[r->num_entries - 1]; + + assert_true((void *)r + new_entry->start_offset == base); + assert_int_equal(first_entry->size + new_entry->size, size); + + free(imd_base); +} + +static void test_imd_entry_add(void **state) +{ + int i; + struct imd imd = {0}; + size_t entry_size = 0; + size_t used_size; + ssize_t entry_offset; + void *base; + struct imd_root *r, *sm_r, *lg_r; + struct imd_entry *first_entry, *new_entry; +__unused struct imd_root_pointer *rp; + + /* No small region case. */ + assert_null(imd_entry_add(&imd, LG_ENTRY_ID, entry_size)); + + base = malloc(LIMIT_SZ); + if (base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)base)); + + assert_int_equal(0, imd_create_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN)); + + r = (struct imd_root *)imd.lg.r; + first_entry = &r->entries[r->num_entries - 1]; + + /* Fail when root is locked. */ + r->flags = IMD_FLAG_LOCKED; + assert_null(imd_entry_add(&imd, LG_ENTRY_ID, entry_size)); + r->flags = 0; + + /* Fail when the maximum number of entries has been reached. */ + r->num_entries = r->max_entries; + assert_null(imd_entry_add(&imd, LG_ENTRY_ID, entry_size)); + r->num_entries = 1; + + /* Fail when entry size is 0 */ + assert_null(imd_entry_add(&imd, LG_ENTRY_ID, 0)); + + /* Fail when entry size (after alignment) overflows imd total size. */ + entry_size = 2049; + r->max_offset = -entry_size; + assert_null(imd_entry_add(&imd, LG_ENTRY_ID, entry_size)); + r->max_offset = 0; + entry_size = 2 * sizeof(int32_t); + + /* Finally succeed. */ + assert_non_null(imd_entry_add(&imd, LG_ENTRY_ID, entry_size)); + assert_int_equal(2, r->num_entries); + + new_entry = &r->entries[r->num_entries - 1]; + assert_int_equal(ENTRY_SZ, (void *)new_entry - (void *)first_entry); + + assert_int_equal(IMD_ENTRY_MAGIC, new_entry->magic); + assert_int_equal(LG_ENTRY_ID, new_entry->id); + assert_int_equal(entry_size, new_entry->size); + + used_size = ALIGN_UP(entry_size, r->entry_align); + entry_offset = first_entry->start_offset - used_size; + assert_int_equal(entry_offset, new_entry->start_offset); + + /* Use small region case. */ + imd_create_tiered_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN, SM_ROOT_SIZE, + SM_ENTRY_ALIGN); + + lg_r = imd.lg.r; + sm_r = imd.sm.r; + + /* All five new entries should be added to small allocations */ + for (i = 0; i < 5; i++) { + assert_non_null(imd_entry_add(&imd, SM_ENTRY_ID, SM_ENTRY_SIZE)); + assert_int_equal(i+2, sm_r->num_entries); + assert_int_equal(2, lg_r->num_entries); + } + + /* But next should fall back on large region */ + assert_non_null(imd_entry_add(&imd, SM_ENTRY_ID, SM_ENTRY_SIZE)); + assert_int_equal(6, sm_r->num_entries); + assert_int_equal(3, lg_r->num_entries); + + /* + * Small allocation is created when occupies less than 1/4 of available + * small region. Verify this. + */ + imd_create_tiered_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN, SM_ROOT_SIZE, + SM_ENTRY_ALIGN); + + assert_non_null(imd_entry_add(&imd, SM_ENTRY_ID, -sm_r->max_offset / 4 + 1)); + assert_int_equal(1, sm_r->num_entries); + assert_int_equal(3, lg_r->num_entries); + + /* Next two should go into small region */ + assert_non_null(imd_entry_add(&imd, SM_ENTRY_ID, -sm_r->max_offset / 4)); + assert_int_equal(2, sm_r->num_entries); + assert_int_equal(3, lg_r->num_entries); + + /* (1/4 * 3/4) */ + assert_non_null(imd_entry_add(&imd, SM_ENTRY_ID, -sm_r->max_offset / 16 * 3)); + assert_int_equal(3, sm_r->num_entries); + assert_int_equal(3, lg_r->num_entries); + + free(base); +} + +static void test_imd_entry_find(void **state) +{ + struct imd imd = {0}; + void *base; + + base = malloc(LIMIT_SZ); + if (base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)base)); + + assert_int_equal(0, imd_create_tiered_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN, + SM_ROOT_SIZE, SM_ENTRY_ALIGN)); + + assert_non_null(imd_entry_add(&imd, LG_ENTRY_ID, LG_ENTRY_SIZE)); + + assert_non_null(imd_entry_find(&imd, LG_ENTRY_ID)); + assert_non_null(imd_entry_find(&imd, SMALL_REGION_ID)); + + /* Try random id, should fail */ + assert_null(imd_entry_find(&imd, 0xC001)); + + free(base); +} + +static void test_imd_entry_find_or_add(void **state) +{ + struct imd imd = {0}; + const struct imd_entry *entry; + struct imd_root *r; + void *base; + + base = malloc(LIMIT_SZ); + if (base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)base)); + + assert_null(imd_entry_find_or_add(&imd, LG_ENTRY_ID, LG_ENTRY_SIZE)); + + assert_int_equal(0, imd_create_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN)); + entry = imd_entry_find_or_add(&imd, LG_ENTRY_ID, LG_ENTRY_SIZE); + assert_non_null(entry); + + r = (struct imd_root *)imd.lg.r; + + assert_int_equal(entry->id, LG_ENTRY_ID); + assert_int_equal(2, r->num_entries); + assert_non_null(imd_entry_find_or_add(&imd, LG_ENTRY_ID, LG_ENTRY_SIZE)); + assert_int_equal(2, r->num_entries); + + free(base); +} + +static void test_imd_entry_size(void **state) +{ + struct imd_entry entry = { .size = LG_ENTRY_SIZE }; + + assert_int_equal(LG_ENTRY_SIZE, imd_entry_size(&entry)); + + entry.size = 0; + assert_int_equal(0, imd_entry_size(&entry)); +} + +static void test_imd_entry_at(void **state) +{ + struct imd imd = {0}; + struct imd_root *r; + struct imd_entry *e = NULL; + const struct imd_entry *entry; + void *base; + + base = malloc(LIMIT_SZ); + if (base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)base)); + + assert_int_equal(0, imd_create_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN)); + + /* Fail when entry is NULL */ + assert_null(imd_entry_at(&imd, e)); + + entry = imd_entry_add(&imd, LG_ENTRY_ID, LG_ENTRY_SIZE); + assert_non_null(entry); + + r = (struct imd_root *) (imd.lg.r); + assert_ptr_equal((void *)r + entry->start_offset, imd_entry_at(&imd, entry)); + + free(base); +} + +static void test_imd_entry_id(void **state) +{ + struct imd_entry entry = { .id = LG_ENTRY_ID }; + + assert_int_equal(LG_ENTRY_ID, imd_entry_id(&entry)); +} + +static void test_imd_entry_remove(void **state) +{ + void *base; + struct imd imd = {0}; + struct imd_root *r; + const struct imd_entry *fst_lg_entry, *snd_lg_entry, *fst_sm_entry; + const struct imd_entry *e = NULL; + + /* Uninitialized handle */ + assert_int_equal(-1, imd_entry_remove(&imd, e)); + + base = malloc(LIMIT_SZ); + if (base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)base)); + + assert_int_equal(0, imd_create_tiered_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN, + LG_ROOT_SIZE, SM_ENTRY_ALIGN)); + + r = imd.lg.r; + assert_int_equal(2, r->num_entries); + fst_lg_entry = &r->entries[0]; + snd_lg_entry = &r->entries[1]; + + /* Only last entry can be removed */ + assert_int_equal(-1, imd_entry_remove(&imd, fst_lg_entry)); + + r->flags = IMD_FLAG_LOCKED; + assert_int_equal(-1, imd_entry_remove(&imd, snd_lg_entry)); + r->flags = 0; + + r = imd.sm.r; + assert_int_equal(1, r->num_entries); + fst_sm_entry = &r->entries[0]; + + /* Fail trying to remove root entry */ + assert_int_equal(-1, imd_entry_remove(&imd, fst_sm_entry)); + assert_int_equal(1, r->num_entries); + + r = imd.lg.r; + assert_int_equal(0, imd_entry_remove(&imd, snd_lg_entry)); + assert_int_equal(1, r->num_entries); + + /* Fail trying to remove root entry */ + assert_int_equal(-1, imd_entry_remove(&imd, fst_lg_entry)); + assert_int_equal(1, r->num_entries); + + free(base); +} + +static void test_imd_cursor_init(void **state) +{ + struct imd imd = {0}; + struct imd_cursor cursor; + + assert_int_equal(-1, imd_cursor_init(NULL, NULL)); + assert_int_equal(-1, imd_cursor_init(NULL, &cursor)); + assert_int_equal(-1, imd_cursor_init(&imd, NULL)); + assert_int_equal(0, imd_cursor_init(&imd, &cursor)); + + assert_ptr_equal(cursor.imdr[0], &imd.lg); + assert_ptr_equal(cursor.imdr[1], &imd.sm); +} + +static void test_imd_cursor_next(void **state) +{ + void *base; + struct imd imd = {0}; + struct imd_cursor cursor; + struct imd_root *r; + const struct imd_entry *entry; + struct imd_entry *fst_lg_entry, *snd_lg_entry, *fst_sm_entry; + assert_int_equal(0, imd_cursor_init(&imd, &cursor)); + + cursor.current_imdr = 3; + cursor.current_entry = 0; + assert_null(imd_cursor_next(&cursor)); + + cursor.current_imdr = 0; + assert_null(imd_cursor_next(&cursor)); + + base = malloc(LIMIT_SZ); + if (base == NULL) + fail_msg("Cannot allocate enough memory - fail test"); + imd_handle_init(&imd, (void *)(LIMIT_SZ + (uintptr_t)base)); + + assert_int_equal(0, imd_create_tiered_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN, + SM_ROOT_SIZE, SM_ENTRY_ALIGN)); + + r = imd.lg.r; + entry = imd_cursor_next(&cursor); + assert_non_null(entry); + + fst_lg_entry = &r->entries[0]; + assert_int_equal(fst_lg_entry->id, entry->id); + assert_ptr_equal(fst_lg_entry, entry); + + entry = imd_cursor_next(&cursor); + assert_non_null(entry); + + snd_lg_entry = &r->entries[1]; + assert_int_equal(snd_lg_entry->id, entry->id); + assert_ptr_equal(snd_lg_entry, entry); + + entry = imd_cursor_next(&cursor); + assert_non_null(entry); + + r = imd.sm.r; + fst_sm_entry = &r->entries[0]; + assert_int_equal(fst_sm_entry->id, entry->id); + assert_ptr_equal(fst_sm_entry, entry); + + entry = imd_cursor_next(&cursor); + assert_null(entry); +} + +int main(void) +{ + const struct CMUnitTest tests[] = { + cmocka_unit_test(test_imd_handle_init), + cmocka_unit_test(test_imd_handle_init_partial_recovery), + cmocka_unit_test(test_imd_create_empty), + cmocka_unit_test(test_imd_create_tiered_empty), + cmocka_unit_test(test_imd_recover), + cmocka_unit_test(test_imd_limit_size), + cmocka_unit_test(test_imd_lockdown), + cmocka_unit_test(test_imd_region_used), + cmocka_unit_test(test_imd_entry_add), + cmocka_unit_test(test_imd_entry_find), + cmocka_unit_test(test_imd_entry_find_or_add), + cmocka_unit_test(test_imd_entry_size), + cmocka_unit_test(test_imd_entry_at), + cmocka_unit_test(test_imd_entry_id), + cmocka_unit_test(test_imd_entry_remove), + cmocka_unit_test(test_imd_cursor_init), + cmocka_unit_test(test_imd_cursor_next), + }; + + return cmocka_run_group_tests(tests, NULL, NULL); +} +
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
Patch Set 1:
(4 comments)
https://review.coreboot.org/c/coreboot/+/44669/1/tests/lib/imd-test.c File tests/lib/imd-test.c:
https://review.coreboot.org/c/coreboot/+/44669/1/tests/lib/imd-test.c@13 PS1, Line 13: void *memset(void * ptr, int value, size_t num); "foo * bar" should be "foo *bar"
https://review.coreboot.org/c/coreboot/+/44669/1/tests/lib/imd-test.c@69 PS1, Line 69: uint32_t align_up_pow2(uint32_t x) { open brace '{' following function definitions go on the next line
https://review.coreboot.org/c/coreboot/+/44669/1/tests/lib/imd-test.c@70 PS1, Line 70: return (IS_POWER_OF_2(x) ? x : 1 << (32 - __builtin_clz(x - 1))); return is not a function, parentheses are not required
https://review.coreboot.org/c/coreboot/+/44669/1/tests/lib/imd-test.c@73 PS1, Line 73: size_t max_entries(size_t root_size) { open brace '{' following function definitions go on the next line
Hello build bot (Jenkins), Anna Karaś, Furquan Shaikh, Patrick Georgi, Martin Roth, Paul Menzel, Paul Fagerburg, Julius Werner,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/44669
to look at the new patch set (#2).
Change subject: tests: Add lib/imd-test test case ......................................................................
tests: Add lib/imd-test test case
Implement unit tests for src/lib/imd.c module.
Signed-off-by: Anna Karas aka@semihalf.com Signed-off-by: Jan Dabros jsd@semihalf.com Change-Id: I9d3ab45c3da2a21c910f52a84526b60c39ff1fe7 --- M tests/lib/Makefile.inc A tests/lib/imd-test.c 2 files changed, 815 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/44669/2
Paul Fagerburg has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
Patch Set 2:
(5 comments)
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c File tests/lib/imd-test.c:
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@89 PS2, Line 89: uintptr_t test_inputs[] = {0, 0xDEAA, 0xF0F0F0F0, ((1ULL << 32) + 4), Consider adding comments for each of these as to why the values were chosen, e.g. uintptr_t test_inputs[] = { 0, /* Lowest possible address */ 0xDEAA, /* Fits in 16 bits */ 0xF0F0F0F0, /* Fits in 32 bits */ ((1ULL << 32) + 4), /* Just above 32-bit limit */ ((1ULL << 60) - 100) /* Very large, but still fits in 64-bit address space */ };
as well as noting which ones will get rounded down by LIMIT_ALIGN. And you should have at least one case (other than 0) which does not get rounded down by LIMIT_ALIGN.
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@155 PS2, Line 155: /* Expect failure, since imd handle is not initialized */ "Expect imd_create_empty to fail, since ...
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@236 PS2, Line 236: sm_region_size = SM_ROOT_SIZE - RP_SZ - ROOT_SZ; Can you explain what you're doing here?
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@299 PS2, Line 299: r = imd.lg.r; : assert_int_equal(2, r->num_entries); I know it's more verbose, but assert_int_equal(2, imd.lg.r->num_entries); would be a little more clear. By using r to point to imd.lg or imd.sm, you're introducing the possibility for error if people add or remove code.
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@495 PS2, Line 495: /* Fail when root is locked. */ Consider saying "Cannot add an entry when root is locked" as that explains the specific thing that fails.
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
Patch Set 2:
(6 comments)
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c File tests/lib/imd-test.c:
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@9 PS2, Line 9: #include <limits.h> What do you need this for? I can't see anything that needs it but I may have missed something.
In general, I think we probably need to be more careful with mixing glibc headers and coreboot headers together, because it is very dangerous. coreboot headers always take precedence, so if you add a dependency on say glibc's <limits.h> here now and then later we want to add a <limits.h> to coreboot that maybe not covers the whole POSIX-required range of definitions, things will break. Even worse, maybe glibc internally decides that <limits.h> should include something else like <stddef.h> to include something that glibc knows are in its own <stddef.h>, but it doesn't know that it would actually get coreboot's version with that include which might not contain what it needs. These kinds of things could change randomly between glibc versions and break things.
In fact, I wonder if we should just build tests with -nostdinc to completely ensure we can't have these issues. Cmocka needs some libc features, but thankfully it's all compiled separately so we could compile that with glibc headers but the tests themselves without them. Only expect_assert_failure() with setjmp() is a problem, unfortunately... to make that work the part calling setjmp() would also have to be hidden in a .c file that is compiled and linked separately. I guess that could be tone if <tests/test.h> does an #undef expect_assert_failure() and replaces it with our own, though a bit hacky.
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@13 PS2, Line 13: void *memset(void *ptr, int value, size_t num); For these kinds of cases I would suggest to centralize them rather than than defining them manually in every test. You could put them in #include <tests/libc/stdlib.h> or something like that. (memset() is provided by coreboot's <string.h>, btw, so you could just include that instead of providing it separately.)
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@38 PS2, Line 38: } __packed; Let's not duplicate all of this stuff, let's just factor them out from the code under test into a separate header (e.g. src/include/imd_private.h or something). (I know I usually say coreboot code shouldn't need to change to conform to tests, but factoring out definitions should be simple and harmless enough.)
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@43 PS2, Line 43: #define CBMEM_ID_IMD_SMALL 0x53a11439 Don't you get these from cbmem.h already?
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@56 PS2, Line 56: #define CURSOR_SZ sizeof(struct imd_cursor) Not sure why you have all of these rather than using sizeof() directly in the code? Not sure they really make things easier to follow...
You also use sizeof() for all these same things directly in the code in many places, please at least decide to do one or the other and then do that consistently.
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@69 PS2, Line 69: uint32_t align_up_pow2(uint32_t x) You can just use (1 << log2_ceil(x)) from coreboot's <lib.h>.
Name of user not set #1003143 has uploaded a new patch set (#3) to the change originally created by Jan Dabros. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
tests: Add lib/imd-test test case
Implement unit tests for src/lib/imd.c module.
Signed-off-by: Jakub Czapiga jacz@semihalf.com Signed-off-by: Anna Karas aka@semihalf.com Signed-off-by: Jan Dabros jsd@semihalf.com Change-Id: I9d3ab45c3da2a21c910f52a84526b60c39ff1fe7 --- M tests/lib/Makefile.inc A tests/lib/imd-test.c 2 files changed, 762 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/44669/3
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
Patch Set 3:
(12 comments)
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c File tests/lib/imd-test.c:
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@49 PS3, Line 49: 0xA000, /* Fits in 16 bits, should not get rounded down*/ line over 96 characters
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@50 PS3, Line 50: 0xDEAA, /* Fits in 16 bits */ please, no space before tabs
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@51 PS3, Line 51: 0xB0B0B000, /* Fits in 32 bits, should not get rounded down */ line over 96 characters
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@52 PS3, Line 52: 0xF0F0F0F0, /* Fits in 32 bits */ please, no space before tabs
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@54 PS3, Line 54: 0x6666777788889000, /* Fits in 64 bits, should not get rounded down */ line over 96 characters
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@55 PS3, Line 55: ((1ULL << 60) - 100) /* Very large address still fitting in 64-bit address space */ line over 96 characters
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@123 PS3, Line 123: assert_int_equal(-1, imd_create_empty(&imd, sizeof(struct imd_root_pointer), LG_ENTRY_ALIGN)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@255 PS3, Line 255: assert_int_equal(2, ((struct imd_root*)imd.lg.r)->num_entries); "(foo*)" should be "(foo *)"
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@256 PS3, Line 256: assert_int_equal(1, ((struct imd_root*)imd.sm.r)->num_entries); "(foo*)" should be "(foo *)"
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@284 PS3, Line 284: assert_int_equal(2, ((struct imd_root*)imd.sm.r)->num_entries); "(foo*)" should be "(foo *)"
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@325 PS3, Line 325: max_size = align_up_pow2(sizeof(struct imd_root_pointer) + sizeof(struct imd_root) + 3 * sizeof(struct imd_entry)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/44669/3/tests/lib/imd-test.c@334 PS3, Line 334: root_size = align_up_pow2(sizeof(struct imd_root_pointer) + sizeof(struct imd_root) + 2 * sizeof(struct imd_entry)); line over 96 characters
Paul Fagerburg has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
Patch Set 3:
For all of the comments (against patchset 2) that you have resolved, please mark them as resolved. As long as there are unresolved comments, your CL cannot be submitted. Buildbot is complaining about line length; this is because we use tab characters (linux style) and they are treated as 8 spaces side. Please fix the line lengths as well.
Name of user not set #1003143 has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
Patch Set 3:
(11 comments)
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c File tests/lib/imd-test.c:
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@9 PS2, Line 9: #include <limits.h>
What do you need this for? I can't see anything that needs it but I may have missed something. […]
Done
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@13 PS2, Line 13: void *memset(void *ptr, int value, size_t num);
For these kinds of cases I would suggest to centralize them rather than than defining them manually […]
Done
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@38 PS2, Line 38: } __packed;
Let's not duplicate all of this stuff, let's just factor them out from the code under test into a se […]
Done
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@43 PS2, Line 43: #define CBMEM_ID_IMD_SMALL 0x53a11439
Don't you get these from cbmem. […]
Done
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@56 PS2, Line 56: #define CURSOR_SZ sizeof(struct imd_cursor)
Not sure why you have all of these rather than using sizeof() directly in the code? Not sure they re […]
Done
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@69 PS2, Line 69: uint32_t align_up_pow2(uint32_t x)
You can just use (1 << log2_ceil(x)) from coreboot's <lib.h>.
Done
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@89 PS2, Line 89: uintptr_t test_inputs[] = {0, 0xDEAA, 0xF0F0F0F0, ((1ULL << 32) + 4),
Consider adding comments for each of these as to why the values were chosen, e.g. […]
Done
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@155 PS2, Line 155: /* Expect failure, since imd handle is not initialized */
"Expect imd_create_empty to fail, since ...
Done
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@236 PS2, Line 236: sm_region_size = SM_ROOT_SIZE - RP_SZ - ROOT_SZ;
Can you explain what you're doing here?
Done
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@299 PS2, Line 299: r = imd.lg.r; : assert_int_equal(2, r->num_entries);
I know it's more verbose, but […]
Done
https://review.coreboot.org/c/coreboot/+/44669/2/tests/lib/imd-test.c@495 PS2, Line 495: /* Fail when root is locked. */
Consider saying "Cannot add an entry when root is locked" as that explains the specific thing that f […]
Done
Name of user not set #1003143 has uploaded a new patch set (#4) to the change originally created by Jan Dabros. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
tests: Add lib/imd-test test case
Implement unit tests for src/lib/imd.c module.
Signed-off-by: Jakub Czapiga jacz@semihalf.com Signed-off-by: Anna Karas aka@semihalf.com Signed-off-by: Jan Dabros jsd@semihalf.com Change-Id: I9d3ab45c3da2a21c910f52a84526b60c39ff1fe7 --- M tests/lib/Makefile.inc A tests/lib/imd-test.c 2 files changed, 766 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/44669/4
Name of user not set #1003143 has uploaded a new patch set (#5) to the change originally created by Jan Dabros. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
tests: Add lib/imd-test test case
Implement unit tests for src/lib/imd.c module.
Make IMD private structures definitions accessible by other units.
To test IMD API correctness there is a need to access its internal structure. It is only possible when private implementation is visible in testing scope.
Signed-off-by: Jakub Czapiga jacz@semihalf.com Signed-off-by: Anna Karas aka@semihalf.com Signed-off-by: Jan Dabros jsd@semihalf.com Change-Id: I9d3ab45c3da2a21c910f52a84526b60c39ff1fe7 --- M tests/lib/Makefile.inc A tests/lib/imd-test.c 2 files changed, 766 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/44669/5
Name of user not set #1003143 has uploaded a new patch set (#6) to the change originally created by Jan Dabros. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
tests: Add lib/imd-test test case
Implement unit tests for src/lib/imd.c module.
Signed-off-by: Jakub Czapiga jacz@semihalf.com Signed-off-by: Anna Karas aka@semihalf.com Signed-off-by: Jan Dabros jsd@semihalf.com Change-Id: I9d3ab45c3da2a21c910f52a84526b60c39ff1fe7 --- M tests/lib/Makefile.inc A tests/lib/imd-test.c 2 files changed, 766 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/44669/6
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
Patch Set 6: Code-Review+1
(2 comments)
https://review.coreboot.org/c/coreboot/+/44669/6/tests/lib/imd-test.c File tests/lib/imd-test.c:
https://review.coreboot.org/c/coreboot/+/44669/6/tests/lib/imd-test.c@218 PS6, Line 218: extern int printf(const char *, ...); Hmm?
https://review.coreboot.org/c/coreboot/+/44669/6/tests/lib/imd-test.c@544 PS6, Line 544: 0xC001 #define this?
Name of user not set #1003143 has uploaded a new patch set (#7) to the change originally created by Jan Dabros. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
tests: Add lib/imd-test test case
Implement unit tests for src/lib/imd.c module.
Signed-off-by: Jakub Czapiga jacz@semihalf.com Signed-off-by: Anna Karas aka@semihalf.com Signed-off-by: Jan Dabros jsd@semihalf.com Change-Id: I9d3ab45c3da2a21c910f52a84526b60c39ff1fe7 --- M tests/lib/Makefile.inc A tests/lib/imd-test.c 2 files changed, 768 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/44669/7
Name of user not set #1003143 has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
Patch Set 6:
(2 comments)
https://review.coreboot.org/c/coreboot/+/44669/6/tests/lib/imd-test.c File tests/lib/imd-test.c:
https://review.coreboot.org/c/coreboot/+/44669/6/tests/lib/imd-test.c@218 PS6, Line 218: extern int printf(const char *, ...);
Hmm?
Done
https://review.coreboot.org/c/coreboot/+/44669/6/tests/lib/imd-test.c@544 PS6, Line 544: 0xC001
#define this?
Done
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
Patch Set 7: Code-Review+2
Paul Fagerburg has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
Patch Set 7: Code-Review+2
Jan Dabros has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/44669 )
Change subject: tests: Add lib/imd-test test case ......................................................................
Abandoned