// SPDX-License-Identifier: GPL-2.0
/*
* KUnit test for the Kernel Linked-list structures.
*
* Copyright (C) 2019, Google LLC.
* Author: David Gow <davidgow@google.com>
*/
#include <kunit/test.h>
#include <linux/list.h>
#include <linux/klist.h>
struct list_test_struct {
int data;
struct list_head list;
};
static void list_test_list_init(struct kunit *test)
{
/* Test the different ways of initialising a list. */
struct list_head list1 = LIST_HEAD_INIT(list1);
struct list_head list2;
LIST_HEAD(list3);
struct list_head *list4;
struct list_head *list5;
INIT_LIST_HEAD(&list2);
list4 = kzalloc(sizeof(*list4), GFP_KERNEL | __GFP_NOFAIL);
INIT_LIST_HEAD(list4);
list5 = kmalloc(sizeof(*list5), GFP_KERNEL | __GFP_NOFAIL);
memset(list5, 0xFF, sizeof(*list5));
INIT_LIST_HEAD(list5);
/* list_empty_careful() checks both next and prev. */
KUNIT_EXPECT_TRUE(test, list_empty_careful(&list1));
KUNIT_EXPECT_TRUE(test, list_empty_careful(&list2));
KUNIT_EXPECT_TRUE(test, <