|
|
|
@ -77,8 +77,8 @@ static void waiter_cb(struct ll_queue *q, void *arg) { |
|
|
|
static void test_basic(void) { |
|
|
|
static void test_basic(void) { |
|
|
|
TEST("basic creation / free"); |
|
|
|
TEST("basic creation / free"); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct ll_queue *q1 = queue_new(ua, 0); |
|
|
|
struct ll_queue *q1 = queue_new(ua, 0,"q1"); |
|
|
|
struct ll_queue *q2 = queue_new(ua, 16); |
|
|
|
struct ll_queue *q2 = queue_new(ua, 16,"q2"); |
|
|
|
ASSERT(q1 && q2, "queue_new failed"); |
|
|
|
ASSERT(q1 && q2, "queue_new failed"); |
|
|
|
ASSERT_EQ(queue_entry_count(q1), 0, ""); |
|
|
|
ASSERT_EQ(queue_entry_count(q1), 0, ""); |
|
|
|
queue_free(q1); queue_free(q2); |
|
|
|
queue_free(q1); queue_free(q2); |
|
|
|
@ -89,7 +89,7 @@ static void test_basic(void) { |
|
|
|
static void test_fifo(void) { |
|
|
|
static void test_fifo(void) { |
|
|
|
TEST("FIFO ordering"); |
|
|
|
TEST("FIFO ordering"); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct ll_queue *q = queue_new(ua, 0); |
|
|
|
struct ll_queue *q = queue_new(ua, 0,"q3"); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
test_data_t *d = (test_data_t*)queue_entry_new(sizeof(test_data_t)); |
|
|
|
test_data_t *d = (test_data_t*)queue_entry_new(sizeof(test_data_t)); |
|
|
|
@ -112,7 +112,7 @@ static void test_fifo(void) { |
|
|
|
static void test_lifo_priority(void) { |
|
|
|
static void test_lifo_priority(void) { |
|
|
|
TEST("put_first (LIFO priority)"); |
|
|
|
TEST("put_first (LIFO priority)"); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct ll_queue *q = queue_new(ua, 0); |
|
|
|
struct ll_queue *q = queue_new(ua, 0,"q4"); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
test_data_t *d = (test_data_t*)queue_entry_new(sizeof(*d)); |
|
|
|
test_data_t *d = (test_data_t*)queue_entry_new(sizeof(*d)); |
|
|
|
@ -142,7 +142,7 @@ static void test_lifo_priority(void) { |
|
|
|
static void test_callback(void) { |
|
|
|
static void test_callback(void) { |
|
|
|
TEST("callback serial processing"); |
|
|
|
TEST("callback serial processing"); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct ll_queue *q = queue_new(ua, 0); |
|
|
|
struct ll_queue *q = queue_new(ua, 0,"q5"); |
|
|
|
|
|
|
|
|
|
|
|
int cnt = 0; |
|
|
|
int cnt = 0; |
|
|
|
queue_set_callback(q, queue_cb, &cnt); |
|
|
|
queue_set_callback(q, queue_cb, &cnt); |
|
|
|
@ -164,7 +164,7 @@ static void test_callback(void) { |
|
|
|
static void test_waiter(void) { |
|
|
|
static void test_waiter(void) { |
|
|
|
TEST("wait_threshold + cancel"); |
|
|
|
TEST("wait_threshold + cancel"); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct ll_queue *q = queue_new(ua, 0); |
|
|
|
struct ll_queue *q = queue_new(ua, 0,"q6"); |
|
|
|
|
|
|
|
|
|
|
|
int called = 0; |
|
|
|
int called = 0; |
|
|
|
struct queue_waiter *w = queue_wait_threshold(q, 2, 0, waiter_cb, &called); |
|
|
|
struct queue_waiter *w = queue_wait_threshold(q, 2, 0, waiter_cb, &called); |
|
|
|
@ -192,7 +192,7 @@ static void test_waiter(void) { |
|
|
|
static void test_limits_hash(void) { |
|
|
|
static void test_limits_hash(void) { |
|
|
|
TEST("size limit + hash find/remove"); |
|
|
|
TEST("size limit + hash find/remove"); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct ll_queue *q = queue_new(ua, 16); |
|
|
|
struct ll_queue *q = queue_new(ua, 16,"q7"); |
|
|
|
queue_set_size_limit(q, 3); |
|
|
|
queue_set_size_limit(q, 3); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
@ -216,7 +216,7 @@ static void test_pool(void) { |
|
|
|
TEST("memory_pool integration + reuse"); |
|
|
|
TEST("memory_pool integration + reuse"); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct memory_pool *pool = memory_pool_init(sizeof(test_data_t)); |
|
|
|
struct memory_pool *pool = memory_pool_init(sizeof(test_data_t)); |
|
|
|
struct ll_queue *q = queue_new(ua, 0); |
|
|
|
struct ll_queue *q = queue_new(ua, 0,"q8"); |
|
|
|
|
|
|
|
|
|
|
|
size_t alloc1 = 0, reuse1 = 0; |
|
|
|
size_t alloc1 = 0, reuse1 = 0; |
|
|
|
memory_pool_get_stats(pool, &alloc1, &reuse1); |
|
|
|
memory_pool_get_stats(pool, &alloc1, &reuse1); |
|
|
|
@ -251,7 +251,7 @@ static void test_stress(void) { |
|
|
|
TEST("stress 10k ops"); |
|
|
|
TEST("stress 10k ops"); |
|
|
|
double start = now_ms(); |
|
|
|
double start = now_ms(); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct UASYNC *ua = uasync_create(); |
|
|
|
struct ll_queue *q = queue_new(ua, 64); |
|
|
|
struct ll_queue *q = queue_new(ua, 64,"q9"); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10000; i++) { |
|
|
|
for (int i = 0; i < 10000; i++) { |
|
|
|
if (queue_entry_count(q) > 80) { |
|
|
|
if (queue_entry_count(q) > 80) { |
|
|
|
|