int main(int argc, char* argv[]) { int32_t i = 0; const char* ns_ip = NULL; char* log_level = "info"; while ((i = getopt(argc, argv, "s:l:h")) != EOF) { switch (i) { case 's': ns_ip = optarg; break; case 'l': log_level = optarg; break; case 'h': default: printf("Usage: %s -s nsip\n", argv[0]); return EXIT_FAILURE; } } if (NULL == ns_ip) { printf("Usage: %s -s nsip\n", argv[0]); return EXIT_FAILURE; } int ret = TFS_ERROR; /* initialize */ if ((ret = t_initialize(ns_ip, 1800, 50000, 1)) != TFS_SUCCESS) { printf("init tfs client fail, ret: %d\n", ret); return ret; } // set log level t_set_log_level(log_level); key_file = argv[0]; // demo small file op_tfs_file(TFS_SMALL_FILE); // demo large file op_tfs_file(TFS_LARGE_FILE); printf("cache hit ratio: %d\n", t_get_cache_hit_ratio()); printf("cache hit ratio: %d\n", t_get_cache_hit_ratio()); /* destroy */ t_destroy(); return TFS_SUCCESS; }
int test_main() { thread_t threads[NUM_THREADS]; int tid; threads_init(); for(tid = 0; tid < NUM_THREADS; ++tid) { t_init(&threads[tid], NULL, test_mutex, "tatomic-%d", tid); } for(tid = 0; tid < NUM_THREADS; ++tid) { t_join(&threads[tid]); t_destroy(&threads[tid]); } assert(atomic_read(&counter) == (NUM_THREADS * STEPS)); threads_fini(); return 0; }