Tester: create tester_utils which contain factorized code for all testers (in progress, continuing)

parent dfdfc13e
......@@ -45,3 +45,4 @@ tester/recorded_hello8000-1s.wav
tester/recorded_hello16000-1s.wav
*.vcxproj.*
tools/msaudiocmp
tester/dtmfgen_file.raw
This diff is collapsed.
......@@ -22,8 +22,8 @@
#include "CUnit/Basic.h"
extern const char *tester_file_prefix;
extern const char *tester_writable_dir_prefix;
extern const char *bc_tester_read_dir_prefix;
extern const char *bc_tester_writable_dir_prefix;
typedef void (*test_function_t)(void);
typedef int (*test_suite_function_t)(const char *name);
......@@ -52,26 +52,26 @@ fprintf(stderr, "Missing argument for \"%s\"\n", argument); \
return -1; \
} \
void tester_init(void (*tester_printf)(int level, const char *fmt, va_list args));
void tester_helper(const char *name, const char* additionnal_helper);
int tester_parse_args(int argc, char** argv, int argid);
int tester_start();
void bc_tester_init(void (*bc_tester_printf)(int level, const char *fmt, va_list args));
void bc_tester_helper(const char *name, const char* additionnal_helper);
int bc_tester_parse_args(int argc, char** argv, int argid);
int bc_tester_start();
int tester_test_suite_index(const char *suite_name);
void tester_list_suites();
void tester_list_suite_tests(const char *suite_name);
int tester_test_index(const char *suite_name, const char *test_name);
int tester_nb_test_suites(void);
int tester_nb_tests(const char *suite_name);
const char * tester_test_suite_name(int suite_index);
const char * tester_test_name(const char *suite_name, int test_index);
int tester_run_tests(const char *suite_name, const char *test_name);
int bc_tester_test_suite_index(const char *suite_name);
void bc_tester_list_suites();
void bc_tester_list_suite_tests(const char *suite_name);
int bc_tester_test_index(const char *suite_name, const char *test_name);
int bc_tester_nb_test_suites(void);
int bc_tester_nb_tests(const char *suite_name);
const char * bc_tester_test_suite_name(int suite_index);
const char * bc_tester_test_name(const char *suite_name, int test_index);
int bc_tester_run_tests(const char *suite_name, const char *test_name);
void tester_add_suite(test_suite_t *suite);
int tester_run_suite(test_suite_t *suite);
void bc_tester_add_suite(test_suite_t *suite);
int bc_tester_run_suite(test_suite_t *suite);
void tester_uninit();
void bc_tester_uninit();
#ifdef __cplusplus
......
......@@ -202,8 +202,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", mediastreamer2_tester_get_file_root(), HELLO_16K_1S_FILE);
char* recorded_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_writable_dir(), RECORDED_16K_1S_FILE);
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);
marielle->user_data = recorded_file;
params.enabled=TRUE;
......@@ -310,7 +310,8 @@ static void event_queue_cb(MediaStream *ms, void *user_pointer) {
if (rb&&ortp_loss_rate_estimator_process_report_block(ctx->estimator,&ms->sessions.rtp_session->rtp,rb)){
float diff = fabs(ortp_loss_rate_estimator_get_value(ctx->estimator) - ctx->loss_rate);
CU_ASSERT_IN_RANGE(diff, 0, 10);
CU_ASSERT_TRUE(diff >= 0);
CU_ASSERT_TRUE(diff <= 10);
}
} while (rtcp_next_packet(evd->packet));
}
......@@ -404,7 +405,8 @@ void upload_bitrate(const char* codec, int payload, int target_bw, int expect_bw
media_stream_enable_adaptive_bitrate_control(&marielle->audio_stream->ms,FALSE);
iterate_adaptive_stream(marielle, margaux, 15000, NULL, 0);
upload_bw=media_stream_get_up_bw(&marielle->audio_stream->ms) / 1000;
CU_ASSERT_IN_RANGE(upload_bw, expect_bw-2, expect_bw+2);
CU_ASSERT_TRUE(upload_bw >= expect_bw-2);
CU_ASSERT_TRUE(upload_bw <= expect_bw+2);
stop_adaptive_stream(marielle,margaux);
}
}
......@@ -452,8 +454,10 @@ void adaptive_video(int max_bw, int exp_min_bw, int exp_max_bw, int loss_rate, i
stream_manager_t * marielle, * margaux;
start_adaptive_stream(MSVideo, &marielle, &margaux, VP8_PAYLOAD_TYPE, 300*1000, max_bw*1000, loss_rate, 50,0);
iterate_adaptive_stream(marielle, margaux, 100000, &marielle->rtcp_count, 7);
CU_ASSERT_IN_RANGE(marielle->adaptive_stats.loss_estim, exp_min_loss, exp_max_loss);
CU_ASSERT_IN_RANGE(marielle->adaptive_stats.congestion_bw_estim, exp_min_bw, exp_max_bw);
CU_ASSERT_TRUE(marielle->adaptive_stats.loss_estim >= exp_min_loss);
CU_ASSERT_TRUE(marielle->adaptive_stats.loss_estim <= exp_max_loss);
CU_ASSERT_TRUE(marielle->adaptive_stats.congestion_bw_estim >= exp_min_bw);
CU_ASSERT_TRUE(marielle->adaptive_stats.congestion_bw_estim <= exp_max_bw);
stop_adaptive_stream(marielle,margaux);
} else {
/*ortp_loss_estimator rely on the fact that we receive some packets: however when
......
......@@ -132,8 +132,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", mediastreamer2_tester_get_file_root(), HELLO_8K_1S_FILE);
char* recorded_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_writable_dir(), RECORDED_8K_1S_FILE);
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);
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);
......@@ -212,8 +212,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", mediastreamer2_tester_get_file_root(), HELLO_8K_1S_FILE);
char* recorded_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_writable_dir(), RECORDED_8K_1S_FILE);
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);
stats_t marielle_stats;
stats_t margaux_stats;
int dummy=0;
......@@ -391,8 +391,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", mediastreamer2_tester_get_file_root(), HELLO_8K_1S_FILE);
char* recorded_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_writable_dir(), RECORDED_8K_1S_FILE);
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);
uint64_t marielle_rtp_sent = 0;
int dummy=0;
......
......@@ -210,7 +210,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", mediastreamer2_tester_get_writable_dir(), DTMFGEN_FILE_NAME);
char* recorded_file = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix, DTMFGEN_FILE_NAME);
ms_filter_reset_statistics();
ms_tester_create_ticker();
......
......@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2_tester.h"
#include "mediastreamer2/msmediaplayer.h"
#include "mediastreamer2/mediastream.h"
static int tester_init() {
ms_init();
......@@ -134,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", mediastreamer2_tester_get_file_root(), filepath);
char* file = ms_strdup_printf("%s/%s", bc_tester_read_dir_prefix, filepath);
play_file(file, unsupported_format, seeking_test, play_twice);
ms_free(file);
ms_free(file);
}
static void play_hello_8000_wav(void) {
......
......@@ -189,7 +189,7 @@ static void fileplay_soundwrite(const char *filename) {
}
static void fileplay_soundwrite_from_file(const char *filepath){
char* file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_file_root(), filepath);
char* file = ms_strdup_printf("%s/%s", bc_tester_read_dir_prefix, filepath);
fileplay_soundwrite(file);
ms_free(file);
}
......@@ -366,7 +366,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", mediastreamer2_tester_get_writable_dir(), SOUNDREAD_FILE_NAME);
char *writable_filename = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix, SOUNDREAD_FILE_NAME);
ms_filter_reset_statistics();
ms_tester_create_ticker();
......
This diff is collapsed.
......@@ -21,27 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define _MEDIASTREAMER2_TESTER_H
#include "CUnit/Basic.h"
#include <mediastreamer2/mediastream.h>
typedef void (*test_function_t)(void);
typedef int (*test_suite_function_t)(const char *name);
typedef struct {
const char *name;
test_function_t func;
} test_t;
typedef struct {
const char *name;
CU_InitializeFunc init_func;
CU_CleanupFunc cleanup_func;
int nb_tests;
test_t *tests;
} test_suite_t;
#include "common/tester_utils.h"
#ifdef __cplusplus
extern "C" {
......@@ -58,29 +38,10 @@ extern test_suite_t player_test_suite;
extern test_suite_t neon_test_suite;
#endif
#define CU_ASSERT_IN_RANGE(value, inf, sup) \
CU_ASSERT_TRUE(value >= inf); \
CU_ASSERT_TRUE(value <= sup);
extern int mediastreamer2_tester_nb_test_suites(void);
extern int mediastreamer2_tester_nb_tests(const char *suite_name);
extern const char * mediastreamer2_tester_test_suite_name(int suite_index);
extern const char * mediastreamer2_tester_test_name(const char *suite_name, int test_index);
extern void mediastreamer2_tester_init(void);
extern void mediastreamer2_tester_uninit(void);
extern int mediastreamer2_tester_run_tests(const char *suite_name, const char *test_name);
extern const char* mediastreamer2_tester_get_file_root();
/* without / at the end */
extern void mediastreamer2_tester_set_file_root(const char* fileroot);
extern const char* mediastreamer2_tester_get_writable_dir();
extern void mediastreamer2_tester_set_writable_dir(const char* writable_dir);
#if TARGET_OS_MAC || TARGET_OS_IPHONE
int apple_main(int argc, char *argv[]);
#endif
#ifdef __cplusplus
};
#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