Commit 6f819de1 authored by Guillaume BIENKOWSKI's avatar Guillaume BIENKOWSKI
Browse files

Preliminary work for tester compilation for iOS

parent cac1551a
......@@ -49,6 +49,8 @@ AM_PROG_CC_C_O
AC_CHECK_PROGS(MD5SUM,[md5sum md5])
AM_CONDITIONAL(HAVE_MD5SUM,test -n $MD5SUM)
ios_found=no
case $target in
*mingw32ce)
CFLAGS="$CFLAGS -D_WIN32_WCE -DORTP_STATIC -D_WIN32_WINNT=0x0501"
......@@ -68,7 +70,9 @@ case $target in
;;
armv6-apple-darwin|armv7-apple-darwin|i386-apple-darwin|armv7s-apple-darwin)
CFLAGS="$CFLAGS -DTARGET_OS_IPHONE=1 "
LIBS="$LIBS -framework CoreFoundation -framework AudioToolbox -framework CoreAudio -framework Foundation -framework QuartzCore -framework OpenGLES -framework UIKit -framework AVFoundation"
ios_found=yes
AC_PROG_OBJC
;;
x86_64-apple-darwin*|i686-apple-darwin*)
MSPLUGINS_CFLAGS=""
......@@ -79,8 +83,7 @@ case $target in
esac
AM_CONDITIONAL(BUILD_IOS, test x$ios_found = xyes)
AC_SUBST(ACLOCAL_MACOS_FLAGS)
AC_SUBST(CONSOLE_FLAGS)
......
......@@ -18,18 +18,24 @@ liblinphone_tester_SOURCES= liblinphone_tester.c liblinphone_tester.h\
remote_provisioning_tester.c
#liblinphone_tester_CFLAGS=$(CUNIT_CFLAGS)
AM_CPPFLAGS=-I$(top_srcdir)/include -I$(top_srcdir)/coreapi
#liblinphone_tester_LDFLAGS=$(CUNIT_LIBS)
LDADD=$(top_builddir)/coreapi/liblinphone.la $(BELLESIP_LIBS) $(LIBXML2_LIBS)
AM_LDFLAGS = $(CUNIT_LIBS)
AM_CPPFLAGS=-I$(top_srcdir)/include -I$(top_srcdir)/coreapi
AM_CFLAGS = $(STRICT_OPTIONS) -DIN_LINPHONE $(ORTP_CFLAGS) $(MEDIASTREAMER_CFLAGS) $(CUNIT_CFLAGS) $(BELLESIP_CFLAGS) $(LIBXML2_CFLAGS)
AM_OBJCFLAGS = $(AM_CFLAGS) -DNO_XCODE
LDADD=$(top_builddir)/coreapi/liblinphone.la $(BELLESIP_LIBS) $(LIBXML2_LIBS)
liblinphone_tester_LDFLAGS=
AM_LDFLAGS=$(CUNIT_LIBS)
if BUILD_IOS
liblinphone_tester_SOURCES += liblinphonetester_ios.m liblinphonetester_ios.h
liblinphone_tester_LDFLAGS += -framework CoreFoundation -framework AudioToolbox -framework CoreAudio -framework Foundation -framework QuartzCore -framework OpenGLES -framework UIKit -framework AVFoundation
# we have to force the linker to use c-style link when mixing Obj-C and C sources, otherwise the Obj-C linker is used, which gives strange errors (UTF8?)
liblinphone_tester_LINK = $(LINK)
endif
AM_CFLAGS=$(STRICT_OPTIONS) -DIN_LINPHONE $(ORTP_CFLAGS) $(MEDIASTREAMER_CFLAGS) $(CUNIT_CFLAGS) $(BELLESIP_CFLAGS) $(LIBXML2_CFLAGS)
test: liblinphone_tester
./liblinphone_tester --config $(abs_srcdir)
......
/*
liblinphone_tester - liblinphone test suite
Copyright (C) 2013 Belledonne Communications SARL
liblinphone_tester - liblinphone test suite
Copyright (C) 2013 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "CUnit/Basic.h"
......@@ -35,6 +35,9 @@ static int nb_test_suites = 0;
static unsigned char curses = 0;
#endif
#if TARGET_OS_IPHONE
#include "liblinphonetester_ios.h"
#endif
const char* test_domain="sipopen.example.org";
......@@ -45,13 +48,11 @@ const char* test_route="sip2.linphone.org";
#if WINAPI_FAMILY_PHONE_APP
const char *liblinphone_tester_file_prefix="Assets";
#else
#ifdef __QNX__
#elif defined(__QNX__)
const char *liblinphone_tester_file_prefix="./app/native/assets/";
#else
const char *liblinphone_tester_file_prefix=".";
#endif
#endif
const char *userhostsfile = "tester_hosts";
......@@ -78,8 +79,8 @@ LinphoneAddress * create_linphone_address(const char * domain) {
static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
stats* counters;
ms_message("Auth info requested for user id [%s] at realm [%s]\n"
,username
,realm);
,username
,realm);
counters = get_stats(lc);
counters->number_of_auth_info_requested++;
}
......@@ -146,9 +147,9 @@ bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) {
int retry=0;
MSList* iterator;
while ((counter==NULL || *counter<value) && retry++ <timeout_ms/100) {
for (iterator=lcs;iterator!=NULL;iterator=iterator->next) {
linphone_core_iterate((LinphoneCore*)(iterator->data));
}
for (iterator=lcs;iterator!=NULL;iterator=iterator->next) {
linphone_core_iterate((LinphoneCore*)(iterator->data));
}
ms_usleep(100000);
}
if(counter && *counter<value) return FALSE;
......@@ -160,7 +161,7 @@ static void set_codec_enable(LinphoneCore* lc,const char* type,int rate,bool_t e
MSList* codecs_it;
PayloadType* pt;
for (codecs_it=codecs;codecs_it!=NULL;codecs_it=codecs_it->next) {
linphone_core_enable_payload_type(lc,(PayloadType*)codecs_it->data,0);
linphone_core_enable_payload_type(lc,(PayloadType*)codecs_it->data,0);
}
if((pt = linphone_core_find_payload_type(lc,type,rate,1))) {
linphone_core_enable_payload_type(lc,pt, enable);
......@@ -202,7 +203,7 @@ LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_f
mgr->v_table.notify_received=linphone_notify_received;
mgr->v_table.publish_state_changed=linphone_publish_state_changed;
mgr->v_table.configuring_status=linphone_configuration_status;
reset_counters(&mgr->stat);
if (rc_file) rc_path = ms_strdup_printf("rcfiles/%s", rc_file);
mgr->lc=configure_lc_from(&mgr->v_table, liblinphone_tester_file_prefix, rc_path, mgr);
......@@ -413,12 +414,12 @@ void linphone_android_log_handler(int prio, const char *fmt, va_list args) {
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;
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);
}
......@@ -430,6 +431,7 @@ static void liblinphone_tester_qnx_log_handler(OrtpLogLevel lev, const char *fmt
}
#endif /* __QNX__ */
void helper(const char *name) {
fprintf(stderr,"%s \t--help\n"
"\t\t\t--verbose\n"
......@@ -449,13 +451,21 @@ void helper(const char *name) {
}
#define CHECK_ARG(argument, index, argc) \
if(index >= argc) { \
fprintf(stderr, "Missing argument for \"%s\"\n", argument); \
return -1; \
} \
if(index >= argc) { \
fprintf(stderr, "Missing argument for \"%s\"\n", argument); \
return -1; \
} \
#ifndef WINAPI_FAMILY_PHONE_APP
int main (int argc, char *argv[]) {
#if TARGET_OS_IPHONE
int ios_tester_main(int argc, char * argv[])
#else
int main (int argc, char *argv[])
#endif
{
int i,j;
int ret;
const char *suite_name=NULL;
......@@ -465,6 +475,8 @@ int main (int argc, char *argv[]) {
linphone_core_set_log_handler(linphone_android_ortp_log_handler);
#elif defined(__QNX__)
linphone_core_set_log_handler(liblinphone_tester_qnx_log_handler);
#elif TARGET_OS_IPHONE
linphone_core_set_log_handler(liblinphone_tester_ios_log_handler);
#else
linphone_core_set_log_file(NULL);
#endif
......
......@@ -223,5 +223,6 @@ const char *liblinphone_tester_get_notify_content(void);
void liblinphone_tester_chat_message_state_change(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud);
void liblinphone_tester_check_rtcp(LinphoneCoreManager* caller, LinphoneCoreManager* callee);
#endif /* LIBLINPHONE_TESTER_H_ */
/*
liblinphone_tester - liblinphone test suite
Copyright (C) 2013 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ortp/ortp.h"
int apple_start_tests(int argc, char* argv[]);
void liblinphone_tester_ios_log_handler(OrtpLogLevel level, const char* fmt, va_list args);
\ No newline at end of file
/*
liblinphone_tester - liblinphone test suite
Copyright (C) 2013 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "liblinphonetester_ios.h"
#include <pthread.h>
#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
extern int ios_tester_main(int argc, char * argv[]);
int g_argc;
char** g_argv;
static void* apple_main(void* data) {
ios_tester_main(g_argc,g_argv);
return NULL;
}
int apple_start_tests(int argc, char* argv[])
{
pthread_t main_thread;
g_argc=argc;
g_argv=argv;
return (int)pthread_create(&main_thread,NULL,apple_main,NULL);
}
void liblinphone_tester_ios_log_handler(OrtpLogLevel level, const char* fmt, va_list args)
{
NSLogv([NSString stringWithUTF8String:fmt], args);
}
#ifdef NO_XCODE /* when compiling under xcode the main is elsewhere */
int main( int argc, char* argv[]){
return ios_tester_main(argc, argv);
}
#endif
\ No newline at end of file
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