mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Add some upnp in tester
This commit is contained in:
parent
8d9cb2fd7d
commit
572f297862
5 changed files with 68 additions and 1 deletions
|
|
@ -4,7 +4,7 @@ if BUILD_CUNIT_TESTS
|
|||
noinst_PROGRAMS=liblinphone_tester
|
||||
TESTS=$(noinst_PROGRAMS)
|
||||
|
||||
liblinphone_tester_SOURCES= liblinphone_tester.c setup_tester.c register_tester.c message_tester.c call_tester.c presence_tester.c
|
||||
liblinphone_tester_SOURCES= liblinphone_tester.c setup_tester.c register_tester.c message_tester.c call_tester.c presence_tester.c upnp_tester.c
|
||||
|
||||
|
||||
#liblinphone_tester_CFLAGS=$(CUNIT_CFLAGS)
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ void liblinphone_tester_init(void) {
|
|||
add_test_suite(&call_test_suite);
|
||||
add_test_suite(&message_test_suite);
|
||||
add_test_suite(&presence_test_suite);
|
||||
add_test_suite(&upnp_test_suite);
|
||||
}
|
||||
|
||||
void liblinphone_tester_uninit(void) {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ extern test_suite_t register_test_suite;
|
|||
extern test_suite_t call_test_suite;
|
||||
extern test_suite_t message_test_suite;
|
||||
extern test_suite_t presence_test_suite;
|
||||
extern test_suite_t upnp_test_suite;
|
||||
|
||||
|
||||
extern int liblinphone_tester_nb_test_suites(void);
|
||||
|
|
|
|||
2
tester/upnp_rc
Normal file
2
tester/upnp_rc
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[net]
|
||||
firewall_policy=4
|
||||
63
tester/upnp_tester.c
Normal file
63
tester/upnp_tester.c
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
belle-sip - SIP (RFC3261) library.
|
||||
Copyright (C) 2010 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 3 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 <stdio.h>
|
||||
#include "CUnit/Basic.h"
|
||||
#include "linphonecore.h"
|
||||
#include "lpconfig.h"
|
||||
#include "private.h"
|
||||
#include "liblinphone_tester.h"
|
||||
|
||||
static void upnp_start_n_stop(void) {
|
||||
int tmp = 0;
|
||||
LinphoneCoreManager* lc_upnp = linphone_core_manager_new2(liblinphone_tester_file_prefix, "upnp_rc", FALSE);
|
||||
wait_for(lc_upnp->lc,lc_upnp->lc,&tmp,1);
|
||||
CU_ASSERT_TRUE(lc_upnp->lc->upnp != NULL);
|
||||
linphone_core_manager_destroy(lc_upnp);
|
||||
}
|
||||
|
||||
static void upnp_check_state(void) {
|
||||
int tmp = 0;
|
||||
LinphoneCoreManager* lc_upnp = linphone_core_manager_new2(liblinphone_tester_file_prefix, "upnp_rc", FALSE);
|
||||
wait_for(lc_upnp->lc,lc_upnp->lc,&tmp,1);
|
||||
CU_ASSERT_TRUE(linphone_core_get_upnp_state(lc_upnp->lc) == LinphoneUpnpStateOk);
|
||||
linphone_core_manager_destroy(lc_upnp);
|
||||
}
|
||||
|
||||
static void upnp_check_ipaddress(void) {
|
||||
int tmp = 0;
|
||||
LinphoneCoreManager* lc_upnp = linphone_core_manager_new2(liblinphone_tester_file_prefix, "upnp_rc", FALSE);
|
||||
wait_for(lc_upnp->lc,lc_upnp->lc,&tmp,1);
|
||||
const char *addr = linphone_core_get_upnp_external_ipaddress(lc_upnp->lc);
|
||||
CU_ASSERT_TRUE(addr != NULL && strlen(addr)>=7);
|
||||
linphone_core_manager_destroy(lc_upnp);
|
||||
}
|
||||
|
||||
test_t upnp_tests[] = {
|
||||
{ "Start and stop", upnp_start_n_stop },
|
||||
{ "Check state", upnp_check_state },
|
||||
{ "Check ip address", upnp_check_ipaddress },
|
||||
};
|
||||
|
||||
test_suite_t upnp_test_suite = {
|
||||
"Upnp",
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(upnp_tests) / sizeof(upnp_tests[0]),
|
||||
upnp_tests
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue