From fe62a972f9dcb15721dbe7f4ab334940ee2a693c Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Thu, 24 Mar 2016 01:55:05 +1300 Subject: [PATCH] Fix valgrind error in Static API test Signed-off-by: Sean Kelly --- api/tests-static/test_client.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/api/tests-static/test_client.cc b/api/tests-static/test_client.cc index 4728c08..e3a3c45 100644 --- a/api/tests-static/test_client.cc +++ b/api/tests-static/test_client.cc @@ -475,14 +475,6 @@ TEST_F(TestStaticClient, AwaStaticClinet_SetFactoryBootstrapInformation_before_i AwaStaticClient * client = AwaStaticClient_New(); EXPECT_TRUE(client != NULL); - EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/")); - EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1")); - EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683)); - - EXPECT_EQ(AwaError_Success, AwaStaticClient_Init(client)); - - AwaStaticClient_Process(client); - AwaFactoryBootstrapInfo bootstrapinfo = { 0 }; sprintf(bootstrapinfo.SecurityInfo.ServerURI, "coap://127.0.0.1"); @@ -498,13 +490,24 @@ TEST_F(TestStaticClient, AwaStaticClinet_SetFactoryBootstrapInformation_before_i sprintf(bootstrapinfo.ServerInfo.Binding, "U"); ASSERT_EQ(AwaError_OperationInvalid, AwaStaticClient_SetFactoryBootstrapInformation(client, &bootstrapinfo)); + + AwaStaticClient_Free(&client); + EXPECT_TRUE(client == NULL); } -TEST_F(TestStaticClientWithServer, AwaStaticClient_SetFactoryBootstrapInformation_after_process) +TEST_F(TestStaticClient, AwaStaticClient_SetFactoryBootstrapInformation_while_running) { AwaStaticClient * client = AwaStaticClient_New(); EXPECT_TRUE(client != NULL); + EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/")); + EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1")); + EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683)); + + EXPECT_EQ(AwaError_Success, AwaStaticClient_Init(client)); + + AwaStaticClient_Process(client); + AwaFactoryBootstrapInfo bootstrapinfo = { 0 }; sprintf(bootstrapinfo.SecurityInfo.ServerURI, "coap://127.0.0.1"); @@ -520,6 +523,9 @@ TEST_F(TestStaticClientWithServer, AwaStaticClient_SetFactoryBootstrapInformati sprintf(bootstrapinfo.ServerInfo.Binding, "U"); ASSERT_EQ(AwaError_OperationInvalid, AwaStaticClient_SetFactoryBootstrapInformation(client, &bootstrapinfo)); + + AwaStaticClient_Free(&client); + EXPECT_TRUE(client == NULL); } TEST_F(TestStaticClient, AwaStaticClient_Bootstrap_Test)