#include #include #include #include #include #include #include #include #include #include #include #include /* See NOTES */ #include #include #include #include "stream.h" #include #include #include #include "gtest_sapp_fun.h" void *g_sapp_test_log_handle; int g_slient_mode = 0; const char *user_define_args; const char *for_test_sapp_version = "4.2.68_c9193fe"; static int g_libsapp_devel_res = GTEST_SAPP_ERR; /* 使用lisapp_devel.so在同一个进程内运行的测试结�???*/ int gtest_set_libsapp_devel_result(int res_value) { g_libsapp_devel_res = res_value; //printf("set res: %p to value :%x\n", &g_libsapp_devel_res, res_value); return 0; } int gtest_get_libsapp_devel_result(void) { //printf("get res: %p value :%x\n", &g_libsapp_devel_res, g_libsapp_devel_res); return g_libsapp_devel_res; } void call_libsapp_devel_with_args(int argc, const char *argv[]) { int ret, real_argc = argc; gtest_set_libsapp_devel_result(GTEST_SAPP_ERR); char *sapp_dumpfile_start_args[argc+2]; if(g_slient_mode){ for(int i = 0; i < argc; i++) { if(argv[i] != NULL) { sapp_dumpfile_start_args[i] = (char*)calloc(1, strlen(argv[i])+1); strcpy(sapp_dumpfile_start_args[i], argv[i]); } } sapp_dumpfile_start_args[argc] = (char*)calloc(3,1); strncpy(sapp_dumpfile_start_args[argc], "-n", 2); sapp_dumpfile_start_args[argc+1] = (char*)calloc(3,1); strncpy(sapp_dumpfile_start_args[argc+1], "-s", 2); real_argc+=2; ret = libsapp_setup_env(real_argc, sapp_dumpfile_start_args); }else{ for(int i = 0; i < argc; i++) { if(argv[i] != NULL) { sapp_dumpfile_start_args[i] = (char*)calloc(1, strlen(argv[i])+1); strcpy(sapp_dumpfile_start_args[i], argv[i]); } } sapp_dumpfile_start_args[argc] = (char*)calloc(3,1); strncpy(sapp_dumpfile_start_args[argc], "-n", 2); real_argc+=1; ret = libsapp_setup_env(real_argc, sapp_dumpfile_start_args); } if(ret < 0){ printf("call libsapp_setup_env() fail"); gtest_set_libsapp_devel_result(GTEST_SAPP_ERR); return; } while(sapp_get_current_state() != SAPP_STATE_READY_TO_EXIT){ usleep(100); } libsapp_destroy_env(); for(int i=0; i gtest_sapp.log"); MESA_handle_runtime_log_creation("./etc/sapp_log.conf"); g_sapp_test_log_handle = MESA_create_runtime_log_handle("./log/test_sapp_benchmark.log", user_log_level); MESA_handle_runtime_log(g_sapp_test_log_handle, RLOG_LV_DEBUG, "sapp_module_test", "starting sapp module test....\n"); gtest_sapp_master_init(); ::testing::InitGoogleTest(&to_gtest_argc, to_gtest_args); ::testing::FLAGS_gtest_death_test_style = "fast"; int ret=RUN_ALL_TESTS(); MESA_destroy_runtime_log_handle(g_sapp_test_log_handle); MESA_handle_runtime_log_destruction(); return ret; }