Commit 08e1743f authored by f.aman's avatar f.aman Committed by Sungkyu Ko

[RI][NS] Modified source and build scripts

	1. Modified tc source for RI CSDK
	2. Modified build script for RI CPP
	3. Added test_app source for NS CPP

Change-Id: I2ca1b75c62e51defeaba77de5d731f7e328a3da9
Signed-off-by: default avatarf.aman <f.aman@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14909Reviewed-by: default avatarTowhidul Islam <t.islam@samsung.com>
Reviewed-by: default avatarMd. Arafat Hossain <arafat.hsn@samsung.com>
Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarSungkyu Ko <sungkyu.ko@samsung.com>
parent baadf0d7
......@@ -19,6 +19,7 @@
*
******************************************************************/
'''
##
# Build script for Linux
#
......@@ -66,11 +67,10 @@ RI_RESOURCE_LIB = ORG_SRC_HOME + ORG_SRC_OUT_DIR
RI_RESOURCE_STACK = RI_RESOURCE_DIR + '/csdk/stack/include'
RI_RESOURCE_SOCKET = RI_RESOURCE_DIR + '/csdk/ocsocket/include'
RI_RESOURCE_RANDOM = RI_RESOURCE_DIR + '/csdk/ocrandom/include'
RI_RESOURCE_LOGGER = RI_RESOURCE_DIR + '/csdk/logger/include'
RI_RESOURCE_COMMON = RI_RESOURCE_DIR + '/c_common/'
RI_RESOURCE_OC_LOGGER = RI_RESOURCE_DIR + '/oc_logger/include'
RI_RESOURCE_CEREAL = ORG_SRC_HOME + '/extlibs/cereal/include/'
RI_RESOURCE_TIMER = ORG_SRC_HOME + '/extlibs/timer/'
CBOR_INC_DIR = ORG_SRC_HOME + '/extlibs/tinycbor/tinycbor/src'
SECURE_VIRTUAL_RESOURCE_INC = ORG_SRC_HOME + '/resource/csdk/security/include'
######################################################################
# Initializing Project Dir
......@@ -98,7 +98,7 @@ RI_CFLAGS = [COMMON_FLAGS]
######################################################################
COMMON_CINCLUDE = [INCLUDE_DIR]
RI_CINCLUDE = [COMMON_CINCLUDE, RI_RESOURCE_INCLUDE, RI_RESOURCE_STACK, RI_RESOURCE_SOCKET, RI_RESOURCE_RANDOM, RI_RESOURCE_OC_LOGGER, INCLUDE_DIR, RI_RESOURCE_COMMON]
RI_CINCLUDE = [COMMON_CINCLUDE, RI_RESOURCE_INCLUDE, RI_RESOURCE_STACK, RI_RESOURCE_SOCKET, RI_RESOURCE_RANDOM, RI_RESOURCE_OC_LOGGER, INCLUDE_DIR, RI_RESOURCE_COMMON, CBOR_INC_DIR, SECURE_VIRTUAL_RESOURCE_INC]
######################################################################
# Initializing Libraries
......
......@@ -304,37 +304,6 @@ TEST_F(RICsdkServerTest_btc, OCSetDeviceInfo_SRC_FSV_P)
}
#endif
/**
* @since 2016-07-19
* @see OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
* @see OCStackResult OCStop()
* @objective Test OCSetDeviceInfo with negative basic way using deviceInfo without setting device information
* @target OCStackResult OCSetDeviceInfo(OCDeviceInfo deviceInfo)
* @test_data deviceInfo Structure containing the device information
* @pre_condition Call OCInit() API
* @procedure Call OCSetDeviceInfo() API
* @post_condition Call OCStop()
* @expected Should return OC_STACK_INVALID_PARAM
*/
#if defined(__LINUX__) || defined(__TIZEN__)
TEST_F(RICsdkServerTest_btc, OCSetDeviceInfo_USV_N)
{
try
{
m_result = m_pRICsdkHelper->initServer();
ASSERT_EQ(OC_STACK_OK,m_result) << "OCInit failed for server. Actual m_result : " << CommonUtil::s_OCStackResultString.at(m_result);
OCDeviceInfo deviceInfo;
m_result = OCSetDeviceInfo(deviceInfo);
ASSERT_EQ(OC_STACK_INVALID_PARAM,m_result) << "OCSetDeviceInfo failed. Actual m_result : " << CommonUtil::s_OCStackResultString.at(m_result);
}
catch(exception &e)
{
SET_FAILURE("Exception occured. Exception is " + std::string(e.what()));
}
}
#endif
/**
* @since 2016-07-19
* @see OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
......
/******************************************************************
*
* Copyright 2016 Samsung Electronics All Rights Reserved.
*
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* LICENSE-2.0" target="_blank">http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
******************************************************************/
#ifndef NS_SIMULATOR_CPP_COMMON_HELPER
#define NS_SIMULATOR_CPP_COMMON_HELPER
#include <iostream>
#include <string>
#include "ocstack.h"
#include "octypes.h"
#include "oic_string.h"
#include "OCPlatform.h"
#include "CommonUtil.h"
#include "IotivityTest_Logger.h"
#include "NSCommon.h"
#include "NSConsumerService.h"
#include "NSProviderService.h"
using namespace std;
using namespace OC;
using namespace OIC::Service;
#endif /* NS_SIMULATOR_CPP_COMMON_HELPER */
/******************************************************************
*
* Copyright 2016 Samsung Electronics All Rights Reserved.
*
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* LICENSE-2.0" target="_blank">http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
******************************************************************/
#include <NSSimulatorCppUtil.h>
bool isStarted = false;
NSConsumerService* g_pNSConsumerServiceInstance = nullptr;
static void onProviderDiscovered(OIC::Service::NSProvider* provider)
{
IOTIVITYTEST_LOG(INFO, "%s is called", __func__);
string providerId = provider->getProviderId();
IOTIVITYTEST_LOG(INFO, "Provider ID is: %s", providerId.c_str());
}
void startConsumer()
{
IOTIVITYTEST_LOG(INFO, "Starting Consumer.......");
g_pNSConsumerServiceInstance = OIC::Service::NSConsumerService::getInstance();
try
{
g_pNSConsumerServiceInstance->start(onProviderDiscovered);
}
catch (exception &e)
{
IOTIVITYTEST_LOG(INFO, "Exception occured while starting consumer....");
}
}
void stopConsumer()
{
try
{
g_pNSConsumerServiceInstance->stop();
}
catch (exception &e)
{
SET_FAILURE("Exception occurs while calling stop. Exception is: " + string(e.what()));
}
}
void chooseOption(int a)
{
switch (a)
{
case 0:
startConsumer();
break;
default:
IOTIVITYTEST_LOG(INFO, "Simulator will configured as default...");
startConsumer();
break;
}
}
int main(int argc, char **argv)
{
PlatformConfig config
{ ServiceType::InProc, ModeType::Both, "0.0.0.0", 0, QualityOfService::LowQos };
OCPlatform::Configure(config);
IOTIVITYTEST_LOG(INFO, "Platform Configuration Done!!");
try
{
OCPlatform::stopPresence();
IOTIVITYTEST_LOG(INFO, "Successfully stopPresense() called !!");
}
catch (...)
{
IOTIVITYTEST_LOG(WARNING, "Can't stop presense..!!!");
}
int inCase = 0;
if (argc > 1)
{
try
{
inCase = atoi(argv[1]);
}
catch (...)
{
inCase = 0;
}
}
chooseOption(inCase);
IOTIVITYTEST_LOG(INFO, "Press any key and the enter to stop the servers :-)....");
char n;
cin >> n;
stopConsumer();
return 0;
}
/******************************************************************
*
* Copyright 2016 Samsung Electronics All Rights Reserved.
*
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* LICENSE-2.0" target="_blank">http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
******************************************************************/
#include <NSSimulatorCppUtil.h>
int id = 0;
OIC::Service::NSProviderService* g_nsProviderService;
const string TEST_TOPIC_1 = "TEST_TOPIC_1";
void syncCallback(OIC::Service::NSSyncInfo *sync)
{
IOTIVITYTEST_LOG(INFO, "NSProviderSyncInfoCallback() called !!");
}
void subscribeRequestCallback(OIC::Service::NSConsumer *consumer)
{
IOTIVITYTEST_LOG(INFO, "subscribeRequestCallback() called !!");
IOTIVITYTEST_LOG(INFO, "Consumer ID: %s", consumer->getConsumerId().c_str());
consumer->acceptSubscription(true);
g_nsProviderService->registerTopic(TEST_TOPIC_1);
}
void startProvider(bool policy)
{
NSProviderService::ProviderConfig cfg;
cfg.m_subscribeRequestCb = subscribeRequestCallback;
cfg.m_syncInfoCb = syncCallback;
if (policy == true)
{
cfg.subControllability = true;
}
else
{
cfg.subControllability = false;
}
g_nsProviderService = NSProviderService::getInstance();
g_nsProviderService->start(cfg);
}
void chooseOption(int a)
{
switch (a)
{
case 0:
startProvider(true);
break;
case 1:
startProvider(false);
break;
default:
IOTIVITYTEST_LOG(INFO, "Simulator will configured as default...");
startProvider(true);
break;
}
}
int main(int argc, char **argv)
{
PlatformConfig config
{ ServiceType::InProc, ModeType::Both, "0.0.0.0", 0, QualityOfService::LowQos };
OCPlatform::Configure(config);
IOTIVITYTEST_LOG(INFO, "Platform Configuration Done!!");
try
{
OCPlatform::stopPresence();
IOTIVITYTEST_LOG(INFO, "Successfully stopPresense() called !!");
}
catch (...)
{
IOTIVITYTEST_LOG(WARNING, "Can't stop presense..!!!");
}
int inCase = 0;
if (argc > 1)
{
try
{
inCase = atoi(argv[1]);
}
catch (...)
{
inCase = 0;
}
}
chooseOption(inCase);
IOTIVITYTEST_LOG(INFO, "Press any key and the enter to stop the servers :-)....");
char n;
cin >> n;
g_nsProviderService->stop();
return 0;
}
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