diff --git a/src/main.c b/src/main.c index f02c5f36..ad08a0cc 100644 --- a/src/main.c +++ b/src/main.c @@ -186,8 +186,10 @@ const command_t k_commands[] = { static int _tf_command_test(const char* file, int argc, char* argv[]) { #if !defined(__ANDROID__) + const char* default_db_path = _get_db_path(); tf_test_options_t test_options = { .exe_path = file, + .db_path = default_db_path, }; bool show_usage = false; @@ -195,10 +197,11 @@ static int _tf_command_test(const char* file, int argc, char* argv[]) { static const struct option k_options[] = { { "tests", required_argument, NULL, 't' }, + { "db-path", required_argument, NULL, 'd' }, { "help", no_argument, NULL, 'h' }, { 0 }, }; - int c = getopt_long(argc, argv, "t:h", k_options, NULL); + int c = getopt_long(argc, argv, "t:d:h", k_options, NULL); if (c == -1) { break; @@ -214,6 +217,9 @@ static int _tf_command_test(const char* file, int argc, char* argv[]) case 't': test_options.tests = optarg; break; + case 'd': + test_options.db_path = optarg; + break; } } @@ -229,10 +235,12 @@ static int _tf_command_test(const char* file, int argc, char* argv[]) tf_printf("options\n"); tf_printf(" -t, --tests tests Comma-separated list of tests to run. (default: all)\n"); tf_printf(" -h, --help Show this usage information.\n"); + tf_free((void*)default_db_path); return EXIT_FAILURE; } tf_tests(&test_options); + tf_free((void*)default_db_path); return EXIT_SUCCESS; #else return EXIT_FAILURE; diff --git a/src/ssb.tests.c b/src/ssb.tests.c index 7a77fa90..622e2f24 100644 --- a/src/ssb.tests.c +++ b/src/ssb.tests.c @@ -1613,7 +1613,9 @@ void tf_ssb_test_following_perf(const tf_test_options_t* options) uv_loop_t loop = { 0 }; uv_loop_init(&loop); - tf_ssb_t* ssb = tf_ssb_create(&loop, NULL, "db.sqlite", NULL); + tf_printf("Testing following_perf.\n"); + tf_printf("Using %s.\n", options->db_path); + tf_ssb_t* ssb = tf_ssb_create(&loop, NULL, options->db_path, NULL); uint64_t start = uv_hrtime(); const char** ids = tf_ssb_db_get_all_visible_identities(ssb, 2); diff --git a/src/tests.h b/src/tests.h index e7adfbe3..4c4a3a8f 100644 --- a/src/tests.h +++ b/src/tests.h @@ -15,6 +15,8 @@ typedef struct _tf_test_options_t const char* exe_path; /** A comma-separated list of tests to run, or NULL. */ const char* tests; + /** Path to the actual local database for running performance tests against. */ + const char* db_path; } tf_test_options_t; /**