diff --git a/tester/Makefile.am b/tester/Makefile.am
index 801d20ca0..24523893f 100644
--- a/tester/Makefile.am
+++ b/tester/Makefile.am
@@ -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)
diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c
index f495b3c42..54f00a698 100644
--- a/tester/liblinphone_tester.c
+++ b/tester/liblinphone_tester.c
@@ -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) {
diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h
index 82aa5181b..f9d73765b 100644
--- a/tester/liblinphone_tester.h
+++ b/tester/liblinphone_tester.h
@@ -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);
diff --git a/tester/upnp_rc b/tester/upnp_rc
new file mode 100644
index 000000000..3b04fd077
--- /dev/null
+++ b/tester/upnp_rc
@@ -0,0 +1,2 @@
+ [net]
+ firewall_policy=4
diff --git a/tester/upnp_tester.c b/tester/upnp_tester.c
new file mode 100644
index 000000000..95a132e62
--- /dev/null
+++ b/tester/upnp_tester.c
@@ -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 .
+*/
+
+#include
+#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
+};