🐎 ci(test): 增加test stage

This commit is contained in:
yangwei
2023-05-31 13:57:17 +08:00
parent 67ed711088
commit 7ed1582309
3 changed files with 56 additions and 20 deletions

View File

@@ -7,6 +7,7 @@ variables:
stages:
- build
- test
.build_before_script:
before_script:
@@ -41,6 +42,26 @@ stages:
tags:
- share
run_test_for_centos7:
stage: test
image: $BUILD_IMAGE_CENTOS7
extends: .build_by_travis_for_centos7
script:
- yum makecache
- ./ci/travis.sh
- cd build
- ctest --verbose
run_test_for_centos8:
stage: test
image: $BUILD_IMAGE_CENTOS8
extends: .build_by_travis_for_centos8
script:
- yum makecache
- ./ci/travis.sh
- cd build
- ctest --verbose
branch_build_debug_for_centos7:
stage: build
extends: .build_by_travis_for_centos7

View File

@@ -69,4 +69,9 @@ install(FILES conf/MESA_handle_logger.conf DESTINATION /usr/lib/tmpfiles.d/ COMP
add_executable(${lib_name}_demo demo/test_handle_logger.c)
target_link_libraries(${lib_name}_demo pthread ${lib_name}_shared)
enable_testing()
add_test(NAME test_compatible_mode COMMAND MESA_handle_logger_demo 1 ./demo_zlog.conf 1 100 0)
add_test(NAME test_perf COMMAND MESA_handle_logger_demo 2 ./demo_zlog.conf 1 1000 0)
include(Package)

View File

@@ -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;
}