Added some auto-tests for bulk timeouts.
This commit is contained in:
parent
d48ef710d8
commit
8899e49f73
@ -761,6 +761,9 @@ int main(int argc, char** argv)
|
|||||||
exotic_add_test(&handle, &exotic_test_timer_add_5_events_1, "timer_add_5_events_1");
|
exotic_add_test(&handle, &exotic_test_timer_add_5_events_1, "timer_add_5_events_1");
|
||||||
exotic_add_test(&handle, &exotic_test_timer_check_5_events_1, "timer_check_5_events_1");
|
exotic_add_test(&handle, &exotic_test_timer_check_5_events_1, "timer_check_5_events_1");
|
||||||
exotic_add_test(&handle, &exotic_test_timer_process_5_events_1, "timer_process_5_events_1");
|
exotic_add_test(&handle, &exotic_test_timer_process_5_events_1, "timer_process_5_events_1");
|
||||||
|
exotic_add_test(&handle, &exotic_test_timer_clear_1, "timer_clear_1");
|
||||||
|
exotic_add_test(&handle, &exotic_test_timer_bulk_1, "timer_bulk_1");
|
||||||
|
exotic_add_test(&handle, &exotic_test_timer_bulk_2, "timer_bulk_2");
|
||||||
exotic_add_test(&handle, &exotic_test_tokenizer_basic_0, "tokenizer_basic_0");
|
exotic_add_test(&handle, &exotic_test_tokenizer_basic_0, "tokenizer_basic_0");
|
||||||
exotic_add_test(&handle, &exotic_test_tokenizer_basic_1, "tokenizer_basic_1");
|
exotic_add_test(&handle, &exotic_test_tokenizer_basic_1, "tokenizer_basic_1");
|
||||||
exotic_add_test(&handle, &exotic_test_tokenizer_basic_1a, "tokenizer_basic_1a");
|
exotic_add_test(&handle, &exotic_test_tokenizer_basic_1a, "tokenizer_basic_1a");
|
||||||
@ -951,7 +954,6 @@ int exotic_initialize(struct exotic_handle* handle, int argc, char** argv)
|
|||||||
void exotic_add_test(struct exotic_handle* handle, exo_test_t func, const char* name)
|
void exotic_add_test(struct exotic_handle* handle, exo_test_t func, const char* name)
|
||||||
{
|
{
|
||||||
struct exo_test_data* test;
|
struct exo_test_data* test;
|
||||||
|
|
||||||
if (!handle)
|
if (!handle)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "exotic_add_test: failed, no handle!\n");
|
fprintf(stderr, "exotic_add_test: failed, no handle!\n");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <uhub.h>
|
#include <uhub.h>
|
||||||
|
|
||||||
#define MAX_EVENTS 15
|
#define MAX_EVENTS 100
|
||||||
static struct timeout_queue* g_queue;
|
static struct timeout_queue* g_queue;
|
||||||
static time_t g_now;
|
static time_t g_now;
|
||||||
static size_t g_max;
|
static size_t g_max;
|
||||||
@ -117,3 +117,28 @@ EXO_TEST(timer_process_5_events_1,{
|
|||||||
g_now = 4;
|
g_now = 4;
|
||||||
return timeout_queue_process(g_queue, g_now) == g_triggered;
|
return timeout_queue_process(g_queue, g_now) == g_triggered;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
EXO_TEST(timer_clear_1,{
|
||||||
|
size_t n;
|
||||||
|
for (n = 0; n < MAX_EVENTS; n++)
|
||||||
|
timeout_queue_remove(g_queue, &g_events[n]);
|
||||||
|
return timeout_queue_get_next_timeout(g_queue, g_now) == g_max;
|
||||||
|
});
|
||||||
|
|
||||||
|
EXO_TEST(timer_bulk_1,{
|
||||||
|
size_t n;
|
||||||
|
g_now = 10;
|
||||||
|
for (n = 0; n < MAX_EVENTS; n++)
|
||||||
|
{
|
||||||
|
timeout_queue_insert(g_queue, &g_events[0], 0);
|
||||||
|
}
|
||||||
|
return timeout_queue_process(g_queue, g_now) == 10;
|
||||||
|
});
|
||||||
|
|
||||||
|
EXO_TEST(timer_bulk_2,{
|
||||||
|
g_now = 110;
|
||||||
|
return timeout_queue_process(g_queue, g_now) == 90;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user