32tv_lt(
const struct timeval *t1,
const struct timeval *t2)
34 if (t1->tv_sec < t2->tv_sec)
38 else if (t1->tv_sec > t2->tv_sec)
44 return t1->tv_usec < t2->tv_usec;
49tv_le(
const struct timeval *t1,
const struct timeval *t2)
51 if (t1->tv_sec < t2->tv_sec)
55 else if (t1->tv_sec > t2->tv_sec)
61 return t1->tv_usec <= t2->tv_usec;
66tv_eq(
const struct timeval *t1,
const struct timeval *t2)
68 return t1->tv_sec == t2->tv_sec && t1->tv_usec == t2->tv_usec;
83 const struct timeval *min,
const struct timeval *max)
91 assert_ptr_not_equal(e, e->
lt);
92 assert_ptr_not_equal(e, e->
gt);
93 assert_ptr_not_equal(e, e->
parent);
96 assert_true(!e->
lt || e->
lt != e->
gt);
112 assert_true(
tv_le(min, &e->
tv));
113 assert_true(
tv_le(&e->
tv, max));
120 if (least &&
tv_lt(&e->
tv, least))
149 max.tv_sec = 0x7FFFFFFF;
150 max.tv_usec = 0x7FFFFFFF;
162 tv->tv_sec +=
random() % 100;
163 tv->tv_usec =
random() % 100;
170 struct timeval least;
172 least.tv_sec = least.tv_usec = 0x7FFFFFFF;
181 while (bit_ceil_n < n)
189 assert_true(maxlev >= log2n);
194 assert_true(
tv_eq(&least, &e->
tv));
204 for (i = 0; i < size; ++i)
206 const int src = rand() % size;
210 array[i] = array[src];
221 for (i = 0; i < indent; ++i)
243 printf(
"*************************\n");
261 for (i = 0; i < n; ++i)
275 for (j = 1; j <= n_mod; ++j)
279 for (i = 0; i < n; ++i)
301 assert_null(s->
root);
303 for (i = 0; i < n; ++i)
static void gc_free(struct gc_arena *a)
#define ALLOC_OBJ_CLEAR(dptr, type)
#define ALLOC_ARRAY(dptr, type, n)
static struct gc_arena gc_new(void)
const char * tv_string(const struct timeval *tv, struct gc_arena *gc)
struct schedule * schedule_init(void)
void schedule_remove_node(struct schedule *s, struct schedule_entry *e)
struct schedule_entry * schedule_find_least(struct schedule_entry *e)
int schedule_entry_compare(const struct schedule_entry *e1, const struct schedule_entry *e2)
This method compares two schedule entries and return which one is earlier,later or equal.
void schedule_add_modify(struct schedule *s, struct schedule_entry *e)
void schedule_free(struct schedule *s)
Garbage collection arena used to keep track of dynamically allocated memory.
struct schedule_entry * lt
struct schedule_entry * parent
struct schedule_entry * gt
struct schedule_entry * root
static bool tv_le(const struct timeval *t1, const struct timeval *t2)
static bool tv_eq(const struct timeval *t1, const struct timeval *t2)
void tv_randomize(struct timeval *tv)
static struct schedule_entry * schedule_find_earliest_wakeup(struct schedule *s)
int schedule_debug(struct schedule *s, int *count, struct timeval *least)
static bool tv_lt(const struct timeval *t1, const struct timeval *t2)
void schedule_verify(struct schedule *s, int n)
void schedule_print_work(struct schedule_entry *e, int indent)
void schedule_randomize_array(struct schedule_entry **array, int size)
void schedule_test(void **state)
Runs the schedule test.
int schedule_debug_entry(const struct schedule_entry *e, int depth, int *count, struct timeval *least, const struct timeval *min, const struct timeval *max)
void schedule_print(struct schedule *s)