aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alljoyn_c/inc/alljoyn_c/MsgArg.h2
-rw-r--r--alljoyn_c/src/Observer.cc15
-rw-r--r--alljoyn_c/unit_test/AboutDataTest.cc4
-rw-r--r--alljoyn_c/unit_test/AboutIconTest.cc4
-rw-r--r--alljoyn_c/unit_test/AboutListenerTest.cc2
-rw-r--r--alljoyn_c/unit_test/AboutListenerTestApi.cc29
-rw-r--r--alljoyn_c/unit_test/AboutObjTest.cc19
-rw-r--r--alljoyn_c/unit_test/AboutObjectDescriptionTest.cc2
-rw-r--r--alljoyn_c/unit_test/AboutProxyTest.cc18
-rw-r--r--alljoyn_c/unit_test/ApplicationStateListenerTest.cc10
-rw-r--r--alljoyn_c/unit_test/AuthListenerTest.cc2
-rw-r--r--alljoyn_c/unit_test/BusAttachmentTest.cc25
-rw-r--r--alljoyn_c/unit_test/InterfaceDescriptionTest.cc42
-rw-r--r--alljoyn_c/unit_test/ObserverTest.cc38
-rw-r--r--alljoyn_c/unit_test/PermissionConfigurationListenerTest.cc22
-rw-r--r--alljoyn_c/unit_test/PermissionConfiguratorTest.cc17
-rw-r--r--alljoyn_c/unit_test/SecurityApplicationProxyTest.cc4
-rw-r--r--alljoyn_core/router/test/ardp.cc92
-rw-r--r--alljoyn_core/router/test/ardptest.cc20
19 files changed, 261 insertions, 106 deletions
diff --git a/alljoyn_c/inc/alljoyn_c/MsgArg.h b/alljoyn_c/inc/alljoyn_c/MsgArg.h
index 697b586..ddcad8f 100644
--- a/alljoyn_c/inc/alljoyn_c/MsgArg.h
+++ b/alljoyn_c/inc/alljoyn_c/MsgArg.h
@@ -362,7 +362,7 @@ extern AJ_API QStatus CDECL_CALL alljoyn_msgarg_get(alljoyn_msgarg arg, const ch
/**
* create a copy of a message argument. This will create a new alljoyn_msgarg and
- * must be cleaned up using alljoyn_msgarg_detroy.
+ * must be cleaned up using alljoyn_msgarg_destroy.
*
* @param source the alljoyn_msgarg to be copied
*
diff --git a/alljoyn_c/src/Observer.cc b/alljoyn_c/src/Observer.cc
index cca2cd8..77f0921 100644
--- a/alljoyn_c/src/Observer.cc
+++ b/alljoyn_c/src/Observer.cc
@@ -181,6 +181,13 @@ ObserverC::ObserverC(alljoyn_busattachment _cbus,
ObserverC::~ObserverC()
{
+ proxiesLock.Lock(MUTEX_CONTEXT);
+ ObjectMap::iterator it = proxies.begin();
+ while (it != proxies.end()) {
+ alljoyn_proxybusobject_ref_decref(it->second);
+ it = proxies.erase(it);
+ }
+ proxiesLock.Unlock(MUTEX_CONTEXT);
}
void ObserverC::Detach()
@@ -261,6 +268,7 @@ void ObserverC::UnregisterAllListeners()
if (it != listeners.end()) {
ProtectedObserverListener l = *it;
listeners.erase(it);
+ delete (*l);
}
it = listeners.begin();
}
@@ -383,6 +391,13 @@ void ObserverC::ObjectDiscovered(const ObjectId& oid,
/* insert in proxy map */
alljoyn_proxybusobject_ref proxyref = alljoyn_proxybusobject_ref_create(proxy);
proxiesLock.Lock(MUTEX_CONTEXT);
+ for (auto it = proxies.begin(); it != proxies.end(); ++it) {
+ if (it->first == oid) {
+ alljoyn_proxybusobject_ref_decref(it->second);
+ proxies.erase(it);
+ break;
+ }
+ }
proxies[oid] = proxyref;
proxiesLock.Unlock(MUTEX_CONTEXT);
diff --git a/alljoyn_c/unit_test/AboutDataTest.cc b/alljoyn_c/unit_test/AboutDataTest.cc
index 07adb9d..3aaa90f 100644
--- a/alljoyn_c/unit_test/AboutDataTest.cc
+++ b/alljoyn_c/unit_test/AboutDataTest.cc
@@ -1122,6 +1122,8 @@ TEST(AboutDataTest, GetMsgArgWithOEMSpecificField) {
status = alljoyn_aboutdata_setfield(aboutData, "SupportNumber", arg, "es");
EXPECT_EQ(ER_OK, status) << " Actual Status: " << QCC_StatusText(status);
+ alljoyn_msgarg_destroy(arg);
+
alljoyn_msgarg aboutArg = alljoyn_msgarg_create();
status = alljoyn_aboutdata_getaboutdata(aboutData, aboutArg, "en");
@@ -1224,6 +1226,8 @@ TEST(AboutDataTest, InitUsingMsgArg) {
status = alljoyn_aboutdata_setfield(aboutData, "SupportNumber", arg, "es");
EXPECT_EQ(ER_OK, status) << " Actual Status: " << QCC_StatusText(status);
+ alljoyn_msgarg_destroy(arg);
+
alljoyn_msgarg aboutArg = alljoyn_msgarg_create();
status = alljoyn_aboutdata_getaboutdata(aboutData, aboutArg, "en");
diff --git a/alljoyn_c/unit_test/AboutIconTest.cc b/alljoyn_c/unit_test/AboutIconTest.cc
index 088a61a..2328753 100644
--- a/alljoyn_c/unit_test/AboutIconTest.cc
+++ b/alljoyn_c/unit_test/AboutIconTest.cc
@@ -100,15 +100,19 @@ TEST(AboutIconTest, isAnnounced) {
EXPECT_EQ(ER_OK, status) << " Actual Status: " << QCC_StatusText(status);
alljoyn_abouticonobj aboutIcon = alljoyn_abouticonobj_create(g_msgBus, icon);
+ alljoyn_abouticon_destroy(icon);
alljoyn_msgarg aodArg = alljoyn_msgarg_create();
status = (*(ajn::BusAttachment*) g_msgBus).GetInternal().GetAnnouncedObjectDescription(*(ajn::MsgArg*)aodArg);
alljoyn_aboutobjectdescription aod =
alljoyn_aboutobjectdescription_create_full(aodArg);
+ alljoyn_msgarg_destroy(aodArg);
+
EXPECT_EQ(ER_OK, status) << " Actual Status: " << QCC_StatusText(status);
EXPECT_TRUE(alljoyn_aboutobjectdescription_haspath(aod, "/About/DeviceIcon"));
+ alljoyn_aboutobjectdescription_destroy(aod);
alljoyn_abouticonobj_destroy(aboutIcon);
status = alljoyn_busattachment_stop(g_msgBus);
EXPECT_EQ(ER_OK, status) << " Actual Status: " << QCC_StatusText(status);
diff --git a/alljoyn_c/unit_test/AboutListenerTest.cc b/alljoyn_c/unit_test/AboutListenerTest.cc
index 641e6bd..ee83a6d 100644
--- a/alljoyn_c/unit_test/AboutListenerTest.cc
+++ b/alljoyn_c/unit_test/AboutListenerTest.cc
@@ -116,6 +116,7 @@ class AboutListenerTest : public testing::Test {
ALLJOYN_TRANSPORT_ANY);
listener = alljoyn_sessionportlistener_create(&callbacks, nullptr);
status = alljoyn_busattachment_bindsessionport(serviceBus, &port, opts, listener);
+ alljoyn_sessionopts_destroy(opts);
ASSERT_EQ(ER_OK, status) << " Actual Status: " << QCC_StatusText(status);
}
@@ -679,6 +680,7 @@ TEST_F(AboutListenerTest, MultipleAnnounceListenersUnregisterAll) {
EXPECT_EQ(ER_OK, status) << " Actual Status: " << QCC_StatusText(status);
destroy_about_test_about_listener(aboutListener1);
destroy_about_test_about_listener(aboutListener2);
+ destroy_about_test_about_listener(aboutListener3);
destroy_about_obj_test_bus_object(altObj);
alljoyn_aboutobj_destroy(aboutObj);
alljoyn_busattachment_destroy(clientBus);
diff --git a/alljoyn_c/unit_test/AboutListenerTestApi.cc b/alljoyn_c/unit_test/AboutListenerTestApi.cc
index a62b58f..383e08d 100644
--- a/alljoyn_c/unit_test/AboutListenerTestApi.cc
+++ b/alljoyn_c/unit_test/AboutListenerTestApi.cc
@@ -98,6 +98,9 @@ static void AJ_CALL non_128_bit_app_id_about_listener_announced_cb(const void* c
QCC_UNUSED(objectDescriptionArg);
announce_non_128_bit_app_id_about_listener* listener =
(announce_non_128_bit_app_id_about_listener*)(context);
+ if (listener->aboutData != NULL) {
+ alljoyn_msgarg_destroy(listener->aboutData);
+ }
listener->aboutData = alljoyn_msgarg_copy(aboutDataArg);
alljoyn_msgarg_stabilize(listener->aboutData);
announceListenerFlags[0] = QCC_TRUE;
@@ -176,6 +179,7 @@ static void AJ_CALL filtered_about_listener_cb(const void* context,
}
}
}
+ alljoyn_aboutobjectdescription_destroy(aod);
}
int setExpectInterfaces(filtered_about_listener* listener, const char* path,
@@ -185,7 +189,7 @@ int setExpectInterfaces(filtered_about_listener* listener, const char* path,
strcpy(listener->objpath, path);
for (; i < infCount; ++i) {
listener->expectedinterfaceset[i] =
- (char*) malloc(sizeof(char) * strlen(interfaces[i]));
+ (char*) malloc(sizeof(char) * (strlen(interfaces[i]) + 1));
strcpy(listener->expectedinterfaceset[i], interfaces[i]);
}
listener->interfacecnt = infCount;
@@ -202,6 +206,7 @@ about_test_about_listener* create_about_test_about_listener(int i)
callback->about_listener_announced = announced_cb;
result->listener = alljoyn_aboutlistener_create(callback, &(result->i));
+ delete callback;
return result;
}
@@ -279,6 +284,7 @@ about_test_wildcard_about_listener* create_about_test_wildcard_about_listener()
callback->about_listener_announced = about_test_wildcard_about_listener_announced_cb;
result->listener = alljoyn_aboutlistener_create(callback, result);
+ delete callback;
return result;
}
@@ -293,6 +299,8 @@ announce_non_128_bit_app_id_about_listener* create_announce_non_128_bit_app_id_a
callback->about_listener_announced = non_128_bit_app_id_about_listener_announced_cb;
result->listener = alljoyn_aboutlistener_create(callback, result);
result->aboutData = NULL;
+
+ delete callback;
return result;
}
@@ -308,6 +316,7 @@ remove_object_description_about_listener* create_remove_object_description_about
callback->about_listener_announced = remove_object_description_about_listener_cb;
result->listener = alljoyn_aboutlistener_create(callback, result);
+ delete callback;
return result;
}
@@ -321,6 +330,8 @@ filtered_about_listener* create_filtered_about_listener()
(alljoyn_aboutlistener_callback*) malloc(sizeof(alljoyn_aboutlistener_callback));
callback->about_listener_announced = filtered_about_listener_cb;
result->listener = alljoyn_aboutlistener_create(callback, result);
+
+ delete callback;
return result;
}
@@ -378,11 +389,15 @@ void destroy_remove_object_description_about_listener(remove_object_description_
void destroy_filtered_about_listener(filtered_about_listener* aboutListener)
{
- if (!aboutListener) {
- return;
- }
- if (aboutListener->listener) {
- alljoyn_aboutlistener_destroy(aboutListener->listener);
- aboutListener->listener = NULL;
+ if (aboutListener != NULL) {
+ if (aboutListener->listener) {
+ alljoyn_aboutlistener_destroy(aboutListener->listener);
+ aboutListener->listener = NULL;
+ }
+ for (size_t i = 0; i < aboutListener->interfacecnt; ++i) {
+ free(aboutListener->expectedinterfaceset[i]);
+ }
+ free(aboutListener);
+ aboutListener = NULL;
}
}
diff --git a/alljoyn_c/unit_test/AboutObjTest.cc b/alljoyn_c/unit_test/AboutObjTest.cc
index f35d53c..12cc3c1 100644
--- a/alljoyn_c/unit_test/AboutObjTest.cc
+++ b/alljoyn_c/unit_test/AboutObjTest.cc
@@ -177,13 +177,16 @@ static about_obj_test_about_listener_2* create_about_obj_test_about_listener_2()
static void destroy_about_obj_test_about_listener_2(about_obj_test_about_listener_2* listener)
{
- if (listener->busName) {
- free(listener->busName);
- listener->busName = NULL;
- }
- if (listener->listener) {
- alljoyn_aboutlistener_destroy(listener->listener);
- listener = NULL;
+ if (listener != NULL) {
+ if (listener->busName) {
+ free(listener->busName);
+ listener->busName = NULL;
+ }
+ if (listener->listener) {
+ alljoyn_aboutlistener_destroy(listener->listener);
+ listener->listener = NULL;
+ }
+ free(listener);
}
}
@@ -244,6 +247,7 @@ class AboutObjTest : public testing::Test {
listener = alljoyn_sessionportlistener_create(&callbacks, NULL);
status = alljoyn_busattachment_bindsessionport(serviceBus, &port, opts, listener);
+ alljoyn_sessionopts_destroy(opts);
EXPECT_EQ(ER_OK, status) << " Actual Status: " << QCC_StatusText(status);
}
@@ -351,6 +355,7 @@ TEST_F(AboutObjTest, AnnounceMissingRequiredField) {
EXPECT_EQ(ER_OK, status) << " Actual Status: " << QCC_StatusText(status);
alljoyn_aboutdata_destroy(badAboutData);
+ alljoyn_aboutobj_destroy(aboutObj);
}
TEST_F(AboutObjTest, SetAnnounceFlag) {
diff --git a/alljoyn_c/unit_test/AboutObjectDescriptionTest.cc b/alljoyn_c/unit_test/AboutObjectDescriptionTest.cc
index 0732191..028ff46 100644
--- a/alljoyn_c/unit_test/AboutObjectDescriptionTest.cc
+++ b/alljoyn_c/unit_test/AboutObjectDescriptionTest.cc
@@ -135,6 +135,7 @@ TEST(AboutObjectDescriptionTest, Construct) {
status = alljoyn_abouticon_seturl(aicon, "image/png", "http://www.example.com");
EXPECT_EQ(ER_OK, status) << " Actual Status: " << QCC_StatusText(status);
alljoyn_abouticonobj aboutIconObj = alljoyn_abouticonobj_create(bus, aicon);
+ alljoyn_abouticon_destroy(aicon);
const qcc::String interfaceQcc = "<node>"
"<interface name='org.alljoyn.test'>"
@@ -228,6 +229,7 @@ TEST(AboutObjectDescriptionTest, GetMsgArg) {
alljoyn_msgarg argObj = alljoyn_msgarg_create();
((BusAttachment*)bus)->GetInternal().GetAnnouncedObjectDescription(*((MsgArg*)argObj));
alljoyn_aboutobjectdescription aod = alljoyn_aboutobjectdescription_create_full(argObj);
+ alljoyn_msgarg_destroy(argObj);
alljoyn_msgarg arg = alljoyn_msgarg_create();
alljoyn_aboutobjectdescription_getmsgarg(aod, arg);
diff --git a/alljoyn_c/unit_test/AboutProxyTest.cc b/alljoyn_c/unit_test/AboutProxyTest.cc
index eba62ff..29e1c75 100644
--- a/alljoyn_c/unit_test/AboutProxyTest.cc
+++ b/alljoyn_c/unit_test/AboutProxyTest.cc
@@ -220,13 +220,16 @@ static about_obj_test_about_listener_2* create_about_obj_test_about_listener_2()
static void destroy_about_obj_test_about_listener_2(about_obj_test_about_listener_2* listener)
{
- if (listener->busName) {
- free(listener->busName);
- listener->busName = NULL;
- }
- if (listener->listener) {
- alljoyn_aboutlistener_destroy(listener->listener);
- listener = NULL;
+ if (listener != NULL) {
+ if (listener->busName) {
+ free(listener->busName);
+ listener->busName = NULL;
+ }
+ if (listener->listener) {
+ alljoyn_aboutlistener_destroy(listener->listener);
+ listener->listener = NULL;
+ }
+ free(listener);
}
}
@@ -271,6 +274,7 @@ class AboutProxyTest : public testing::Test {
listener = alljoyn_sessionportlistener_create(&callbacks, NULL);
status = alljoyn_busattachment_bindsessionport(serviceBus, &port, opts, listener);
+ alljoyn_sessionopts_destroy(opts);
EXPECT_EQ(ER_OK, status) << " Actual Status: " << QCC_StatusText(status);
}
diff --git a/alljoyn_c/unit_test/ApplicationStateListenerTest.cc b/alljoyn_c/unit_test/ApplicationStateListenerTest.cc
index de7f8ae..013f35e 100644
--- a/alljoyn_c/unit_test/ApplicationStateListenerTest.cc
+++ b/alljoyn_c/unit_test/ApplicationStateListenerTest.cc
@@ -162,12 +162,18 @@ class ApplicationStateListenerTest : public testing::Test {
TEST_F(ApplicationStateListenerTest, shouldCreateListenerWithCallbacksAndNullContext)
{
- EXPECT_NE(nullptr, alljoyn_applicationstatelistener_create(&m_nonNullCallbacks, nullptr));
+ m_listener = alljoyn_applicationstatelistener_create(&m_nonNullCallbacks, nullptr);
+ EXPECT_NE(nullptr, m_listener);
+ alljoyn_applicationstatelistener_destroy(m_listener);
+ m_listener = nullptr;
}
TEST_F(ApplicationStateListenerTest, shouldCreateListenerWithCallbacksAndNonNullContext)
{
- EXPECT_NE(nullptr, alljoyn_applicationstatelistener_create(&m_nonNullCallbacks, this));
+ m_listener = alljoyn_applicationstatelistener_create(&m_nonNullCallbacks, this);
+ EXPECT_NE(nullptr, m_listener);
+ alljoyn_applicationstatelistener_destroy(m_listener);
+ m_listener = nullptr;
}
TEST_F(ApplicationStateListenerTest, shouldDestroyNullListenerWithoutException)
diff --git a/alljoyn_c/unit_test/AuthListenerTest.cc b/alljoyn_c/unit_test/AuthListenerTest.cc
index bc47283..b90b9e2 100644
--- a/alljoyn_c/unit_test/AuthListenerTest.cc
+++ b/alljoyn_c/unit_test/AuthListenerTest.cc
@@ -1047,6 +1047,8 @@ TEST(DefaultAuthListenerTest, shouldCreateAuthListenerWithEmptyCallbacks)
alljoyn_authlistener listener = alljoyn_authlistener_create(&s_emptySynchronousCallbacks, nullptr);
EXPECT_NE(nullptr, listener);
+
+ alljoyn_authlistener_destroy(listener);
}
TEST_F(DefaultAuthListenerNoPasswordTest, shouldReturnTrueForDefaultVerifyCredentials)
diff --git a/alljoyn_c/unit_test/BusAttachmentTest.cc b/alljoyn_c/unit_test/BusAttachmentTest.cc
index 360fda6..6982ef4 100644
--- a/alljoyn_c/unit_test/BusAttachmentTest.cc
+++ b/alljoyn_c/unit_test/BusAttachmentTest.cc
@@ -210,6 +210,8 @@ TEST_F(BusAttachmentSecurity20Test, shouldReturnErrorWhenUnregisteringUnknownLis
CreateApplicationStateListener(&listener);
EXPECT_EQ(ER_APPLICATION_STATE_LISTENER_NO_SUCH_LISTENER, alljoyn_busattachment_unregisterapplicationstatelistener(m_securityAgent, listener));
+
+ alljoyn_applicationstatelistener_destroy(listener);
}
TEST_F(BusAttachmentSecurity20Test, shouldRegisterSuccessfullyForNewListener)
@@ -218,6 +220,8 @@ TEST_F(BusAttachmentSecurity20Test, shouldRegisterSuccessfullyForNewListener)
CreateApplicationStateListener(&listener);
EXPECT_EQ(ER_OK, alljoyn_busattachment_registerapplicationstatelistener(m_securityAgent, listener));
+
+ alljoyn_applicationstatelistener_destroy(listener);
}
TEST_F(BusAttachmentSecurity20Test, shouldUnregisterSuccessfullyForSameListener)
@@ -226,8 +230,9 @@ TEST_F(BusAttachmentSecurity20Test, shouldUnregisterSuccessfullyForSameListener)
CreateApplicationStateListener(&listener);
ASSERT_EQ(ER_OK, alljoyn_busattachment_registerapplicationstatelistener(m_securityAgent, listener));
-
EXPECT_EQ(ER_OK, alljoyn_busattachment_unregisterapplicationstatelistener(m_securityAgent, listener));
+
+ alljoyn_applicationstatelistener_destroy(listener);
}
TEST_F(BusAttachmentSecurity20Test, shouldReturnErrorWhenRegisteringSameListenerTwice)
@@ -236,8 +241,9 @@ TEST_F(BusAttachmentSecurity20Test, shouldReturnErrorWhenRegisteringSameListener
CreateApplicationStateListener(&listener);
ASSERT_EQ(ER_OK, alljoyn_busattachment_registerapplicationstatelistener(m_securityAgent, listener));
-
EXPECT_EQ(ER_APPLICATION_STATE_LISTENER_ALREADY_EXISTS, alljoyn_busattachment_registerapplicationstatelistener(m_securityAgent, listener));
+
+ alljoyn_applicationstatelistener_destroy(listener);
}
TEST_F(BusAttachmentSecurity20Test, shouldReturnErrorWhenUnregisteringSameListenerTwice)
@@ -247,8 +253,9 @@ TEST_F(BusAttachmentSecurity20Test, shouldReturnErrorWhenUnregisteringSameListen
ASSERT_EQ(ER_OK, alljoyn_busattachment_registerapplicationstatelistener(m_securityAgent, listener));
ASSERT_EQ(ER_OK, alljoyn_busattachment_unregisterapplicationstatelistener(m_securityAgent, listener));
-
EXPECT_EQ(ER_APPLICATION_STATE_LISTENER_NO_SUCH_LISTENER, alljoyn_busattachment_unregisterapplicationstatelistener(m_securityAgent, listener));
+
+ alljoyn_applicationstatelistener_destroy(listener);
}
TEST_F(BusAttachmentSecurity20Test, shouldRegisterSameListenerSuccessfullyAfterUnregister)
@@ -260,6 +267,8 @@ TEST_F(BusAttachmentSecurity20Test, shouldRegisterSameListenerSuccessfullyAfterU
ASSERT_EQ(ER_OK, alljoyn_busattachment_unregisterapplicationstatelistener(m_securityAgent, listener));
EXPECT_EQ(ER_OK, alljoyn_busattachment_registerapplicationstatelistener(m_securityAgent, listener));
+
+ alljoyn_applicationstatelistener_destroy(listener);
}
TEST_F(BusAttachmentSecurity20Test, shouldCallStateListenerAfterRegister)
@@ -272,6 +281,8 @@ TEST_F(BusAttachmentSecurity20Test, shouldCallStateListenerAfterRegister)
ChangeApplicationState();
EXPECT_TRUE(WaitForTrueOrTimeout(&listenerCalled, STATE_CHANGE_TIMEOUT_MS));
+
+ alljoyn_applicationstatelistener_destroy(listener);
}
TEST_F(BusAttachmentSecurity20Test, shouldNotCallStateListenerAfterUnregister)
@@ -285,6 +296,8 @@ TEST_F(BusAttachmentSecurity20Test, shouldNotCallStateListenerAfterUnregister)
ChangeApplicationState();
EXPECT_FALSE(WaitForTrueOrTimeout(&listenerCalled, STATE_CHANGE_TIMEOUT_MS));
+
+ alljoyn_applicationstatelistener_destroy(listener);
}
TEST_F(BusAttachmentSecurity20Test, shouldCallAllStateListeners)
@@ -302,6 +315,9 @@ TEST_F(BusAttachmentSecurity20Test, shouldCallAllStateListeners)
EXPECT_TRUE(WaitForTrueOrTimeout(&firstListenerCalled, STATE_CHANGE_TIMEOUT_MS));
EXPECT_TRUE(WaitForTrueOrTimeout(&secondListenerCalled, STATE_CHANGE_TIMEOUT_MS));
+
+ alljoyn_applicationstatelistener_destroy(firstListener);
+ alljoyn_applicationstatelistener_destroy(secondListener);
}
TEST_F(BusAttachmentSecurity20Test, shouldCallOnlyOneStateListenerWhenOtherUnregistered)
@@ -320,6 +336,9 @@ TEST_F(BusAttachmentSecurity20Test, shouldCallOnlyOneStateListenerWhenOtherUnreg
EXPECT_FALSE(WaitForTrueOrTimeout(&firstListenerCalled, STATE_CHANGE_TIMEOUT_MS));
EXPECT_TRUE(WaitForTrueOrTimeout(&secondListenerCalled, STATE_CHANGE_TIMEOUT_MS));
+
+ alljoyn_applicationstatelistener_destroy(firstListener);
+ alljoyn_applicationstatelistener_destroy(secondListener);
}
TEST(BusAttachmentTest, createinterface) {
diff --git a/alljoyn_c/unit_test/InterfaceDescriptionTest.cc b/alljoyn_c/unit_test/InterfaceDescriptionTest.cc
index f4a12f2..1011c4e 100644
--- a/alljoyn_c/unit_test/InterfaceDescriptionTest.cc
+++ b/alljoyn_c/unit_test/InterfaceDescriptionTest.cc
@@ -1988,6 +1988,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionforlan
ASSERT_NE(nullptr, testIntf);
EXPECT_EQ(0u, alljoyn_interfacedescription_getdescriptionforlanguage(testIntf, description, SIZE, "en"));
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionforlanguage__NoDescriptionInRequestedLanguage__Returns0)
@@ -2003,6 +2005,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionforlan
alljoyn_interfacedescription_setdescriptionforlanguage(testIntf, "German Description", "de");
EXPECT_EQ(0u, alljoyn_interfacedescription_getdescriptionforlanguage(testIntf, description, SIZE, "en"));
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionforlanguage_DescriptionsInMultipleLanguages_ReturnsRequested)
@@ -2028,6 +2032,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionforlan
EXPECT_STREQ(FRENCH_DESCRIPTION, description);
EXPECT_EQ(sizeof(SPANISH_DESCRIPTION) - 1, alljoyn_interfacedescription_getdescriptionforlanguage(testIntf, description, SIZE, "es"));
EXPECT_STREQ(SPANISH_DESCRIPTION, description);
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionforlanguage_ExtendedLanguagesRequested_ReturnsMatchingDescriptions)
@@ -2060,6 +2066,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionforlan
EXPECT_STREQ(GERMAN_LATIN_DESCRIPTION, description);
EXPECT_EQ(sizeof(GERMAN_DESCRIPTION) - 1, alljoyn_interfacedescription_getdescriptionforlanguage(testIntf, description, SIZE, "de-Deva-DE"));
EXPECT_STREQ(GERMAN_DESCRIPTION, description);
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getpropertydescriptionforlanguage__NoDescriptionSet__Returns0)
@@ -2076,6 +2084,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getpropertydescripti
ASSERT_EQ(ER_OK, alljoyn_interfacedescription_addproperty(testIntf, PROPERTY_NAME, "s", ALLJOYN_PROP_ACCESS_READ));
EXPECT_EQ(0u, alljoyn_interfacedescription_getpropertydescriptionforlanguage(testIntf, PROPERTY_NAME, description, SIZE, "en"));
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_setpropertydescriptionforlanguage__NoPropertySet__ReturnsNoSuchProperty)
@@ -2089,6 +2099,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_setpropertydescripti
EXPECT_EQ(ER_BUS_NO_SUCH_PROPERTY, alljoyn_interfacedescription_setpropertydescriptionforlanguage(
testIntf, PROPERTY_NAME, "Description", "en"));
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getpropertydescriptionforlanguage__DescriptionsInMultipleLanguages__ReturnsRequested)
@@ -2123,6 +2135,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getpropertydescripti
EXPECT_EQ(sizeof(SPANISH_DESCRIPTION) - 1, alljoyn_interfacedescription_getpropertydescriptionforlanguage(
testIntf, PROPERTY_NAME, description, SIZE, "es"));
EXPECT_STREQ(SPANISH_DESCRIPTION, description);
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getpropertydescriptionforlanguage__MultipleProperties__ReturnsRequested)
@@ -2167,6 +2181,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getpropertydescripti
EXPECT_EQ(sizeof(SECOND_FRENCH_DESCRIPTION) - 1, alljoyn_interfacedescription_getpropertydescriptionforlanguage(
testIntf, SECOND_PROPERTY_NAME, description, SIZE, "fr"));
EXPECT_STREQ(SECOND_FRENCH_DESCRIPTION, description);
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getmemberdescriptionforlanguage__NoDescriptionSet__Returns0)
@@ -2184,6 +2200,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getmemberdescription
EXPECT_EQ(0u, alljoyn_interfacedescription_getmemberdescriptionforlanguage(
testIntf, MEMBER_NAME, description, SIZE, "en"));
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_setmemberdescriptionforlanguage__NoMemberAdded__ReturnsNoSuchMember)
@@ -2197,6 +2215,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_setmemberdescription
EXPECT_EQ(ER_BUS_INTERFACE_NO_SUCH_MEMBER, alljoyn_interfacedescription_setmemberdescriptionforlanguage(
testIntf, MEMBER_NAME, "Description", "en"));
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getmemberdescriptionforlanguage__DescriptionsInMultipleLanguages_ReturnsRequested)
@@ -2231,6 +2251,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getmemberdescription
EXPECT_EQ(sizeof(SPANISH_DESCRIPTION) - 1, alljoyn_interfacedescription_getmemberdescriptionforlanguage(
testIntf, MEMBER_NAME, description, SIZE, "es"));
EXPECT_STREQ(SPANISH_DESCRIPTION, description);
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getmemberdescriptionforlanguage__MultipleMembers__ReturnsRequested)
@@ -2273,6 +2295,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getmemberdescription
EXPECT_EQ(sizeof(SECOND_FRENCH_DESCRIPTION) - 1, alljoyn_interfacedescription_getmemberdescriptionforlanguage(
testIntf, SECOND_MEMBER_NAME, description, SIZE, "fr"));
EXPECT_STREQ(SECOND_FRENCH_DESCRIPTION, description);
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getargdescriptionforlanguage__NoDescriptionSet__Returns0)
@@ -2290,6 +2314,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getargdescriptionfor
EXPECT_EQ(0u, alljoyn_interfacedescription_getargdescriptionforlanguage(
testIntf, MEMBER_NAME, "inStr", description, SIZE, "en"));
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_setargdescriptionforlanguage__NoMemberAdded__ReturnsNoSuchMember)
@@ -2303,6 +2329,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_setargdescriptionfor
EXPECT_EQ(ER_BUS_INTERFACE_NO_SUCH_MEMBER, alljoyn_interfacedescription_setargdescriptionforlanguage(
testIntf, MEMBER_NAME, "arg", "Description", "en"));
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getargdescriptionforlanguage__DescriptionsInMultipleLanguages__ReturnsRequested)
@@ -2338,6 +2366,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getargdescriptionfor
EXPECT_EQ(sizeof(SPANISH_DESCRIPTION) - 1, alljoyn_interfacedescription_getargdescriptionforlanguage(
testIntf, MEMBER_NAME, ARG_NAME, description, SIZE, "es"));
EXPECT_STREQ(SPANISH_DESCRIPTION, description);
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getmemberdescriptionforlanguage__MultipleArgs__ReturnsRequested)
@@ -2380,6 +2410,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getmemberdescription
EXPECT_EQ(sizeof(SECOND_FRENCH_DESCRIPTION) - 1, alljoyn_interfacedescription_getargdescriptionforlanguage(
testIntf, MEMBER_NAME, SECOND_ARG_NAME, description, SIZE, "fr"));
EXPECT_STREQ(SECOND_FRENCH_DESCRIPTION, description);
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlanguages2__NoDescriptionSet__ReturnsZeroSize)
@@ -2393,6 +2425,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlangua
size_t returnedSize = alljoyn_interfacedescription_getdescriptionlanguages2(
testIntf, nullptr, 0);
EXPECT_EQ(0u, returnedSize);
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlanguages2__DescriptionsInDifferentLanguages__ReturnsTotalSize)
@@ -2423,6 +2457,8 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlangua
size_t expectedSize = strlen("en-US") + 1 + strlen("en") + 1 + strlen("de") + 1 + strlen("fr") + 1;
size_t returnedSize = alljoyn_interfacedescription_getdescriptionlanguages2(testIntf, nullptr, 0);
EXPECT_EQ(expectedSize, returnedSize);
+
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlanguages2__InterfaceDescriptionSet__ProvidesItsLanguage)
@@ -2448,6 +2484,7 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlangua
EXPECT_STREQ(expectedLanguages, returnedLanguages);
free(returnedLanguages);
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlanguages2__PropertyDescriptionSet__ProvidesItsLanguage)
@@ -2477,6 +2514,7 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlangua
EXPECT_STREQ(expectedLanguages, returnedLanguages);
free(returnedLanguages);
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlanguages2__MemberDescriptionSet__ProvidesItsLanguage)
@@ -2506,6 +2544,7 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlangua
EXPECT_STREQ(expectedLanguages, returnedLanguages);
free(returnedLanguages);
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlanguages2__ArgumentDescriptionSet__ProvidesItsLanguage)
@@ -2535,6 +2574,7 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlangua
EXPECT_STREQ(expectedLanguages, returnedLanguages);
free(returnedLanguages);
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlanguages2__DescriptionsInDifferentLanguages__ReturnsAllLanguages)
@@ -2575,6 +2615,7 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlangua
EXPECT_STREQ(expectedLanguages, returnedLanguages);
free(returnedLanguages);
+ alljoyn_busattachment_destroy(bus);
}
TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlanguages2__MaximumSizeSmallerThanTagsList__OmitsTheLastTag)
@@ -2617,4 +2658,5 @@ TEST(InterfaceDescriptionTest, alljoyn_interfacedescription_getdescriptionlangua
EXPECT_STREQ(expectedLanguages, returnedLanguages);
free(returnedLanguages);
+ alljoyn_busattachment_destroy(bus);
}
diff --git a/alljoyn_c/unit_test/ObserverTest.cc b/alljoyn_c/unit_test/ObserverTest.cc
index 3cf39c0..5be8a2a 100644
--- a/alljoyn_c/unit_test/ObserverTest.cc
+++ b/alljoyn_c/unit_test/ObserverTest.cc
@@ -195,8 +195,8 @@ class Participant : public SessionPortListener, public SessionListener {
for (it = objects.begin(); it != objects.end(); ++it) {
if (it->second.second) {
bus.UnregisterBusObject(*(it->second.first));
- delete it->second.first;
}
+ delete it->second.first;
}
delete aboutObj;
@@ -334,6 +334,11 @@ struct ObserverListener {
virtual ~ObserverListener() {
alljoyn_observerlistener_destroy(listener);
+ ProxyVector::iterator it = proxies.begin();
+ while (it != proxies.end()) {
+ alljoyn_proxybusobject_ref_decref(*it);
+ it = proxies.erase(it);
+ }
}
void ExpectInvocations(int newCounter) {
@@ -458,11 +463,9 @@ static bool WaitForAll(vector<Event*>& events, uint32_t wait_ms = MAX_WAIT_MS)
static int CountProxies(alljoyn_observer observer)
{
- int count;
- alljoyn_proxybusobject_ref iter;
- for (count = 0, iter = alljoyn_observer_getfirst(observer);
- iter != NULL;
- iter = alljoyn_observer_getnext(observer, iter)) {
+ int count = 0;
+ alljoyn_proxybusobject_ref iter = alljoyn_observer_getfirst(observer);
+ for (; iter != NULL; iter = alljoyn_observer_getnext(observer, iter)) {
++count;
}
return count;
@@ -1080,14 +1083,21 @@ TEST_F(ObserverTest, StressNumPartObjects) {
EXPECT_TRUE(WaitForAll(events));
//clean up
- for (int i = 0; i < STRESS_FACTOR; i++) {
- alljoyn_observer_unregisterlistener(observers[i], listeners[i]->listener);
- alljoyn_observerlistener_destroy(listeners[i]->listener);
- alljoyn_observer_destroy(observers[i]);
- providers[i]->UnregisterObject("a");
- providers[i]->UnregisterObject("b");
- delete consumers[i];
- delete providers[i];
+ for (size_t i = 0; i < STRESS_FACTOR; i++) {
+ if (i < providers.size()) {
+ providers[i]->UnregisterObject("a");
+ providers[i]->UnregisterObject("b");
+ delete providers[i];
+ }
+ if (i < observers.size()) {
+ alljoyn_observer_destroy(observers[i]);
+ }
+ if (i < listeners.size()) {
+ delete listeners[i];
+ }
+ if (i < consumers.size()) {
+ delete consumers[i];
+ }
}
}
diff --git a/alljoyn_c/unit_test/PermissionConfigurationListenerTest.cc b/alljoyn_c/unit_test/PermissionConfigurationListenerTest.cc
index d8d35e5..83a5f54 100644
--- a/alljoyn_c/unit_test/PermissionConfigurationListenerTest.cc
+++ b/alljoyn_c/unit_test/PermissionConfigurationListenerTest.cc
@@ -95,20 +95,17 @@ class PermissionConfigurationListenerTest : public testing::Test {
}
};
-TEST_F(PermissionConfigurationListenerTest, shouldCreateListenerWithCallbacksAndNullContext)
+TEST_F(PermissionConfigurationListenerTest, shouldCreateAndDestroyListenerWithCallbacksAndNullContext)
{
- EXPECT_NE(nullptr, alljoyn_permissionconfigurationlistener_create(&m_callbacks, nullptr));
-}
-
-TEST_F(PermissionConfigurationListenerTest, shouldCreateListenerWithCallbacksAndNonNullContext)
-{
- EXPECT_NE(nullptr, alljoyn_permissionconfigurationlistener_create(&m_callbacks, this));
+ alljoyn_permissionconfigurationlistener listener = alljoyn_permissionconfigurationlistener_create(&m_callbacks, nullptr);
+ EXPECT_NE(nullptr, listener);
+ alljoyn_permissionconfigurationlistener_destroy(listener);
}
-TEST_F(PermissionConfigurationListenerTest, shouldDestroyNonNullListenerWithoutException)
+TEST_F(PermissionConfigurationListenerTest, shouldCreateAndDestroyListenerWithCallbacksAndNonNullContext)
{
- alljoyn_permissionconfigurationlistener listener = alljoyn_permissionconfigurationlistener_create(&m_callbacks, nullptr);
-
+ alljoyn_permissionconfigurationlistener listener = alljoyn_permissionconfigurationlistener_create(&m_callbacks, this);
+ EXPECT_NE(nullptr, listener);
alljoyn_permissionconfigurationlistener_destroy(listener);
}
@@ -120,6 +117,8 @@ TEST_F(PermissionConfigurationListenerTest, shouldCallFactoryResetCallback)
((PermissionConfigurationListener*)listener)->FactoryReset();
EXPECT_TRUE(factoryResetHappened);
+
+ alljoyn_permissionconfigurationlistener_destroy(listener);
}
TEST_F(PermissionConfigurationListenerTest, shouldCallPolicyChangedCallback)
@@ -130,6 +129,7 @@ TEST_F(PermissionConfigurationListenerTest, shouldCallPolicyChangedCallback)
((PermissionConfigurationListener*)listener)->PolicyChanged();
EXPECT_TRUE(policyChangedHappened);
+ alljoyn_permissionconfigurationlistener_destroy(listener);
}
TEST_F(PermissionConfigurationListenerTest, shouldCallStartManagementCallback)
@@ -140,6 +140,7 @@ TEST_F(PermissionConfigurationListenerTest, shouldCallStartManagementCallback)
((PermissionConfigurationListener*)listener)->StartManagement();
EXPECT_TRUE(startManagementHappened);
+ alljoyn_permissionconfigurationlistener_destroy(listener);
}
TEST_F(PermissionConfigurationListenerTest, shouldCallEndManagementCallback)
@@ -150,4 +151,5 @@ TEST_F(PermissionConfigurationListenerTest, shouldCallEndManagementCallback)
((PermissionConfigurationListener*)listener)->EndManagement();
EXPECT_TRUE(endManagementHappened);
+ alljoyn_permissionconfigurationlistener_destroy(listener);
}
diff --git a/alljoyn_c/unit_test/PermissionConfiguratorTest.cc b/alljoyn_c/unit_test/PermissionConfiguratorTest.cc
index 099a305..7827107 100644
--- a/alljoyn_c/unit_test/PermissionConfiguratorTest.cc
+++ b/alljoyn_c/unit_test/PermissionConfiguratorTest.cc
@@ -161,7 +161,8 @@ class PermissionConfiguratorTestWithSecurity : public PermissionConfiguratorTest
PermissionConfiguratorTestWithSecurity() :
PermissionConfiguratorTestWithoutSecurity(),
- m_callbacks()
+ m_callbacks(),
+ m_listener(nullptr)
{ }
protected:
@@ -180,23 +181,32 @@ class PermissionConfiguratorTestWithSecurity : public PermissionConfiguratorTest
m_configuratorUnderTest = alljoyn_busattachment_getpermissionconfigurator(m_appUnderTest);
}
+ virtual void TearDown()
+ {
+ if (m_listener != nullptr) {
+ alljoyn_permissionconfigurationlistener_destroy(m_listener);
+ }
+ PermissionConfiguratorTestWithoutSecurity::TearDown();
+ }
+
void PassFlagsToCallbacks(bool* policyChanged, bool* factoryResetHappened)
{
m_callbacksContext.factoryResetHappened = factoryResetHappened;
m_callbacksContext.policyChanged = policyChanged;
- alljoyn_permissionconfigurationlistener listener = alljoyn_permissionconfigurationlistener_create(&m_callbacks, &m_callbacksContext);
+ m_listener = alljoyn_permissionconfigurationlistener_create(&m_callbacks, &m_callbacksContext);
ASSERT_EQ(ER_OK, alljoyn_busattachment_enablepeersecuritywithpermissionconfigurationlistener(m_appUnderTest,
NULL_AUTH_MECHANISM,
nullptr,
nullptr,
QCC_TRUE,
- listener));
+ m_listener));
FlushUnwantedCallback(policyChanged);
}
private:
alljoyn_permissionconfigurationlistener_callbacks m_callbacks;
+ alljoyn_permissionconfigurationlistener m_listener;
struct CallbacksContext {
bool* policyChanged;
@@ -795,6 +805,7 @@ TEST_F(PermissionConfiguratorPreClaimTest, shouldPassSignManifest)
{
AJ_PSTR signedManifestXmls[1];
EXPECT_EQ(ER_OK, alljoyn_permissionconfigurator_signmanifest(m_configuratorUnderTest, m_identityCertificate, s_validAllowAllManifestTemplate, &signedManifestXmls[0]));
+ alljoyn_permissionconfigurator_manifest_destroy(signedManifestXmls[0]);
}
TEST_F(PermissionConfiguratorPreClaimTest, shouldReturnErrorWhenClaimingWithInvalidPublicKey)
diff --git a/alljoyn_c/unit_test/SecurityApplicationProxyTest.cc b/alljoyn_c/unit_test/SecurityApplicationProxyTest.cc
index beb5ec9..39105f2 100644
--- a/alljoyn_c/unit_test/SecurityApplicationProxyTest.cc
+++ b/alljoyn_c/unit_test/SecurityApplicationProxyTest.cc
@@ -1329,6 +1329,7 @@ TEST_F(SecurityApplicationProxyFullSetupTest, shouldPassGetManifests)
alljoyn_manifestarray manifestArray;
EXPECT_EQ(ER_OK, alljoyn_securityapplicationproxy_getmanifests(m_managedAppSecurityApplicationProxy, &manifestArray));
EXPECT_EQ(1U, manifestArray.count);
+ alljoyn_securityapplicationproxy_manifestarray_cleanup(&manifestArray);
}
TEST_F(SecurityApplicationProxyFullSetupTest, shouldPassResetForValidProxyAndInstalledMembership)
@@ -1445,13 +1446,14 @@ TEST_F(SecurityApplicationProxyFullSetupTest, shouldPassRemoveMembership)
m_certIds.ids[0].issuerPublicKey,
nullptr,
0U));
-
+ alljoyn_securityapplicationproxy_certificateidarray_cleanup(&m_certIds);
EXPECT_EQ(ER_OK, alljoyn_securityapplicationproxy_getmembershipsummaries(m_managedAppSecurityApplicationProxy, &m_certIds));
EXPECT_EQ(0U, m_certIds.count);
}
TEST_F(SecurityApplicationProxyFullSetupTest, shouldPassInstallManifests)
{
+ SecurityApplicationProxyTestHelper::DestroyCertificate(m_managedAppIdentityCertificate);
SecurityApplicationProxyTestHelper::CreateIdentityCert(m_securityManager, m_managedApp, &m_managedAppIdentityCertificate, false);
ASSERT_EQ(ER_OK, alljoyn_securityapplicationproxy_signmanifest(s_validManagedAppManifestTemplate,
m_managedAppIdentityCertificate,
diff --git a/alljoyn_core/router/test/ardp.cc b/alljoyn_core/router/test/ardp.cc
index cbb09b8..e0487cf 100644
--- a/alljoyn_core/router/test/ardp.cc
+++ b/alljoyn_core/router/test/ardp.cc
@@ -56,7 +56,7 @@
#include <ArdpProtocol.h>
-#define QCC_MODULE "ARDP"
+#define QCC_MODULE "ARDP_TEST"
using namespace ajn;
@@ -75,7 +75,6 @@ const uint32_t UDP_TIMEWAIT = 1000; /**< How long do we stay in TIMWAIT
const uint32_t UDP_SEGBMAX = 65507; /**< Maximum size of an ARDP message (for receive buffer sizing) */
const uint32_t UDP_SEGMAX = 50; /**< Maximum number of ARDP messages in-flight (bandwidth-delay product sizing) */
-bool g_user = false;
char const* g_localport = "9954";
char const* g_foreignport = "9955";
char const* g_address = "127.0.0.1";
@@ -102,9 +101,8 @@ bool AcceptCb(ArdpHandle* handle, qcc::IPAddress ipAddr, uint16_t ipPort, ArdpCo
QCC_DbgTrace(("AcceptCb(handle=%p, ipAddr=\"%s\", foreign=%d, conn=%p, buf=%p(\"%s\"), len=%d, status=%s)",
handle, ipAddr.ToString().c_str(), ipPort, conn, buf, (char*) buf, len, QCC_StatusText(status)));
- uint16_t length = random() % UDP_SEGBMAX;
- uint8_t* buffer = new uint8_t[length];
- status = ARDP_Accept(handle, conn, UDP_SEGMAX, UDP_SEGBMAX, buffer, length);
+ status = ARDP_Accept(handle, conn, UDP_SEGMAX, UDP_SEGBMAX, reinterpret_cast<uint8_t*>(const_cast<char*>(g_ajnAcceptString)),
+ strlen(g_ajnAcceptString) + 1);
if (status != ER_OK) {
QCC_DbgPrintf(("AcceptCb(): ARDP_Accept failed with %s", QCC_StatusText(status)));
}
@@ -125,8 +123,8 @@ void ConnectCb(ArdpHandle* handle, ArdpConnRecord* conn, bool passive, uint8_t*
uint16_t length = random() % UDP_SEGBMAX;
uint8_t* buffer = new uint8_t[length];
QCC_DbgPrintf(("ConnectCb(): ARDP_Send(handle=%p, conn=%p, buffer=%p, length=%d)", handle, conn, buffer, length));
-
status = ARDP_Send(handle, conn, buffer, length, 0);
+ delete [] buffer;
if (status != ER_OK) {
QCC_DbgPrintf(("ConnectCb(): ARDP_Send failed with %s", QCC_StatusText(status)));
}
@@ -171,8 +169,8 @@ void SendCb(ArdpHandle* handle, ArdpConnRecord* conn, uint8_t* buf, uint32_t len
uint16_t length = random() % UDP_SEGBMAX;
uint8_t* buffer = new uint8_t[length];
QCC_DbgTrace(("SendCb(): ARDP_Send(handle=%p, conn=%p, buffer=%p, length=%d.)", handle, conn, buffer, length));
-
status = ARDP_Send(handle, conn, buffer, length, 0);
+ delete [] buffer;
if (status != ER_OK) {
QCC_DbgPrintf(("SendCb(): ARDP_Send failed with %s", QCC_StatusText(status)));
}
@@ -205,20 +203,19 @@ void* Test::Run(void* arg)
QCC_UNUSED(arg);
qcc::SocketFd sock;
-
- QStatus status = qcc::Socket(qcc::QCC_AF_INET, qcc::QCC_SOCK_DGRAM, sock);
+ qcc::IPAddress ipToConnectTo(g_address);
+ QStatus status = qcc::Socket(ipToConnectTo.IsIPv4() ? qcc::QCC_AF_INET : qcc::QCC_AF_INET6, qcc::QCC_SOCK_DGRAM, sock);
if (status != ER_OK) {
QCC_LogError(status, ("Test::Run(): Socket(): Failed"));
return 0;
}
-
status = qcc::SetBlocking(sock, false);
if (status != ER_OK) {
QCC_LogError(status, ("Test::Run(): SetBlocking(): Failed"));
return 0;
}
- status = qcc::Bind(sock, qcc::IPAddress("0.0.0.0"), atoi(g_localport));
+ status = qcc::Bind(sock, qcc::IPAddress(ipToConnectTo.IsIPv4() ? "0.0.0.0" : "::"), atoi(g_localport));
if (status != ER_OK) {
QCC_LogError(status, ("Test::Run(): Bind(): Failed"));
return 0;
@@ -255,14 +252,14 @@ void* Test::Run(void* arg)
bool connectSent = false;
- while (IsRunning()) {
+ while ((!g_interrupt) && (IsRunning())) {
std::vector<qcc::Event*> checkEvents, signaledEvents;
checkEvents.push_back(&stopEvent);
checkEvents.push_back(&timerEvent);
checkEvents.push_back(sockEvent);
status = qcc::Event::Wait(checkEvents, signaledEvents);
- if (status != ER_OK && status != ER_TIMEOUT) {
+ if ((status != ER_OK) && (status != ER_TIMEOUT)) {
QCC_LogError(status, ("Test::Run(): Event::Wait(): Failed"));
break;
}
@@ -272,13 +269,14 @@ void* Test::Run(void* arg)
QCC_DbgPrintf(("Test::Run(): Stop event fired"));
stopEvent.ResetEvent();
} else if (*i == &timerEvent) {
- if (g_user) {
- if (connectSent == false) {
- connectSent = true;
- ArdpConnRecord* conn;
- ARDP_Connect(ardpHandle, sock, qcc::IPAddress(g_address), atoi(g_foreignport), UDP_SEGMAX, UDP_SEGBMAX,
- &conn, (uint8_t* )g_ajnConnString, strlen(g_ajnConnString) + 1, NULL);
- continue;
+ if (connectSent == false) {
+ connectSent = true;
+ ArdpConnRecord* conn;
+ status = ARDP_Connect(ardpHandle, sock, ipToConnectTo,
+ atoi(g_foreignport), UDP_SEGMAX, UDP_SEGBMAX, &conn,
+ reinterpret_cast<uint8_t*>(const_cast<char*>(g_ajnConnString)), strlen(g_ajnConnString) + 1, nullptr);
+ if (status != ER_OK) {
+ QCC_LogError(status, ("Test::Run(): ARDP_Connect failed"));
}
}
} else {
@@ -289,9 +287,18 @@ void* Test::Run(void* arg)
}
}
ARDP_FreeHandle(ardpHandle);
+ qcc::Close(sock);
+ delete sockEvent;
return 0;
}
+static void usage() {
+ printf("-l <local port to bind to> \n");
+ printf("-f <foreign port to connect to> \n");
+ printf("-a <address to connect to> \n");
+ exit(0);
+}
+
int CDECL_CALL main(int argc, char** argv)
{
if (AllJoynInit() != ER_OK) {
@@ -302,30 +309,40 @@ int CDECL_CALL main(int argc, char** argv)
return 1;
}
- printf("%s main()\n", argv[0]);
-
for (int i = 1; i < argc; ++i) {
if (0 == strcmp("-l", argv[i])) {
- g_localport = argv[i + 1];
- i += 1;
+ ++i;
+ if (i == argc) {
+ printf("option %s requires a parameter\n", argv[i - 1]);
+ usage();
+ } else {
+ g_localport = argv[i];
+ }
} else if (0 == strcmp("-f", argv[i])) {
- g_foreignport = argv[i + 1];
- i += 1;
+ ++i;
+ if (i == argc) {
+ printf("option %s requires a parameter\n", argv[i - 1]);
+ usage();
+ } else {
+ g_foreignport = argv[i];
+ }
} else if (0 == strcmp("-a", argv[i])) {
- g_address = argv[i + 1];
- i += 1;
- } else if (0 == strcmp("-u", argv[i])) {
- g_user = true;
+ ++i;
+ if (i == argc) {
+ printf("option %s requires a parameter\n", argv[i - 1]);
+ usage();
+ } else {
+ g_address = argv[i];
+ }
} else {
printf("Unknown option %s\n", argv[i]);
- exit(0);
+ usage();
}
}
- printf("g_user == %d.\n", g_user);
- printf("g_localport == %s\n", g_localport);
- printf("g_foreignport == %s\n", g_foreignport);
- printf("g_address == %s\n", g_address);
+ printf("local port to bind to == %s\n", g_localport);
+ printf("foreign port to connect to == %s\n", g_foreignport);
+ printf("address to connect to == %s\n", g_address);
signal(SIGINT, SigIntHandler);
@@ -336,8 +353,9 @@ int CDECL_CALL main(int argc, char** argv)
qcc::Sleep(100);
}
- test->Stop();
- test->Join();
+ if (test->Stop() == ER_OK) {
+ test->Join();
+ }
delete test;
AllJoynRouterShutdown();
diff --git a/alljoyn_core/router/test/ardptest.cc b/alljoyn_core/router/test/ardptest.cc
index a1c0bfa..caa7c62 100644
--- a/alljoyn_core/router/test/ardptest.cc
+++ b/alljoyn_core/router/test/ardptest.cc
@@ -126,6 +126,7 @@ static String NextTok(String& inStr)
}
return Trim(ret);
}
+
static void RemoveConn(ArdpConnRecord*conn) {
std::map<uint32_t, ArdpConnRecord*>::iterator it = connList.begin();
@@ -169,19 +170,9 @@ bool AcceptCb(ArdpHandle* handle, qcc::IPAddress ipAddr, uint16_t ipPort, ArdpCo
QCC_UNUSED(len);
printf("Inside Accept callback, we received a SYN from %s:%d, the message is \"%s\", status %s \n", ipAddr.ToString().c_str(), ipPort, (char*)buf, QCC_StatusText(status));
- printf("Connection no is %d, conn pointer is %p \n", g_conn, conn);
+ printf("Connection no is %d, conn pointer is %p \n", g_conn, conn);
connList[g_conn] = conn;
g_conn++;
- //int option=0;
- //printf("Do you want to accept(1) it or not? ");
- //scanf("%d",&option);
- //if(option==1) {
- // printf("Returning true..\n");
- // return true;
- //} else {
- // printf("Returning false..\n");
- // return false;
- //}
return true;
}
@@ -247,7 +238,6 @@ class ThreadClass : public Thread {
while ((!g_interrupt) && (IsRunning())) {
uint32_t ms;
ARDP_Run(m_handle, m_sock, true, false, true, &ms);
- //qcc::Sleep(1000);
}
return this;
@@ -544,6 +534,7 @@ int CDECL_CALL main(int argc, char** argv)
}
if (strcmp(cmd.c_str(), "exit") == 0) {
+ g_interrupt = true;
break;
}
@@ -552,8 +543,9 @@ int CDECL_CALL main(int argc, char** argv)
}
}
- t1->Stop();
- t1->Join();
+ if (t1->Stop() == ER_OK) {
+ t1->Join();
+ }
delete t1;
AllJoynRouterShutdown();