From 03ad6404b6776c6c5329bdc5c54be89f20d50e17 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 24 Sep 2015 11:07:07 +0200 Subject: [PATCH] tester: remove --config since bc tester already provide it now --- mediastreamer2 | 2 +- tester/common/bc_tester_utils.c | 35 +++++++++++++++++++++++++++------ tester/liblinphone_tester.c | 4 ---- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 079af18e9..262c1ca2e 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 079af18e985acad5a752cb11dd1c40b329b037a3 +Subproject commit 262c1ca2e48d5c0eedae86cc36579bacd234ee48 diff --git a/tester/common/bc_tester_utils.c b/tester/common/bc_tester_utils.c index ea80fc498..6b14355b3 100644 --- a/tester/common/bc_tester_utils.c +++ b/tester/common/bc_tester_utils.c @@ -51,7 +51,8 @@ along with this program. If not, see . #endif static char *bc_tester_resource_dir_prefix = NULL; -static char *bc_tester_writable_dir_prefix = NULL; +// by default writable will always write near the executable +static char *bc_tester_writable_dir_prefix = "."; int bc_printf_verbosity_info; int bc_printf_verbosity_error; @@ -346,6 +347,7 @@ static int file_exists(const char* root_path) { static void detect_res_prefix(const char* prog) { char* progpath = strdup(prog); char* prefix = NULL; + FILE* writable_file = NULL; #if defined(BC_TESTER_WINDOWS_PHONE) || defined(BC_TESTER_WINDOWS_UNIVERSAL) bc_tester_set_resource_dir_prefix("Assets"); @@ -383,20 +385,41 @@ static void detect_res_prefix(const char* prog) { free(progpath2); } + if (bc_tester_resource_dir_prefix != NULL && !file_exists(bc_tester_resource_dir_prefix)) { + printf("Invalid provided resource directory: could not find expected resources in %s.\n", bc_tester_resource_dir_prefix); + free(bc_tester_resource_dir_prefix); + bc_tester_resource_dir_prefix = NULL; + } + if (prefix != NULL) { - if (bc_tester_resource_dir_prefix == NULL) { + if (bc_tester_resource_dir_prefix != NULL) { printf("Resource directory set to %s\n", prefix); bc_tester_set_resource_dir_prefix(prefix); } + if (bc_tester_writable_dir_prefix == NULL) { printf("Writable directory set to %s\n", prefix); bc_tester_set_writable_dir_prefix(prefix); } free(prefix); - } else if (bc_tester_resource_dir_prefix == NULL || bc_tester_writable_dir_prefix == NULL) { - printf("Failed to detect resources for %s.\n", prog); - printf("Could not find resource directory in %s! Please try again using option --resource-dir and/or --writable-dir.\n", progpath); - abort(); + } + + // check that we can write in writable directory + if (bc_tester_writable_dir_prefix != NULL) { + writable_file = fopen("bc_tester_utils.tmp", "w"); + if (writable_file) { + fclose(writable_file); + } + } + if (bc_tester_resource_dir_prefix == NULL || writable_file == NULL) { + if (bc_tester_resource_dir_prefix == NULL) { + printf("Failed to detect resources for %s.\n", prog); + printf("Could not find resource directory in %s! Please try again using option --resource-dir.\n", progpath); + } + if (writable_file == NULL) { + printf("Failed to write file in %s. Please try again using option --writable-dir.\n", bc_tester_writable_dir_prefix); + } + exit(1); } if (progpath != NULL) { diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 15a3e8001..55e4628cd 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -175,7 +175,6 @@ static const char* liblinphone_helper = "\t\t\t--verbose\n" "\t\t\t--silent\n" "\t\t\t--log-file \n" - "\t\t\t--config \n" "\t\t\t--domain \n" "\t\t\t--auth-domain \n" "\t\t\t--dns-hosts \n" @@ -218,9 +217,6 @@ int main (int argc, char *argv[]) } else if (strcmp(argv[i],"--auth-domain")==0){ CHECK_ARG("--auth-domain", ++i, argc); auth_domain=argv[i]; - } else if (strcmp(argv[i],"--config")==0){ - CHECK_ARG("--config", ++i, argc); - bc_tester_set_resource_dir_prefix(argv[i]); }else if (strcmp(argv[i],"--dns-hosts")==0){ CHECK_ARG("--dns-hosts", ++i, argc); userhostsfile=argv[i];