try:
from subprocess import Popen, call, PIPE
except ImportError:
- raise ImportError("can import Popen, call from subprocess, exit.")
+ raise ImportError("cannot import Popen from subprocess, exit.")
try:
from shutil import copyfile
except ImportError:
- raise ImportError("can import copyfile from shutil, exit.")
+ raise ImportError("cannot import copyfile from shutil, exit.")
Import('test_env')
rd_mode = sptest_env.get('RD_MODE')
out_dir = sptest_env.get('BUILD_DIR')
-
unittest_dir = 'resource/csdk/security/provisioning/unittest/'
-sec_provisioning_src_dir = sptest_env.get('SRC_DIR') + '/resource/csdk/security/provisioning/sample/'
-unittest_build_dir = sptest_env.get('BUILD_DIR') + unittest_dir
+sec_provisioning_src_dir = src_dir + '/resource/csdk/security/provisioning/sample/'
+unittest_build_dir = out_dir + unittest_dir
sptest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
-sptest_env.AppendENVPath('PATH', [sptest_env.get('BUILD_DIR'), unittest_build_dir])
+sptest_env.AppendENVPath('PATH', [out_dir, unittest_build_dir])
+
######################################################################
# Config files
cfg_client = 'oic_svr_db_client.dat'
server_bin = 'sample_server' + sptest_env.get('PROGSUFFIX')
unittest_bin = 'unittest' + sptest_env.get('PROGSUFFIX')
+
+
######################################################################
# Functions
######################################################################
def safe_remove(file_name):
if path.isfile(file_name):
- print 'Removing: '+ file_name
+ print 'Removing: ' + file_name
remove(file_name)
+
def clean_config():
print 'Clean configs'
safe_remove('oic_svr_db_server1.dat')
safe_remove('secureresourceprovider.dat')
safe_remove('device_properties.dat')
+
def start_srv(num):
if not path.isfile(unittest_build_dir + server_bin):
print "no executable file"
return
- cfg_srv = 'oic_svr_db_server'+num+'.dat'
+ cfg_srv = 'oic_svr_db_server' + num + '.dat'
copyfile(sec_provisioning_src_dir + 'oic_svr_db_server_justworks.dat', cfg_srv)
if not sptest_env.get('RELEASE'):
- po = Popen(unittest_build_dir + server_bin + ' '+num+' ' + cfg_srv,
- shell=True, universal_newlines=True, stdout=open('srv'+num+'.log', 'w'))
+ po = Popen(
+ unittest_build_dir + server_bin + ' ' + num + ' ' + cfg_srv,
+ shell=True,
+ universal_newlines=True,
+ stdout=open('srv' + num + '.log', 'w'))
else:
po = Popen([unittest_build_dir + server_bin, num, cfg_srv])
print "start server ", num, " pid: ", po.pid
return po
+
def kill_all():
if target_os in ['msys_nt', 'windows']:
from signal import SIGTERM
- for line in Popen('tasklist /FI "IMAGENAME eq '+server_bin+'" /NH', stdout=PIPE).stdout.readlines():
+ ptask = 'tasklist /FI "IMAGENAME eq ' + server_bin + '" /NH'
+ for line in Popen(ptask, stdout=PIPE).stdout.readlines():
cmd_list = line.decode('cp866', 'ignore').split()
if len(cmd_list):
if not cmd_list[1].isdigit():
except ImportError:
print "can not process check"
+
def run_test(target, source, env):
kill_all()
clean_config()
po_srv2.terminate()
clean_config()
kill_all()
+
+
######################################################################
# Build flags
######################################################################
with_upstream_libcoap = sptest_env.get('WITH_UPSTREAM_LIBCOAP')
if with_upstream_libcoap == '1':
- sptest_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+ sptest_env.AppendUnique(CPPPATH=['#extlibs/libcoap/libcoap/include'])
else:
- sptest_env.AppendUnique(CPPPATH = ['../../../connectivity/lib/libcoap-4.1.1/include'])
-
-sptest_env.PrependUnique(CPPPATH = [
- '../include',
- '../../include',
- '../include/internal',
- '../../../include',
- '../../../ocrandom/include',
- '../../../logger/include',
- '../../../stack/include',
- '../../../security/include',
- '../../../security/include/internal',
- '../../../security/provisioning/include/internal',
- '../../../../oc_logger/include',
- '../include/oxm',
- '../../../../../extlibs/base64',
- '../../../connectivity/inc',
- '../../../connectivity/inc/pkix',
- '../../../connectivity/common/inc',
- '../../../connectivity/api'
- ])
+ sptest_env.AppendUnique(CPPPATH=['../../../connectivity/lib/libcoap-4.1.1/include'])
+
+sptest_env.PrependUnique(CPPPATH=[
+ '../include',
+ '../../include',
+ '../include/internal',
+ '../../../include',
+ '../../../ocrandom/include',
+ '../../../logger/include',
+ '../../../stack/include',
+ '../../../security/include',
+ '../../../security/include/internal',
+ '../../../security/provisioning/include/internal',
+ '../../../../oc_logger/include',
+ '../include/oxm',
+ '../../../../../extlibs/base64',
+ '../../../connectivity/inc',
+ '../../../connectivity/inc/pkix',
+ '../../../connectivity/common/inc',
+ '../../../connectivity/api'
+])
sptest_env.PrependUnique(LIBS=[
'ocpmapi_internal',
sptest_env.AppendUnique(LIBS=['sqlite3'])
else:
if target_os in ['linux', 'tizen']:
- sptest_env.ParseConfig('pkg-config --cflags --libs sqlite3 gobject-2.0 gio-2.0 glib-2.0')
-# TODO: remove this workaround needed for g++-4.7
- sptest_env.Append(LIBS = ['m'])
+ sptest_env.ParseConfig(
+ 'pkg-config --cflags --libs sqlite3 gobject-2.0 gio-2.0 glib-2.0')
+ # TODO: remove this workaround needed for g++-4.7
+ sptest_env.Append(LIBS=['m'])
######################################################################
# Source files and Targets
######################################################################
-unittest_src = ['pmutilitytest.cpp',
- 'secureresourceprovider.cpp',
- 'provisioningdatabasemanager.cpp',
- 'ocprovisioningmanager.cpp',
- 'credentialgeneratortest.cpp',
- 'otmunittest.cpp'
- ]
+unittest_src = [
+ 'pmutilitytest.cpp',
+ 'secureresourceprovider.cpp',
+ 'provisioningdatabasemanager.cpp',
+ 'ocprovisioningmanager.cpp',
+ 'credentialgeneratortest.cpp',
+ 'otmunittest.cpp',
+]
tests = sptest_env.Program(unittest_bin, unittest_src)
server = sptest_env.Program(server_bin, ['sampleserver.cpp'])