summaryrefslogtreecommitdiff
path: root/tests/lib
diff options
context:
space:
mode:
authorMaximilian Brune <maximilian.brune@9elements.com>2023-09-16 19:56:45 +0200
committerJakub Czapiga <czapiga@google.com>2024-02-24 11:49:46 +0000
commita99b580c75278d306d2d1eb0b6893e83388ec513 (patch)
treefe7c54d9195782454984f4d9a9165c658a0f07aa /tests/lib
parent366ceeef0f07d3962ee6e6a0f3151a7f438c97ed (diff)
treewide: Move list.h to commonlib
It is needed in order to move device_tree.c into commonlib in a subsequent commit. Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com> Change-Id: I16eb7b743fb1d36301f0eda563a62364e7a9cfec Reviewed-on: https://review.coreboot.org/c/coreboot/+/77968 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Makefile.mk4
-rw-r--r--tests/lib/list-test.c149
2 files changed, 0 insertions, 153 deletions
diff --git a/tests/lib/Makefile.mk b/tests/lib/Makefile.mk
index b8c4c71eaf..01777171c9 100644
--- a/tests/lib/Makefile.mk
+++ b/tests/lib/Makefile.mk
@@ -9,7 +9,6 @@ tests-y += timestamp-test
tests-y += edid-test
tests-y += cbmem_console-romstage-test
tests-y += cbmem_console-ramstage-test
-tests-y += list-test
tests-y += fmap-test
tests-y += imd_cbmem-romstage-test
tests-y += imd_cbmem-ramstage-test
@@ -74,9 +73,6 @@ cbmem_console-ramstage-test-stage := ramstage
cbmem_console-ramstage-test-srcs += tests/lib/cbmem_console-test.c
cbmem_console-ramstage-test-srcs += tests/stubs/console.c
-list-test-srcs += tests/lib/list-test.c
-list-test-srcs += src/lib/list.c
-
fmap-test-srcs += tests/lib/fmap-test.c
fmap-test-srcs += src/lib/fmap.c
fmap-test-srcs += tests/stubs/console.c
diff --git a/tests/lib/list-test.c b/tests/lib/list-test.c
deleted file mode 100644
index 39bfb17f7c..0000000000
--- a/tests/lib/list-test.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-#include <tests/test.h>
-#include <stdlib.h>
-#include <string.h>
-#include <list.h>
-
-struct test_container {
- int value;
-
- struct list_node list_node;
-};
-
-void test_list_insert_after(void **state)
-{
- int i = 0;
- struct list_node root = { .prev = NULL, .next = NULL };
- struct test_container *c1 = (struct test_container *)malloc(sizeof(*c1));
- struct test_container *c2 = (struct test_container *)malloc(sizeof(*c2));
- struct test_container *c3 = (struct test_container *)malloc(sizeof(*c2));
- struct test_container *ptr;
- const int values[] = { 5, 10, 13 }; /* Random values */
-
- memset(c1, 0, sizeof(*c1));
- memset(c2, 0, sizeof(*c2));
- memset(c2, 0, sizeof(*c3));
-
- c1->value = values[0];
- c2->value = values[1];
- c3->value = values[2];
-
- list_insert_after(&c1->list_node, &root);
- list_insert_after(&c2->list_node, &c1->list_node);
- list_insert_after(&c3->list_node, &c2->list_node);
-
- list_for_each(ptr, root, list_node) {
- assert_int_equal(values[i], ptr->value);
- i++;
- }
-
- assert_int_equal(3, i);
-
- free(c3);
- free(c2);
- free(c1);
-}
-
-void test_list_insert_before(void **state)
-{
- int i = 0;
- struct list_node root = { .prev = NULL, .next = NULL };
- struct test_container *c1 = (struct test_container *)malloc(sizeof(*c1));
- struct test_container *c2 = (struct test_container *)malloc(sizeof(*c2));
- struct test_container *c3 = (struct test_container *)malloc(sizeof(*c2));
- struct test_container *ptr;
- const int values[] = { 19, 71, 991 }; /* Random values */
-
- memset(c1, 0, sizeof(*c1));
- memset(c2, 0, sizeof(*c2));
- memset(c2, 0, sizeof(*c3));
-
- c1->value = values[0];
- c2->value = values[1];
- c3->value = values[2];
-
- list_insert_after(&c3->list_node, &root);
- list_insert_before(&c2->list_node, &c3->list_node);
- list_insert_before(&c1->list_node, &c2->list_node);
-
-
- list_for_each(ptr, root, list_node) {
- assert_int_equal(values[i], ptr->value);
- i++;
- }
-
- assert_int_equal(3, i);
-
- free(c3);
- free(c2);
- free(c1);
-}
-
-void test_list_remove(void **state)
-{
- struct list_node root = { .prev = NULL, .next = NULL };
- struct test_container *c1 = (struct test_container *)malloc(sizeof(*c1));
- struct test_container *c2 = (struct test_container *)malloc(sizeof(*c2));
- struct test_container *ptr;
- int len;
-
- list_insert_after(&c1->list_node, &root);
- list_insert_after(&c2->list_node, &c1->list_node);
-
- len = 0;
- list_for_each(ptr, root, list_node) {
- len++;
- }
- assert_int_equal(2, len);
-
- list_remove(&c1->list_node);
-
- len = 0;
- list_for_each(ptr, root, list_node) {
- len++;
- }
- assert_int_equal(1, len);
-
- list_remove(&c2->list_node);
- len = 0;
- list_for_each(ptr, root, list_node) {
- len++;
- }
- assert_int_equal(0, len);
-
- free(c2);
- free(c1);
-}
-
-void test_list_append(void **state)
-{
- size_t idx;
- struct test_container *node;
- struct list_node root = {};
- struct test_container nodes[] = {
- {1}, {2}, {3}
- };
-
- for (idx = 0; idx < ARRAY_SIZE(nodes); ++idx)
- list_append(&nodes[idx].list_node, &root);
-
- idx = 0;
- list_for_each(node, root, list_node) {
- assert_ptr_equal(node, &nodes[idx]);
- idx++;
- }
-}
-
-int main(void)
-{
- const struct CMUnitTest tests[] = {
- cmocka_unit_test(test_list_insert_after),
- cmocka_unit_test(test_list_insert_before),
- cmocka_unit_test(test_list_remove),
- cmocka_unit_test(test_list_append),
- };
-
-
- return cb_run_group_tests(tests, NULL, NULL);
-}