15#include "threads/test.h"
40 printf (
"testing various size lists:");
41 for (size = 0; size <
MAX_SIZE; size++)
46 for (repeat = 0; repeat < 10; repeat++)
54 for (i = 0; i < size; i++)
60 for (i = 0; i < size; i++)
83 for (i = 0; i < size; i++)
101 ASSERT ((
size_t) ofs <
sizeof values /
sizeof *values);
117 for (i = 0; i < cnt; i++)
120 struct value t = array[j];
#define ASSERT(CONDITION)
This is outside the header guard so that debug.h may be included multiple times with different settin...
#define UNUSED
GCC lets us add "attributes" to functions, function parameters, etc.
struct list_elem * list_begin(struct list *list)
Returns the beginning of LIST.
struct list_elem * list_min(struct list *list, list_less_func *less, void *aux)
Returns the element in LIST with the smallest value according to LESS given auxiliary data AUX.
struct list_elem * list_rbegin(struct list *list)
Returns the LIST's reverse beginning, for iterating through LIST in reverse order,...
void list_unique(struct list *list, struct list *duplicates, list_less_func *less, void *aux)
Iterates through LIST and removes all but the first in each set of adjacent elements that are equal a...
struct list_elem * list_prev(struct list_elem *elem)
Returns the element before ELEM in its list.
struct list_elem * list_end(struct list *list)
Returns LIST's tail.
void list_insert(struct list_elem *before, struct list_elem *elem)
Inserts ELEM just before BEFORE, which may be either an interior element or a tail.
struct list_elem * list_max(struct list *list, list_less_func *less, void *aux)
Returns the element in LIST with the largest value according to LESS given auxiliary data AUX.
void list_init(struct list *list)
Initializes LIST as an empty list.
struct list_elem * list_rend(struct list *list)
Returns LIST's head.
void list_push_back(struct list *list, struct list_elem *elem)
Inserts ELEM at the end of LIST, so that it becomes the back in LIST.
struct list_elem * list_next(struct list_elem *elem)
Returns the element after ELEM in its list.
void list_reverse(struct list *list)
Reverses the order of LIST.
void list_sort(struct list *list, list_less_func *less, void *aux)
Sorts LIST according to LESS given auxiliary data AUX, using a natural iterative merge sort that runs...
void list_insert_ordered(struct list *list, struct list_elem *elem, list_less_func *less, void *aux)
Inserts ELEM in the proper position in LIST, which must be sorted according to LESS given auxiliary d...
int printf(const char *format,...)
Writes formatted output to the console.
#define list_entry(LIST_ELEM, STRUCT, MEMBER)
Converts pointer to list element LIST_ELEM into a pointer to the structure that LIST_ELEM is embedded...
unsigned long random_ulong(void)
Returns a pseudo-random unsigned long.
struct list_elem elem
List element.
#define MAX_SIZE
Test program for lib/kernel/list.c.
static void shuffle(struct value[], size_t)
static bool value_less(const struct list_elem *, const struct list_elem *, void *)
static void verify_list_bkwd(struct list *, int size)
Verifies that LIST contains the values 0...SIZE when traversed in reverse order.
void test(void)
Test the linked list implementation.
static void verify_list_fwd(struct list *, int size)
Verifies that LIST contains the values 0...SIZE when traversed in forward order.