Commit 673ddcae authored by Yann Diorcet's avatar Yann Diorcet
Browse files

liblinphone tester: add android mk and modify sources for make it works

parent 9a9c5d61
......@@ -89,8 +89,6 @@ LOCAL_C_INCLUDES += \
LOCAL_LDLIBS += -llog -ldl
LOCAL_STATIC_LIBRARIES := \
cpufeatures \
libmediastreamer2 \
......@@ -198,3 +196,6 @@ else
endif
endif
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_EXPORT_CFLAGS := $(LOCAL_CFLAGS)
LOCAL_PATH := $(call my-dir)/../../tester
common_SRC_FILES := \
call_tester.c \
liblinphone_tester.c \
message_tester.c \
presence_tester.c \
register_tester.c \
setup_tester.c \
# neon
include $(CLEAR_VARS)
ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)
LOCAL_MODULE := liblinphone_tester
LOCAL_SRC_FILES += $(common_SRC_FILES)
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES := cunit liblinphone
include $(BUILD_SHARED_LIBRARY)
endif
# noneon
include $(CLEAR_VARS)
LOCAL_MODULE := liblinphone_testernoneon
ifeq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_MODULE_FILENAME := liblinphone_testerarmv5
endif
LOCAL_SRC_FILES += $(common_SRC_FILES)
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES := cunit liblinphonenoneon
include $(BUILD_SHARED_LIBRARY)
#end
......@@ -141,8 +141,8 @@ static bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_m
}
static void simple_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneCore* lc_marie=marie->lc;
LinphoneCore* lc_pauline=pauline->lc;
......@@ -182,8 +182,8 @@ static void simple_call(void) {
}
static void cancelled_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneCall* out_call = linphone_core_invite(pauline->lc,"marie");
linphone_call_ref(out_call);
......@@ -216,8 +216,8 @@ static void call_with_dns_time_out(void) {
}
static void cancelled_ringing_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneCall* out_call = linphone_core_invite(pauline->lc,"marie");
linphone_call_ref(out_call);
......@@ -234,8 +234,8 @@ static void cancelled_ringing_call(void) {
}
static void early_declined_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneCall* in_call;
LinphoneCall* out_call = linphone_core_invite(pauline->lc,"marie");
......@@ -256,8 +256,8 @@ static void early_declined_call(void) {
}
static void call_terminated_by_caller(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
CU_ASSERT_TRUE(call(pauline,marie));
/*just to sleep*/
......@@ -270,8 +270,8 @@ static void call_terminated_by_caller(void) {
}
static void call_paused_resumed(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneCall* call_obj;
CU_ASSERT_TRUE(call(pauline,marie));
......@@ -308,8 +308,8 @@ static bool_t pause_call_1(LinphoneCoreManager* mgr_1,LinphoneCall* call_1,Linph
}
static void call_paused_resumed_from_callee(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneCall* call_obj;
CU_ASSERT_TRUE(call(pauline,marie));
......@@ -333,9 +333,11 @@ static void call_paused_resumed_from_callee(void) {
linphone_core_manager_destroy(pauline);
}
#ifdef VIDEO_ENABLED
static void call_with_video_added(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneCall* call_obj;
LinphoneVideoPolicy pauline_policy;
LinphoneCallParams* marie_params;
......@@ -376,10 +378,12 @@ static void call_with_video_added(void) {
linphone_core_manager_destroy(pauline);
}
#endif
static void simple_conference(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* laure = linphone_core_manager_new(FILE_PREFIX, "laure_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneCoreManager* laure = linphone_core_manager_new(liblinphone_tester_file_prefix, "laure_rc");
stats initial_marie_stat;
stats initial_pauline_stat;
stats initial_laure_stat;
......@@ -434,8 +438,8 @@ static void simple_conference(void) {
}
static void srtp_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
linphone_core_set_media_encryption(marie->lc,LinphoneMediaEncryptionSRTP);
linphone_core_set_media_encryption(pauline->lc,LinphoneMediaEncryptionSRTP);
......@@ -455,8 +459,8 @@ static void srtp_call(void) {
}
static void early_media_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_early_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_early_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
CU_ASSERT_TRUE(call(pauline,marie));
......@@ -472,9 +476,9 @@ static void early_media_call(void) {
}
static void simple_call_transfer(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* laure = linphone_core_manager_new(FILE_PREFIX, "laure_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneCoreManager* laure = linphone_core_manager_new(liblinphone_tester_file_prefix, "laure_rc");
LinphoneCall* pauline_called_by_marie;
char* laure_identity=linphone_address_as_string(laure->identity);
......@@ -521,9 +525,9 @@ static void simple_call_transfer(void) {
}
static void call_transfer_existing_call_outgoing_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* laure = linphone_core_manager_new(FILE_PREFIX, "laure_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneCoreManager* laure = linphone_core_manager_new(liblinphone_tester_file_prefix, "laure_rc");
LinphoneCall* marie_call_pauline;
LinphoneCall* pauline_called_by_marie;
......
......@@ -38,6 +38,11 @@ const char* test_username="liblinphone_tester";
const char* test_password="secret";
const char* test_route="sip2.linphone.org";
#if WINAPI_FAMILY_PHONE_APP
const char *liblinphone_tester_file_prefix="Assets";
#else
const char *liblinphone_tester_file_prefix="./tester";
#endif
LinphoneAddress * create_linphone_address(const char * domain) {
LinphoneAddress *addr = linphone_address_new(NULL);
......@@ -87,9 +92,9 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c
LinphoneCore* lc;
int retry=0;
stats* counters;
char filepath[50];
char ringpath[50];
char ringbackpath[50];
char filepath[256];
char ringpath[256];
char ringbackpath[256];
sprintf(filepath, "%s/%s", path, file);
lc = linphone_core_new(v_table,NULL,filepath,NULL);
linphone_core_set_user_data(lc,&global_stat);
......@@ -294,18 +299,59 @@ int liblinphone_tester_run_tests(const char *suite_name, const char *test_name)
return CU_get_error();
}
#ifdef ANDROID
#include <android/log.h>
static const char* LogDomain = "liblinphone_tester";
void linphone_android_log_handler(int prio, const char *fmt, va_list args) {
char str[4096];
char *current;
char *next;
vsnprintf(str, sizeof(str) - 1, fmt, args);
str[sizeof(str) - 1] = '\0';
if (strlen(str) < 512) {
__android_log_write(prio, LogDomain, str);
} else {
current = str;
while ((next = strchr(current, '\n')) != NULL) {
*next = '\0';
__android_log_write(prio, LogDomain, current);
current = next + 1;
}
__android_log_write(prio, LogDomain, current);
}
}
static void linphone_android_ortp_log_handler(OrtpLogLevel lev, const char *fmt, va_list args) {
int prio;
switch(lev){
case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
default: prio = ANDROID_LOG_DEFAULT; break;
}
linphone_android_log_handler(prio, fmt, args);
}
#endif
#ifndef WINAPI_FAMILY_PHONE_APP
int main (int argc, char *argv[]) {
int i;
int i,j;
int ret;
char *suite_name=NULL;
char *test_name=NULL;
const char *suite_name=NULL;
const char *test_name=NULL;
for(i=1;i<argc;++i){
if (strcmp(argv[i],"--help")==0){
fprintf(stderr,"%s \t--help\n"
"\t\t\t--verbose\n"
"\t\t\t--list-suites\n"
"\t\t\t--list-tests <suite>\n"
"\t\t\t--config <config path>\n"
"\t\t\t--domain <test sip domain>\n"
"\t\t\t---auth-domain <test auth domain>\n"
#if HAVE_CU_GET_SUITE
......@@ -318,7 +364,11 @@ int main (int argc, char *argv[]) {
, argv[0]);
return 0;
}else if (strcmp(argv[i],"--verbose")==0){
#ifndef ANDROID
linphone_core_enable_logs(NULL);
#else
linphone_core_enable_logs_with_cb(linphone_android_ortp_log_handler);
#endif
}else if (strcmp(argv[i],"--domain")==0){
i++;
test_domain=argv[i];
......@@ -328,9 +378,23 @@ int main (int argc, char *argv[]) {
}else if (strcmp(argv[i],"--test")==0){
i++;
test_name=argv[i];
}else if (strcmp(argv[i],"--config")==0){
i++;
liblinphone_tester_file_prefix=argv[i];
}else if (strcmp(argv[i],"--suite")==0){
i++;
suite_name=argv[i];
}else if (strcmp(argv[i],"--list-suites")==0){
for(j=0;j<liblinphone_tester_nb_test_suites();j++) {
suite_name = liblinphone_tester_test_suite_name(j);
fprintf(stdout, "%s\n", suite_name);
}
}else if (strcmp(argv[i],"--list-tests")==0){
suite_name = argv[++i];
for(j=0;j<liblinphone_tester_nb_tests(suite_name);j++) {
test_name = liblinphone_tester_test_name(suite_name, j);
fprintf(stdout, "%s\n", test_name);
}
}
}
......@@ -341,3 +405,47 @@ int main (int argc, char *argv[]) {
}
#endif
#ifdef ANDROID
#include <jni.h>
#include <CUnit/Util.h>
#define CALLBACK_BUFFER_SIZE 1024
static JNIEnv *current_env = NULL;
static jobject current_obj = 0;
void cunit_android_trace_handler(int level, const char *fmt, va_list args) {
char buffer[CALLBACK_BUFFER_SIZE];
JNIEnv *env = current_env;
if(env == NULL) return;
vsnprintf(buffer, CALLBACK_BUFFER_SIZE, fmt, args);
jstring javaString = (*env)->NewStringUTF(env, buffer);
jint javaLevel = level;
jclass cls = (*env)->GetObjectClass(env, current_obj);
jmethodID method = (*env)->GetMethodID(env, cls, "printLog", "(ILjava/lang/String;)V");
(*env)->CallVoidMethod(env, current_obj, method, javaLevel, javaString);
}
JNIEXPORT jint JNICALL Java_org_linphone_tester_Tester_run(JNIEnv *env, jobject obj, jobjectArray stringArray) {
int i, ret;
int argc = (*env)->GetArrayLength(env, stringArray);
char **argv = (char**) malloc(sizeof(char*) * argc);
for (i=0; i<argc; i++) {
jstring string = (jstring) (*env)->GetObjectArrayElement(env, stringArray, i);
const char *rawString = (const char *) (*env)->GetStringUTFChars(env, string, 0);
argv[i] = strdup(rawString);
(*env)->ReleaseStringUTFChars(env, argv[i], rawString);
}
current_env = env;
current_obj = obj;
CU_set_trace_handler(cunit_android_trace_handler);
ret = main(argc, argv);
current_env = NULL;
CU_set_trace_handler(NULL);
for (i=0; i<argc; i++) {
free(argv[i]);
}
free(argv);
return ret;
}
#endif
......@@ -40,16 +40,11 @@ typedef struct {
test_t *tests;
} test_suite_t;
#if WINAPI_FAMILY_PHONE_APP
#define FILE_PREFIX "Assets"
#else
#define FILE_PREFIX "./tester"
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern const char *liblinphone_tester_file_prefix;
extern test_suite_t setup_test_suite;
extern test_suite_t register_test_suite;
extern test_suite_t call_test_suite;
......
......@@ -62,8 +62,8 @@ void linphone_chat_message_state_change(LinphoneChatMessage* msg,LinphoneChatMes
}
static void text_message(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
char* to = linphone_address_as_string(marie->identity);
LinphoneChatRoom* chat_room = linphone_core_create_chat_room(pauline->lc,to);
linphone_chat_room_send_message(chat_room,"Bla bla bla bla");
......@@ -74,8 +74,8 @@ static void text_message(void) {
}
static void text_message_with_ack(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
char* to = linphone_address_as_string(marie->identity);
LinphoneChatRoom* chat_room = linphone_core_create_chat_room(pauline->lc,to);
LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu");
......@@ -88,8 +88,8 @@ static void text_message_with_ack(void) {
}
static void text_message_with_external_body(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
char* to = linphone_address_as_string(marie->identity);
LinphoneChatRoom* chat_room = linphone_core_create_chat_room(pauline->lc,to);
LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu");
......@@ -105,8 +105,8 @@ static void text_message_with_external_body(void) {
}
static void text_message_with_send_error(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
char* to = linphone_address_as_string(pauline->identity);
LinphoneChatRoom* chat_room = linphone_core_create_chat_room(marie->lc,to);
LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu");
......
......@@ -43,7 +43,7 @@ void notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf) {
}
static void simple_publish(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneProxyConfig* proxy;
linphone_core_get_default_proxy(marie->lc,&proxy);
linphone_proxy_config_edit(proxy);
......@@ -54,8 +54,8 @@ static void simple_publish(void) {
}
static void simple_subscribe(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(FILE_PREFIX, "pauline_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
const MSList* marie_friends = linphone_core_get_friend_list(marie->lc);
LinphoneFriend* friend;
CU_ASSERT_PTR_NOT_NULL_FATAL(marie_friends);
......@@ -74,7 +74,7 @@ static void simple_subscribe(void) {
}
static void unsubscribe_while_subscribing(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(FILE_PREFIX, "marie_rc");
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneFriend* friend = linphone_friend_new_with_addr("sip:toto@git.linphone.org"); /*any unexisting address*/
linphone_friend_edit(friend);
linphone_friend_enable_subscribes(friend,TRUE);
......
......@@ -234,7 +234,7 @@ static void authenticated_register_with_late_credentials(){
}
static LinphoneCore* configure_lc(LinphoneCoreVTable* v_table) {
return configure_lc_from(v_table, FILE_PREFIX, "multi_account_lrc", 3);
return configure_lc_from(v_table, liblinphone_tester_file_prefix, "multi_account_lrc", 3);
}
static void multiple_proxy(){
......@@ -313,7 +313,9 @@ static void io_recv_error(){
test_t register_tests[] = {
{ "Simple register", simple_register },
{ "TCP register", simple_tcp_register },
#ifndef ANDROID
{ "TLS register", simple_tls_register },
#endif
{ "Simple authenticated register", simple_authenticated_register },
{ "Digest auth without initial credentials", authenticated_register_with_no_initial_credentials },
{ "Authenticated register with late credentials", authenticated_register_with_late_credentials },
......
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