Build: reworked unit tests to use gtest in a more generic way
[platform/upstream/iotivity.git] / resource / c_common / oic_string / test / SConscript
index 9d30251..29f394a 100644 (file)
 #
 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
-Import('env')
 import os
+import os.path
 
-stringtest_env = env.Clone()
-src_dir = stringtest_env.get('SRC_DIR')
+# SConscript file for Local PKI google tests
+gtest_env = SConscript('#extlibs/gtest/SConscript')
+stringtest_env = gtest_env.Clone()
+target_os = stringtest_env.get('TARGET_OS')
 
 ######################################################################
 # Build flags
 ######################################################################
-stringtest_env.PrependUnique(CPPPATH = [
-        '../include',
-        '#extlibs/gtest/gtest-1.7.0/include' ])
+stringtest_env.PrependUnique(CPPPATH = ['../include'])
 
-stringtest_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource/c_common')])
-stringtest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
-stringtest_env.PrependUnique(LIBS = ['c_common', 'gtest', 'gtest_main', 'pthread'])
-
-if env.get('LOGGING'):
-       stringtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+stringtest_env.AppendUnique(LIBPATH = [os.path.join(stringtest_env.get('BUILD_DIR'), 'resource', 'c_common')])
+stringtest_env.PrependUnique(LIBS = ['c_common'])
+if target_os not in ['windows']:
+    stringtest_env.PrependUnique(LIBS = ['pthread'])
+stringtest_env.PrependUnique(LIBS = ['gtest', 'gtest_main'])
+if stringtest_env.get('LOGGING'):
+    stringtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 #
 ######################################################################
 # Source files and Targets
@@ -45,10 +46,9 @@ stringtests = stringtest_env.Program('stringtests', ['linux/oic_string_tests.cpp
 
 Alias("test", [stringtests])
 
-env.AppendTarget('test')
-if env.get('TEST') == '1':
-       target_os = env.get('TARGET_OS')
-       if target_os == 'linux':
+stringtest_env.AppendTarget('test')
+if stringtest_env.get('TEST') == '1':
+    if target_os in ['linux']:
                 from tools.scons.RunTest import *
                 run_test(stringtest_env,
                          'resource_ccommon_string_test.memcheck',