summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authoryangwei <[email protected]>2023-05-31 13:57:17 +0800
committeryangwei <[email protected]>2023-05-31 13:57:17 +0800
commit7ed1582309d7446c8bbe7c5bfe037c792d9d59f5 (patch)
treec6c2a3daffaa3ce61ff97231f6dabbc172711a21 /demo
parent67ed711088b4ddafbdfc470618ed427082e1a106 (diff)
🐎 ci(test): 增加test stageHEADdev-2.0
Diffstat (limited to 'demo')
-rw-r--r--demo/test_handle_logger.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/demo/test_handle_logger.c b/demo/test_handle_logger.c
index bd36de3..7f28632 100644
--- a/demo/test_handle_logger.c
+++ b/demo/test_handle_logger.c
@@ -106,6 +106,7 @@ int main(int argc, char ** args)
{
pthread_t t[MAX_THREAD_NUM];
int i = 0;
+ int ret =0;
if (argc != 6)
{
@@ -136,26 +137,35 @@ int main(int argc, char ** args)
{
printf("get log sample_handle error\n");
return -1;
- }
+ }
- test_handle = MESA_create_runtime_log_handle("./log/test_log", RLOG_LV_DEBUG);
- if(test_handle == NULL)
- {
- printf("get log test_handle error\n");
- return -1;
- }
+ test_handle = MESA_create_runtime_log_handle("./log/test_log", RLOG_LV_DEBUG);
+ if (test_handle == NULL)
+ {
+ printf("get log test_handle error\n");
+ return -1;
+ }
- for(i = 0; i < g_thread_num; i++)
- {
- pthread_create(&t[i], NULL, thread_logger, (void *)(unsigned long)(i));
- }
- signal(SIGINT, sig_int_handler);
- signal(SIGHUP, sig_hup_handler);
- while(1)
- ;
- //MESA_destroy_runtime_log_handle(sample_handle);
- //MESA_destroy_runtime_log_handle(test_handle);
- //sample_handle = NULL;
- //test_handle = NULL;
- return 0;
+ for (i = 0; i < g_thread_num; i++)
+ {
+ pthread_create(&t[i], NULL, thread_logger, (void *)(unsigned long)(i));
+ }
+ signal(SIGINT, sig_int_handler);
+ signal(SIGHUP, sig_hup_handler);
+
+ // 等待所有线程结束并回收
+ for (i = 0; i < g_thread_num; ++i) {
+ ret = pthread_join(t[i], NULL);
+ if (ret != 0) {
+ fprintf(stderr, "Failed to join thread %d\n", i);
+ return 1;
+ }
+ }
+
+ printf("All threads finished\n");
+ // MESA_destroy_runtime_log_handle(sample_handle);
+ // MESA_destroy_runtime_log_handle(test_handle);
+ // sample_handle = NULL;
+ // test_handle = NULL;
+ return 0;
}