##
import os
+import shutil
Import('env')
src_dir = gtest_env.get('SRC_DIR')
targets_need_gtest = ['darwin','linux', 'msys_nt', 'windows']
-gtest_dir = os.path.join(src_dir, 'extlibs', 'gtest', 'gtest-1.7.0')
+gtest_dir = os.path.join(src_dir, 'extlibs', 'gtest', 'googletest-release-1.7.0')
gtest_lib_dir = os.path.join(gtest_dir,'lib')
gtest_dotlib_dir = os.path.join(gtest_lib_dir, '.libs')
-gtest_zip_file = os.path.join(src_dir, 'extlibs', 'gtest', 'gtest-1.7.0.zip')
-gtest_url = 'http://pkgs.fedoraproject.org/repo/pkgs/gtest/gtest-1.7.0.zip/2d6ec8ccdf5c46b05ba54a9fd1d130d7/gtest-1.7.0.zip'
+gtest_zip_file = os.path.join(src_dir, 'extlibs', 'gtest', 'release-1.7.0.zip')
+gtest_url = 'https://github.com/google/googletest/archive/release-1.7.0.zip'
if target_os in targets_need_gtest:
print '*** Checking for installation of google unit test 1.7.0 ***'
print 'Unzipping to : ' + gtest_dir
gtest_env.UnpackAll(gtest_dir, gtest_zip)
-if target_os == 'darwin':
- if os.path.exists(gtest_dir):
- # Build gtest and store it at a temporary directory
-
- if not os.path.exists(gtest_lib_dir):
-# print 'Create a directory'
-# os.mkdir(gtest_lib_dir)
-
-
- print 'Invoke cmake command to generate appropriate make files'
- gtest_env.Configure(gtest_dir, './configure')
-
- # Run make on gtest
- print 'Making google unit test'
- gtest_env.Configure(gtest_dir, 'make')
-
-# print 'Create a directory'
-# os.mkdir(gtest_dotlib_dir)
-
- print 'Change to a directory'
- os.chdir(gtest_dotlib_dir)
-
-## print 'Change to a directory'
-# os.chdir(gtest_lib_dir)
-
- print 'Create hard links pointing to gtest libraries'
- os.link('libgtest.a', gtest_lib_dir + 'libgtest.a')
- os.link('libgtest_main.a', gtest_lib_dir + 'libgtest_main.a')
- print 'Create hard links pointing to gtest libraries - DONE'
-
-
-elif target_os in ['linux']:
+if target_os in ['linux']:
if os.path.exists(gtest_dir):
if not os.path.exists(gtest_lib_dir):
# Run configure on gtest
print 'Configuring google unit test'
+ reconfigure_ran = gtest_env.Configure(gtest_dir, 'autoreconf -i')
if env.get('CROSS_COMPILE'):
- env.Configure(gtest_dir, './configure --disable-shared --host=' + env['CROSS_COMPILE'])
+ configure_ran = env.Configure(gtest_dir, './configure --disable-shared --host=' + env['CROSS_COMPILE'])
+ gtest_env.Depends(configure_ran, reconfigure_ran)
else:
- env.Configure(gtest_dir, './configure --disable-shared')
+ configure_ran = env.Configure(gtest_dir, './configure --disable-shared')
+ gtest_env.Depends(configure_ran, reconfigure_ran)
# Run make on gtest
print 'Making google unit test'
- gtest_env.Configure(gtest_dir, 'make')
+ make_ran = gtest_env.Configure(gtest_dir, 'make')
+ gtest_env.Depends(make_ran, configure_ran)
-elif target_os == 'msys_nt':
+elif target_os in ['darwin', 'msys_nt']:
if os.path.exists(gtest_dir):
if not os.path.exists(gtest_lib_dir):
# Create lib dir
gtest_env.Configure(gtest_dir, 'cp libgtest_main.a lib')
gtest_env.Configure(gtest_dir, 'mv libgtest_main.a lib/.libs')
-elif target_os == 'windows':
+elif target_os in ['windows']:
# Avoid building the same StaticLibrary in more than one environment, by using the
# IOTIVITY_GTEST_HAS_BEEN_BUILT environment variable
if not env.has_key('IOTIVITY_GTEST_HAS_BEEN_BUILT'):
if target_os in ['windows']:
gtest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
+
Return('gtest_env')
in auto_build.sh which is also in the the repository root directory.
To dynamically link with the Google Unit test library,
-add <src_dir>/extlibs/gtest/gtest-1.7.0/lib/.libs/ to LD_LIBRARY_PATH
+add <src_dir>/extlibs/gtest/googletest-release-1.7.0/lib/.libs/ to LD_LIBRARY_PATH
//---------------------------------------------------------------------
For example:
- GTEST_DIR := /home/johndoe/utils/gtest-1.7.0
+ GTEST_DIR := /home/johndoe/utils/googletest-release-1.7.0
3. The unit test assumes that a network interface is available
(e.g. "eth0", "wlan0", etc.)
6. Export LD_LIBRARY_PATH before running the unit tests.
Example:
- export LD_LIBRARY_PATH=/home/tester/Documents/iotivity/extlibs/gtest/gtest-1.7.0/lib/.libs/
+ export LD_LIBRARY_PATH=/home/tester/Documents/iotivity/extlibs/gtest/googletest-release-1.7.0/lib/.libs/
7. Run the unit test by issuing the following command from root 'iotivity' folder
./out/<TARGET_OS>/<TARGET_ARCH>/<release/debug>/resource/csdk/stack/test
scons VERBOSE=1 %BUILD_OPTIONS% -c clean
rd /s /q out
del .sconsign.dblite
- del extlibs\gtest\gtest*.lib
- del extlibs\gtest\gtest-1.7.0\src\gtest*.obj
+ del extlibs\gtest\googletest*.lib
+ del extlibs\gtest\googletest-release-1.7.0\src\gtest*.obj
erase /s *.obj
erase resource\c_common\iotivity_config.h
erase extlibs\libcoap\coap.lib
erase extlibs\libcoap\libcoap\include\coap\coap_config.h
erase extlibs\mbedtls\mbed*.lib
) else if "!RUN_ARG!"=="cleangtest" (
- rd /s /q extlibs\gtest\gtest-1.7.0
- del extlibs\gtest\gtest-1.7.0.zip
+ rd /s /q extlibs\gtest\googletest-release-1.7.0
+ del extlibs\gtest\release-1.7.0.zip
) else (
echo.%0 - Script requires a valid argument!
goto :EOF