projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bridge: Write CFM updates more quickly.
[openvswitch]
/
tests
/
test-list.c
diff --git
a/tests/test-list.c
b/tests/test-list.c
index 0aa0f8b2ad6896eaf3f49612a01a599d02fd79b3..5e62e0c00b3e7ef0ab9cc4b818c94a8efec3146d 100644
(file)
--- a/
tests/test-list.c
+++ b/
tests/test-list.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009
, 2010
Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-34,10
+34,10
@@
struct element {
* elements in order into 'list'. */
static void
make_list(struct list *list, struct element elements[],
* elements in order into 'list'. */
static void
make_list(struct list *list, struct element elements[],
- int values[], size_t n)
+ int values[], size_t n)
{
size_t i;
{
size_t i;
-
+
list_init(list);
for (i = 0; i < n; i++) {
elements[i].value = i;
list_init(list);
for (i = 0; i < n; i++) {
elements[i].value = i;
@@
-49,13
+49,13
@@
make_list(struct list *list, struct element elements[],
/* Verifies that 'list' contains exactly the 'n' values in 'values', in the
* specified order. */
static void
/* Verifies that 'list' contains exactly the 'n' values in 'values', in the
* specified order. */
static void
-check_list(struct list *list, const int values[], size_t n)
+check_list(struct list *list, const int values[], size_t n)
{
struct element *e;
size_t i;
{
struct element *e;
size_t i;
-
+
i = 0;
i = 0;
- LIST_FOR_EACH (e,
struct element,
node, list) {
+ LIST_FOR_EACH (e, node, list) {
assert(i < n);
assert(e->value == values[i]);
i++;
assert(i < n);
assert(e->value == values[i]);
i++;
@@
-64,7
+64,7
@@
check_list(struct list *list, const int values[], size_t n)
assert(i == n);
i = 0;
assert(i == n);
i = 0;
- LIST_FOR_EACH_REVERSE (e,
struct element,
node, list) {
+ LIST_FOR_EACH_REVERSE (e, node, list) {
assert(i < n);
assert(e->value == values[n - i - 1]);
i++;
assert(i < n);
assert(e->value == values[n - i - 1]);
i++;
@@
-79,12
+79,12
@@
check_list(struct list *list, const int values[], size_t n)
#if 0
/* Prints the values in 'list', plus 'name' as a title. */
static void
#if 0
/* Prints the values in 'list', plus 'name' as a title. */
static void
-print_list(const char *name, struct list *list)
+print_list(const char *name, struct list *list)
{
struct element *e;
{
struct element *e;
-
+
printf("%s:", name);
printf("%s:", name);
- LIST_FOR_EACH (e,
struct element,
node, list) {
+ LIST_FOR_EACH (e, node, list) {
printf(" %d", e->value);
}
printf("\n");
printf(" %d", e->value);
}
printf("\n");
@@
-93,7
+93,7
@@
print_list(const char *name, struct list *list)
/* Tests basic list construction. */
static void
/* Tests basic list construction. */
static void
-test_list_construction(void)
+test_list_construction(void)
{
enum { MAX_ELEMS = 100 };
size_t n;
{
enum { MAX_ELEMS = 100 };
size_t n;
@@
-102,7
+102,7
@@
test_list_construction(void)
struct element elements[MAX_ELEMS];
int values[MAX_ELEMS];
struct list list;
struct element elements[MAX_ELEMS];
int values[MAX_ELEMS];
struct list list;
-
+
make_list(&list, elements, values, n);
check_list(&list, values, n);
}
make_list(&list, elements, values, n);
check_list(&list, values, n);
}
@@
-111,7
+111,7
@@
test_list_construction(void)
/* Tests that LIST_FOR_EACH_SAFE properly allows for deletion of the current
* element of a list. */
static void
/* Tests that LIST_FOR_EACH_SAFE properly allows for deletion of the current
* element of a list. */
static void
-test_list_for_each_safe(void)
+test_list_for_each_safe(void)
{
enum { MAX_ELEMS = 10 };
size_t n;
{
enum { MAX_ELEMS = 10 };
size_t n;
@@
-125,13
+125,13
@@
test_list_for_each_safe(void)
struct element *e, *next;
size_t values_idx, n_remaining;
int i;
struct element *e, *next;
size_t values_idx, n_remaining;
int i;
-
+
make_list(&list, elements, values, n);
i = 0;
values_idx = 0;
n_remaining = n;
make_list(&list, elements, values, n);
i = 0;
values_idx = 0;
n_remaining = n;
- LIST_FOR_EACH_SAFE (e, next,
struct element,
node, &list) {
+ LIST_FOR_EACH_SAFE (e, next, node, &list) {
assert(i < n);
if (pattern & (1ul << i)) {
list_remove(&e->node);
assert(i < n);
if (pattern & (1ul << i)) {
list_remove(&e->node);
@@
-158,14
+158,14
@@
test_list_for_each_safe(void)
}
static void
}
static void
-run_test(void (*function)(void))
+run_test(void (*function)(void))
{
function();
printf(".");
}
int
{
function();
printf(".");
}
int
-main(void)
+main(void)
{
run_test(test_list_construction);
run_test(test_list_for_each_safe);
{
run_test(test_list_construction);
run_test(test_list_for_each_safe);