Commit 5d410717 authored by Ghislain MARY's avatar Ghislain MARY

Synchronize bc_tester + fix build.

parent b940d2d3
......@@ -27,20 +27,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "CUnit/Basic.h"
#include "CUnit/Automated.h"
#if WINAPI_FAMILY_PHONE_APP
const char *bc_tester_read_dir_prefix="Assets";
#elif defined(__QNX__)
const char *bc_tester_read_dir_prefix="./app/native/assets/";
#else
const char *bc_tester_read_dir_prefix=".";
#ifdef _WIN32
#if defined(__MINGW32__) || !defined(WINAPI_FAMILY_PARTITION) || !defined(WINAPI_PARTITION_DESKTOP)
#define BC_TESTER_WINDOWS_DESKTOP 1
#elif defined(WINAPI_FAMILY_PARTITION)
#if defined(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#define BC_TESTER_WINDOWS_DESKTOP 1
#endif
/* TODO: have the same "static" for QNX and windows as above? */
#ifdef ANDROID
const char *bc_tester_writable_dir_prefix = "/data/data/org.linphone.tester/cache";
#else
const char *bc_tester_writable_dir_prefix = ".";
#if defined(WINAPI_PARTITION_PHONE_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
#define BC_TESTER_WINDOWS_PHONE 1
#endif
#if defined(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
#define BC_TESTER_WINDOWS_UNIVERSAL 1
#endif
#endif
#endif
static char *bc_tester_resource_dir_prefix = NULL;
static char *bc_tester_writable_dir_prefix = NULL;
int bc_printf_verbosity_info;
int bc_printf_verbosity_error;
......@@ -97,7 +102,7 @@ int bc_tester_suite_index(const char *suite_name) {
return -1;
}
int bc_tester_nb_suites() {
int bc_tester_nb_suites(void) {
return nb_test_suites;
}
......@@ -114,7 +119,7 @@ int bc_tester_nb_tests(const char *suite_name) {
return test_suite[i]->nb_tests;
}
void bc_tester_list_suites() {
void bc_tester_list_suites(void) {
int j;
for(j=0;j<nb_test_suites;j++) {
bc_tester_printf(bc_printf_verbosity_info, "%s", bc_tester_suite_name(j));
......@@ -272,6 +277,22 @@ void bc_tester_helper(const char *name, const char* additionnal_helper) {
}
void bc_tester_init(void (*ftester_printf)(int level, const char *fmt, va_list args), int iverbosity_info, int iverbosity_error) {
#if defined(BC_TESTER_WINDOWS_PHONE) || defined(BC_TESTER_WINDOWS_UNIVERSAL)
bc_tester_set_resource_dir_prefix("Assets");
#elif defined(__QNX__)
bc_tester_set_resource_dir_prefix("./app/native/assets/");
#else
bc_tester_set_resource_dir_prefix(".");
#endif
#ifdef ANDROID
bc_tester_set_writable_dir_prefix("/data/data/org.linphone.tester/cache");
#elif defined(__QNX__)
bc_tester_set_writable_dir_prefix("./tmp");
#else
bc_tester_set_writable_dir_prefix(".");
#endif
tester_printf_va = ftester_printf;
bc_printf_verbosity_error = iverbosity_error;
bc_printf_verbosity_info = iverbosity_info;
......@@ -364,14 +385,56 @@ void bc_tester_uninit() {
test_suite = NULL;
nb_test_suites = 0;
}
if (bc_tester_resource_dir_prefix != NULL) {
free(bc_tester_resource_dir_prefix);
bc_tester_resource_dir_prefix = NULL;
}
if (bc_tester_writable_dir_prefix != NULL) {
free(bc_tester_writable_dir_prefix);
bc_tester_writable_dir_prefix = NULL;
}
}
char * bc_tester_res(const char *name) {
static void bc_tester_set_dir_prefix(char **prefix, const char *name) {
size_t len = strlen(name);
if (*prefix != NULL) free(*prefix);
*prefix = malloc(len + 1);
strncpy(*prefix, name, len);
(*prefix)[len] = '\0';
}
const char * bc_tester_get_resource_dir_prefix(void) {
return bc_tester_resource_dir_prefix;
}
void bc_tester_set_resource_dir_prefix(const char *name) {
bc_tester_set_dir_prefix(&bc_tester_resource_dir_prefix, name);
}
const char * bc_tester_get_writable_dir_prefix(void) {
return bc_tester_writable_dir_prefix;
}
void bc_tester_set_writable_dir_prefix(const char *name) {
bc_tester_set_dir_prefix(&bc_tester_writable_dir_prefix, name);
}
static char * bc_tester_path(const char *prefix, const char *name) {
char* file = NULL;
if (name) {
size_t len = strlen(bc_tester_read_dir_prefix) + 1 + strlen(name) + 1;
size_t len = strlen(prefix) + 1 + strlen(name) + 1;
file = malloc(len);
snprintf(file, len, "%s/%s", bc_tester_read_dir_prefix, name);
snprintf(file, len, "%s/%s", prefix, name);
file[strlen(file)] = '\0';
}
return file;
}
char * bc_tester_res(const char *name) {
return bc_tester_path(bc_tester_resource_dir_prefix, name);
}
char * bc_tester_file(const char *name) {
return bc_tester_path(bc_tester_writable_dir_prefix, name);
}
......@@ -25,8 +25,9 @@
#include <string.h>
#include <math.h>
extern const char *bc_tester_read_dir_prefix;
extern const char *bc_tester_writable_dir_prefix;
#ifdef _WIN32
#define snprintf _snprintf
#endif
extern int bc_printf_verbosity_info;
extern int bc_printf_verbosity_error;
......@@ -68,6 +69,10 @@ int bc_tester_start();
void bc_tester_add_suite(test_suite_t *suite);
void bc_tester_uninit();
void bc_tester_printf(int level, const char *fmt, ...);
const char * bc_tester_get_resource_dir_prefix(void);
void bc_tester_set_resource_dir_prefix(const char *name);
const char * bc_tester_get_writable_dir_prefix(void);
void bc_tester_set_writable_dir_prefix(const char *name);
int bc_tester_nb_suites();
int bc_tester_nb_tests(const char* name);
......@@ -83,11 +88,19 @@ int bc_tester_suite_index(const char *suite_name);
/**
* Get full path to the given resource
*
* @param name relative resource path (relative to bc_tester_writable_dir_prefix)
* @param name relative resource path
* @return path to the resource. Must be freed by caller.
*/
char * bc_tester_res(const char *name);
/**
* Get full path to the given writable_file
*
* @param name relative writable file path
* @return path to the writable file. Must be freed by caller.
*/
char * bc_tester_file(const char *name);
/*Redefine the CU_... macros WITHOUT final ';' semicolon, to allow IF conditions and with smarter error message */
extern int CU_assertImplementation(int bValue,
......
......@@ -200,8 +200,8 @@ void start_adaptive_stream(MSFormatType type, stream_manager_t ** pmarielle, str
stream_manager_t *marielle=*pmarielle=stream_manager_new(type);
stream_manager_t *margaux=*pmargaux=stream_manager_new(type);
char* file = ms_strdup_printf("%s/%s", bc_tester_read_dir_prefix, HELLO_16K_1S_FILE);
char* recorded_file = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix, RECORDED_16K_1S_FILE);
char* file = bc_tester_res(HELLO_16K_1S_FILE);
char* recorded_file = bc_tester_file(RECORDED_16K_1S_FILE);
marielle->user_data = recorded_file;
params.enabled=TRUE;
......@@ -248,9 +248,8 @@ void start_adaptive_stream(MSFormatType type, stream_manager_t ** pmarielle, str
*pmarielle);
rtp_session_enable_network_simulation(margaux_ms->sessions.rtp_session,&params);
ms_free(recorded_file);
ms_free(file);
free(recorded_file);
free(file);
}
static void iterate_adaptive_stream(stream_manager_t * marielle, stream_manager_t * margaux,
......
......@@ -128,8 +128,8 @@ static void basic_audio_stream_base( const char* marielle_local_ip
AudioStream * margaux = audio_stream_new2 (margaux_local_ip, margaux_local_rtp_port,margaux_local_rtcp_port);
stats_t margaux_stats;
RtpProfile* profile = rtp_profile_new("default profile");
char* hello_file = ms_strdup_printf("%s/%s", bc_tester_read_dir_prefix, HELLO_8K_1S_FILE);
char* recorded_file = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix, RECORDED_8K_1S_FILE);
char* hello_file = bc_tester_res(HELLO_8K_1S_FILE);
char* recorded_file = bc_tester_file(RECORDED_8K_1S_FILE);
int dummy=0;
rtp_session_set_multicast_loopback(marielle->ms.sessions.rtp_session,TRUE);
rtp_session_set_multicast_loopback(margaux->ms.sessions.rtp_session,TRUE);
......@@ -187,8 +187,8 @@ static void basic_audio_stream_base( const char* marielle_local_ip
audio_stream_stop(margaux);
unlink(recorded_file);
ms_free(recorded_file);
ms_free(hello_file);
free(recorded_file);
free(hello_file);
rtp_profile_destroy(profile);
}
......@@ -210,8 +210,8 @@ static void encrypted_audio_stream_base( bool_t change_ssrc,
AudioStream * marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE);
AudioStream * margaux = audio_stream_new (MARGAUX_RTP_PORT,MARGAUX_RTCP_PORT, FALSE);
RtpProfile* profile = rtp_profile_new("default profile");
char* hello_file = ms_strdup_printf("%s/%s", bc_tester_read_dir_prefix, HELLO_8K_1S_FILE);
char* recorded_file = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix, RECORDED_8K_1S_FILE);
char* hello_file = bc_tester_res(HELLO_8K_1S_FILE);
char* recorded_file = bc_tester_file(RECORDED_8K_1S_FILE);
stats_t marielle_stats;
stats_t margaux_stats;
int dummy=0;
......@@ -349,8 +349,8 @@ static void encrypted_audio_stream_base( bool_t change_ssrc,
}
unlink(recorded_file);
ms_free(recorded_file);
ms_free(hello_file);
free(recorded_file);
free(hello_file);
} else {
ms_warning("srtp not available, skiping...");
}
......@@ -392,8 +392,8 @@ static void codec_change_for_audio_stream(void) {
AudioStream *margaux = audio_stream_new2(MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_RTCP_PORT);
stats_t margaux_stats;
RtpProfile *profile = rtp_profile_new("default profile");
char* hello_file = ms_strdup_printf("%s/%s", bc_tester_read_dir_prefix, HELLO_8K_1S_FILE);
char* recorded_file = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix, RECORDED_8K_1S_FILE);
char* hello_file = bc_tester_res(HELLO_8K_1S_FILE);
char* recorded_file = bc_tester_file(RECORDED_8K_1S_FILE);
uint64_t marielle_rtp_sent = 0;
int dummy=0;
......@@ -447,8 +447,8 @@ static void codec_change_for_audio_stream(void) {
audio_stream_stop(margaux);
unlink(recorded_file);
ms_free(recorded_file);
ms_free(hello_file);
free(recorded_file);
free(hello_file);
rtp_profile_destroy(profile);
}
......@@ -460,7 +460,7 @@ static void tmmbr_feedback_for_audio_stream(void) {
RtpProfile *profile = rtp_profile_new("default profile");
RtpSession *marielle_session;
RtpSession *margaux_session;
char* hello_file = ms_strdup_printf("%s/%s", bc_tester_read_dir_prefix, HELLO_8K_1S_FILE);
char* hello_file = bc_tester_res(HELLO_8K_1S_FILE);
int dummy=0;
reset_stats(&marielle_stats);
......@@ -508,7 +508,7 @@ static void tmmbr_feedback_for_audio_stream(void) {
audio_stream_stop(marielle);
audio_stream_stop(margaux);
ms_free(hello_file);
free(hello_file);
ortp_ev_queue_destroy(marielle_stats.q);
ortp_ev_queue_destroy(margaux_stats.q);
rtp_profile_destroy(profile);
......
......@@ -206,7 +206,7 @@ static void dtmfgen_filerec_fileplay_tonedet(void) {
unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_FILEREC
| FILTER_MASK_FILEPLAY | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK;
bool_t send_silence = TRUE;
char* recorded_file = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix, DTMFGEN_FILE_NAME);
char* recorded_file = bc_tester_file(DTMFGEN_FILE_NAME);
ms_filter_reset_statistics();
ms_tester_create_ticker();
......@@ -251,7 +251,7 @@ static void dtmfgen_filerec_fileplay_tonedet(void) {
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
unlink(recorded_file);
ms_free(recorded_file);
free(recorded_file);
}
......
......@@ -135,9 +135,9 @@ static void play_file(const char *filepath, bool_t unsupported_format, bool_t se
}
static void play_root_file(const char *filepath, bool_t unsupported_format, bool_t seeking_test, bool_t play_twice){
char* file = ms_strdup_printf("%s/%s", bc_tester_read_dir_prefix, filepath);
char* file = bc_tester_res(filepath);
play_file(file, unsupported_format, seeking_test, play_twice);
ms_free(file);
free(file);
}
static void play_hello_8000_wav(void) {
......
......@@ -185,9 +185,9 @@ static void fileplay_soundwrite(const char *filename) {
}
static void fileplay_soundwrite_from_file(const char *filepath){
char* file = ms_strdup_printf("%s/%s", bc_tester_read_dir_prefix, filepath);
char* file = bc_tester_res(filepath);
fileplay_soundwrite(file);
ms_free(file);
free(file);
}
static void fileplay_soundwrite_48000_stereo(void) {
......@@ -362,7 +362,7 @@ static void soundread_filerec_fileplay_soundwrite(void) {
int playback_sample_rate = 8000;
int capture_nchannels = 1;
int playback_nchannels = 1;
char *writable_filename = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix, SOUNDREAD_FILE_NAME);
char *writable_filename = bc_tester_file(SOUNDREAD_FILE_NAME);
ms_filter_reset_statistics();
ms_tester_create_ticker();
......@@ -425,7 +425,7 @@ static void soundread_filerec_fileplay_soundwrite(void) {
ms_tester_destroy_ticker();
unlink(writable_filename);
ms_free(writable_filename);
free(writable_filename);
}
......
......@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static FILE * log_file = NULL;
static void log_handler(int lev, const char *fmt, va_list args) {
#ifdef WIN32
#ifdef _WIN32
vfprintf(lev == ORTP_ERROR ? stderr : stdout, fmt, args);
fprintf(lev == ORTP_ERROR ? stderr : stdout, "\n");
#else
......@@ -71,7 +71,7 @@ static const char* mediastreamer2_helper =
"\t\t\t--log-file <output log file path>\n";
#if defined(WIN32) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#if defined(_WIN32) && !defined(MS2_WINDOWS_DESKTOP)
#define BUILD_ENTRY_POINT 0
#else
#define BUILD_ENTRY_POINT 1
......
......@@ -693,9 +693,7 @@ static test_t tests[] = {
{ "Video configuration", video_configuration_stream },
{ "AVPF RPSI count", avpf_rpsi_count}
};
#else
static test_t tests[] = {};
#endif
test_suite_t video_stream_test_suite = {
"VideoStream",
tester_init,
......@@ -703,3 +701,12 @@ test_suite_t video_stream_test_suite = {
sizeof(tests) / sizeof(tests[0]),
tests
};
#else
test_suite_t video_stream_test_suite = {
"VideoStream",
NULL,
NULL,
0,
NULL
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment