1
This commit is contained in:
1 parent
3ab19094d0
commit
8a3cdaf759
2 files changed
+1
-55
No files matched your search
@@ -1,54 +0,0 @@
|
||||
#include "u_async.h"
|
||||
#include <stdio.h>
|
||||
#include "../lib/debug_config.h"
|
||||
|
||||
/* Test statistics */
|
||||
static struct {
|
||||
int tests_run;
|
||||
int tests_passed;
|
||||
int tests_failed;
|
||||
|
||||
/* Timer statistics */
|
||||
int timer_callbacks;
|
||||
int timer_cancellations;
|
||||
int immediate_timeouts;
|
||||
|
||||
/* Socket statistics */
|
||||
int socket_events;
|
||||
int socket_errors;
|
||||
|
||||
/* Error statistics */
|
||||
int memory_allocation_errors;
|
||||
int invalid_parameter_errors;
|
||||
int race_condition_errors;
|
||||
} test_stats = {0};
|
||||
|
||||
/* Timer callback for testing */
|
||||
static void test_timer_callback(void* arg) {
|
||||
test_stats.timer_callbacks++;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "Timer callback fired. Total callbacks: %d", test_stats.timer_callbacks);
|
||||
}
|
||||
|
||||
int main() {
|
||||
debug_config_init();
|
||||
debug_set_level(DEBUG_LEVEL_TRACE);
|
||||
debug_set_categories(DEBUG_CATEGORY_ALL);
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "Before any tests: immediate_timeouts = %d", test_stats.immediate_timeouts);
|
||||
|
||||
uasync_t* ua = uasync_create();
|
||||
|
||||
/* Set 5 immediate timeouts */
|
||||
for (int i = 0; i < 5; i++) {
|
||||
void* timer = uasync_set_timeout(ua, 0, NULL, test_timer_callback);
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "After setting 5 immediate timeouts, before poll: immediate_timeouts = %d", test_stats.immediate_timeouts);
|
||||
|
||||
uasync_poll(ua, 1);
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "After poll: immediate_timeouts = %d", test_stats.immediate_timeouts);
|
||||
|
||||
uasync_destroy(ua, 0);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user